Class: Cadre::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(valise, component) ⇒ Config


3
4
5
6
# File 'lib/cadre/config.rb', line 3

def initialize(valise, component)
  @valise = valise
  @component = component
end

Instance Attribute Details

#componentObject (readonly)

Returns the value of attribute component


7
8
9
# File 'lib/cadre/config.rb', line 7

def component
  @component
end

#valiseObject (readonly)

Returns the value of attribute valise


7
8
9
# File 'lib/cadre/config.rb', line 7

def valise
  @valise
end

Instance Method Details

#backtrace_limitObject


41
42
43
# File 'lib/cadre/config.rb', line 41

def backtrace_limit
  value_or_fail('backtrace_limit')
end

#backtrace_patternObject


37
38
39
# File 'lib/cadre/config.rb', line 37

def backtrace_pattern
  Regexp.new(value_or_fail('backtrace_pattern'))
end

#config_hashObject


9
10
11
# File 'lib/cadre/config.rb', line 9

def config_hash
  valise.find("config.yaml").contents
end

#include_pendingObject Also known as: include_pending?


45
46
47
# File 'lib/cadre/config.rb', line 45

def include_pending
  !!value_or_fail('include_pending')
end

#output_pathObject


23
24
25
# File 'lib/cadre/config.rb', line 23

def output_path
  value_or_fail("output_path", false)
end

#quietObject Also known as: quiet?


32
33
34
# File 'lib/cadre/config.rb', line 32

def quiet
  !verbose
end

#value_or_fail(value, common = true) ⇒ Object


13
14
15
16
17
18
19
20
21
# File 'lib/cadre/config.rb', line 13

def value_or_fail(value, common=true)
  if common
    config_hash.fetch(component, {}).fetch(value){config_hash.fetch(value)}
  else
    config_hash.fetch(component).fetch(value)
  end
rescue KeyError
  raise "Field not configurated: #{value}" #yep: configurated
end

#verboseObject Also known as: verbose?


27
28
29
# File 'lib/cadre/config.rb', line 27

def verbose
  !!value_or_fail("verbose")
end