Class: Clockker::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/clockker/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(overrides = {}) ⇒ Config

Returns a new instance of Config.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/clockker/config.rb', line 6

def initialize(overrides = {})
  if File.exists?(File.join(Dir.home, '.clockker'))
    clockker_config = JSON.parse(File.read(File.join(Dir.home, '.clockker')))
  else
    clockker_config = '{}'
  end

  # Set values from clockker_config
  @whitelist = clockker_config["whitelist"]
  @blacklist = clockker_config["blacklist"]
  @url_whitelist = clockker_config["url_whitelist"]
  @config_version = clockker_config["version"]
  @token = clockker_config["token"]
  @region = clockker_config["region"]
  @submit_frequency = clockker_config["submit_frequency"]
  @log_level = clockker_config["log_level"]
  @development = clockker_config["development"]

  # override values specified at the command line
  overrides.each do |key, value|
    instance_variable_set "@#{key}".to_sym, value
  end
end

Instance Attribute Details

#blacklistObject

Returns the value of attribute blacklist.



5
6
7
# File 'lib/clockker/config.rb', line 5

def blacklist
  @blacklist
end

#config_versionObject

Returns the value of attribute config_version.



5
6
7
# File 'lib/clockker/config.rb', line 5

def config_version
  @config_version
end

#developmentObject

Returns the value of attribute development.



5
6
7
# File 'lib/clockker/config.rb', line 5

def development
  @development
end

#identifierObject

Returns the value of attribute identifier.



5
6
7
# File 'lib/clockker/config.rb', line 5

def identifier
  @identifier
end

#log_levelObject

Returns the value of attribute log_level.



5
6
7
# File 'lib/clockker/config.rb', line 5

def log_level
  @log_level
end

#regionObject

Returns the value of attribute region.



5
6
7
# File 'lib/clockker/config.rb', line 5

def region
  @region
end

#submit_frequencyObject

Returns the value of attribute submit_frequency.



5
6
7
# File 'lib/clockker/config.rb', line 5

def submit_frequency
  @submit_frequency
end

#tokenObject

Returns the value of attribute token.



5
6
7
# File 'lib/clockker/config.rb', line 5

def token
  @token
end

#url_whitelistObject

Returns the value of attribute url_whitelist.



5
6
7
# File 'lib/clockker/config.rb', line 5

def url_whitelist
  @url_whitelist
end

#whitelistObject

Returns the value of attribute whitelist.



5
6
7
# File 'lib/clockker/config.rb', line 5

def whitelist
  @whitelist
end