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.



7
8
9
10
11
12
13
14
15
# File 'lib/theine/config.rb', line 7

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

Instance Attribute Details

#base_portObject

Returns the value of attribute base_port.



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

def base_port
  @base_port
end

#max_portObject

Returns the value of attribute max_port.



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

def max_port
  @max_port
end

#min_free_workersObject

Returns the value of attribute min_free_workers.



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

def min_free_workers
  @min_free_workers
end

#rails_rootObject (readonly)

Returns the value of attribute rails_root.



5
6
7
# File 'lib/theine/config.rb', line 5

def rails_root
  @rails_root
end

#spawn_parallelObject

Returns the value of attribute spawn_parallel.



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

def spawn_parallel
  @spawn_parallel
end

Instance Method Details

#load_config(path) ⇒ Object



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

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