Class: Theine::ConfigReader
- Inherits:
-
Object
- Object
- Theine::ConfigReader
- Defined in:
- lib/theine/config.rb
Instance Attribute Summary collapse
-
#base_port ⇒ Object
Returns the value of attribute base_port.
-
#max_port ⇒ Object
Returns the value of attribute max_port.
-
#min_free_workers ⇒ Object
Returns the value of attribute min_free_workers.
-
#rails_root ⇒ Object
readonly
Returns the value of attribute rails_root.
-
#spawn_parallel ⇒ Object
Returns the value of attribute spawn_parallel.
Instance Method Summary collapse
-
#initialize(rails_root) ⇒ ConfigReader
constructor
A new instance of ConfigReader.
- #load_config(path) ⇒ Object
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.("~/.theine")) load_config("#{rails_root}/.theine") end |
Instance Attribute Details
#base_port ⇒ Object
Returns the value of attribute base_port.
6 7 8 |
# File 'lib/theine/config.rb', line 6 def base_port @base_port end |
#max_port ⇒ Object
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_workers ⇒ Object
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_root ⇒ Object (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_parallel ⇒ Object
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 |