Class: RSpectacles::Config
- Inherits:
-
Object
- Object
- RSpectacles::Config
show all
- Defined in:
- lib/rspectacles/config.rb
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
6
7
8
9
|
# File 'lib/rspectacles/config.rb', line 6
def initialize
user_options = load_user_opts
@opts = OpenStruct.new defaults.merge(user_options)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
28
29
30
|
# File 'lib/rspectacles/config.rb', line 28
def method_missing(method, *args)
@opts.send method, *args
end
|
Instance Method Details
#defaults ⇒ Object
11
12
13
14
15
16
17
18
|
# File 'lib/rspectacles/config.rb', line 11
def defaults
{
sinatra_port: 4567,
pubsub_channel_name: 'redis-rspec-examples',
last_run_primary_key: 'redis-rspec-last-run',
redis_uri: 'redis://127.0.0.1:6379/'
}
end
|
#load_user_opts ⇒ Object
20
21
22
23
24
25
26
|
# File 'lib/rspectacles/config.rb', line 20
def load_user_opts
if ENV['RSPECTACLES_CONFIG'] && ::File.exists?(::File.expand_path(ENV['RSPECTACLES_CONFIG']))
YAML.load_file(::File.expand_path(ENV['RSPECTACLES_CONFIG']))
else
{}
end
end
|