Class: Semi::Config
- Inherits:
-
Object
- Object
- Semi::Config
- Defined in:
- lib/semi/config.rb
Instance Attribute Summary collapse
-
#commands ⇒ Object
readonly
Returns the value of attribute commands.
-
#defaults ⇒ Object
readonly
Returns the value of attribute defaults.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#validators ⇒ Object
readonly
Returns the value of attribute validators.
Instance Method Summary collapse
-
#initialize(path = nil) ⇒ Config
constructor
A new instance of Config.
- #load(path) ⇒ Object
Constructor Details
#initialize(path = nil) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/semi/config.rb', line 11 def initialize(path=nil) @defaults = {} @validators = {} @files = [] @commands = {} if path self.load(path) end end |
Instance Attribute Details
#commands ⇒ Object (readonly)
Returns the value of attribute commands.
9 10 11 |
# File 'lib/semi/config.rb', line 9 def commands @commands end |
#defaults ⇒ Object (readonly)
Returns the value of attribute defaults.
6 7 8 |
# File 'lib/semi/config.rb', line 6 def defaults @defaults end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
7 8 9 |
# File 'lib/semi/config.rb', line 7 def files @files end |
#validators ⇒ Object (readonly)
Returns the value of attribute validators.
8 9 10 |
# File 'lib/semi/config.rb', line 8 def validators @validators end |
Instance Method Details
#load(path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/semi/config.rb', line 22 def load(path) data = YAML.load_file(path) if data.key? 'defaults' @defaults = data['defaults'] end if data.key? 'validate' @validators = data['validate'] end if data.key? 'files' @files = data['files'] end if data.key? 'commands' @commands = data['commands'] end return data end |