Class: GemChangelogDiff::ConfigLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_changelog_diff/config_loader.rb

Overview

Loads and merges YAML config from user and project locations.

Constant Summary collapse

USER_CONFIG_DIR =
File.join(Dir.home, ".config", "gem_changelog_diff")
USER_CONFIG_PATH =
File.join(USER_CONFIG_DIR, "config.yml")
PROJECT_CONFIG_NAME =
".gem_changelog_diff.yml"

Instance Method Summary collapse

Constructor Details

#initialize(project_dir: Dir.pwd) ⇒ ConfigLoader

Returns a new instance of ConfigLoader.



12
13
14
# File 'lib/gem_changelog_diff/config_loader.rb', line 12

def initialize(project_dir: Dir.pwd)
  @project_dir = project_dir
end

Instance Method Details

#loadHash<Symbol, Object>

Loads config from user and project files, with project taking priority.

Returns:

  • (Hash<Symbol, Object>)


18
19
20
21
22
# File 'lib/gem_changelog_diff/config_loader.rb', line 18

def load
  user_config = load_file(USER_CONFIG_PATH)
  project_config = load_file(project_config_path)
  user_config.merge(project_config)
end