Method: Constancy::Config#initialize

Defined in:
lib/constancy/config.rb

#initialize(path: nil, targets: nil, call_external_apis: true) ⇒ Config

Returns a new instance of Config.



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/constancy/config.rb', line 51

def initialize(path: nil, targets: nil, call_external_apis: true)
  if path.nil? or File.directory?(path)
    self.config_file = Constancy::Config.discover(dir: path)
  elsif File.exist?(path)
    self.config_file = path
  else
    raise Constancy::ConfigFileNotFound.new
  end

  if self.config_file.nil? or not File.exist?(self.config_file) or not File.readable?(self.config_file)
    raise Constancy::ConfigFileNotFound.new
  end

  self.config_file = File.expand_path(self.config_file)
  self.base_dir = File.dirname(self.config_file)
  self.target_allowlist = targets
  self.call_external_apis = call_external_apis
  parse!
end