Module: Diffend::Configs::Fetcher

Defined in:
lib/diffend/configs/fetcher.rb

Overview

Class responsible for fetching the config from .diffend.yml

Class Method Summary collapse

Class Method Details

.call(plugin_path, build_path) ⇒ Hash

Returns details from configuration file.

Examples:

details = Fetcher.new.call('./')
details.build_path #=> './'

Parameters:

  • plugin_path (String)

    path of the plugin

  • build_path (String)

    path of the current build

Returns:

  • (Hash)

    details from configuration file



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/diffend/configs/fetcher.rb', line 22

def call(plugin_path, build_path)
  default_config = File.join(plugin_path, 'config', 'diffend.yml')
  project_config = File.join(build_path, Diffend::Config::FILENAME)

  hash = read_file(default_config)

  if File.exist?(project_config)
    hash.merge!(read_file(project_config) || {})
  end

  hash
end