Module: Lakitu::Options

Defined in:
lib/lakitu/options.rb

Constant Summary collapse

DEFAULTS =
{
  refresh_interval_minutes: 10
}
PROFILE_DEFAULTS =
{
  ignore: false,
  format: "%{profile}-%{name}-%{id}"
}
@@options =
nil

Class Method Summary collapse

Class Method Details

.config_optionsObject



29
30
31
32
# File 'lib/lakitu/options.rb', line 29

def self.config_options
  return { } unless File.exist?(Lakitu::OPTIONS_FILE_PATH)
  deep_symbolize_keys(::YAML::load(File.read(Lakitu::OPTIONS_FILE_PATH)) || {})
end

.default_configObject



34
35
36
37
# File 'lib/lakitu/options.rb', line 34

def self.default_config
  create_provider_defaults
  YAML.dump(deep_stringify_keys(options.to_h))
end

.merge(arg) ⇒ Object



25
26
27
# File 'lib/lakitu/options.rb', line 25

def self.merge arg
  @@options = OpenStruct.new(options.to_h.merge arg)
end

.optionsObject



14
15
16
17
18
19
# File 'lib/lakitu/options.rb', line 14

def self.options
  unless @@options
    @@options = OpenStruct.new(DEFAULTS.merge config_options)
  end
  @@options
end

.options=(arg) ⇒ Object



21
22
23
# File 'lib/lakitu/options.rb', line 21

def self.options= arg
  @@options = arg ? OpenStruct.new(arg) : arg
end