Class: Semi::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commandsObject (readonly)

Returns the value of attribute commands.



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

def commands
  @commands
end

#defaultsObject (readonly)

Returns the value of attribute defaults.



6
7
8
# File 'lib/semi/config.rb', line 6

def defaults
  @defaults
end

#filesObject (readonly)

Returns the value of attribute files.



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

def files
  @files
end

#validatorsObject (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