Class: Rigit::Config

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

Overview

Handles the rig config file. Usage example:

Config.load 'path/to.yml'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.



18
19
20
# File 'lib/rigit/config.rb', line 18

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



11
12
13
# File 'lib/rigit/config.rb', line 11

def path
  @path
end

Class Method Details

.load(path) ⇒ Object

Returns a new configatron instance, after loading from a YAML file.



14
15
16
# File 'lib/rigit/config.rb', line 14

def self.load(path)
  new(path).settings
end

Instance Method Details

#settingsObject



22
23
24
# File 'lib/rigit/config.rb', line 22

def settings
  @settings ||= settings!
end

#settings!Object



26
27
28
29
30
# File 'lib/rigit/config.rb', line 26

def settings!
  settings = Configatron::RootStore.new
  settings.configure_from_hash YAML.load_file(path) if File.exist? path
  settings
end