Class: Theine::ConfigReader

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rails_root) ⇒ ConfigReader

Returns a new instance of ConfigReader.



15
16
17
18
19
20
21
22
23
24
# File 'lib/theine/config.rb', line 15

def initialize(rails_root)
  @rails_root = rails_root
  @base_port = 11000
  @max_port = 11100
  @min_free_workers = 2
  @spawn_parallel = true
  @silent = false
  load_config(File.expand_path("~/.theine"))
  load_config("#{rails_root}/.theine")
end

Instance Attribute Details

#base_portObject

Returns the value of attribute base_port.



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

def base_port
  @base_port
end

#max_portObject

Returns the value of attribute max_port.



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

def max_port
  @max_port
end

#min_free_workersObject

Returns the value of attribute min_free_workers.



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

def min_free_workers
  @min_free_workers
end

#rails_rootObject (readonly)

Returns the value of attribute rails_root.



13
14
15
# File 'lib/theine/config.rb', line 13

def rails_root
  @rails_root
end

#silentObject

Returns the value of attribute silent.



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

def silent
  @silent
end

#spawn_parallelObject

Returns the value of attribute spawn_parallel.



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

def spawn_parallel
  @spawn_parallel
end

Instance Method Details

#load_config(path) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/theine/config.rb', line 26

def load_config(path)
  if File.exist?(path)
    config = YAML.load(File.read(path))
    config.each_pair do |k, v|
      setter = :"#{k}="
      send(setter, v) if respond_to?(setter)
    end
  end
end