Class: BsPlus::Config
Constant Summary collapse
- HomePath =
File. '~/.browserstack-cred'
- LocalPath =
File. './.browserstack-cred'
- OtherDefaults =
{ }
Class Method Summary collapse
- .all ⇒ Object
- .fetch(key, &blk) ⇒ Object
- .home_config ⇒ Object
- .init ⇒ Object
- .local_config ⇒ Object
- .method_missing(key) ⇒ Object
- .write(key, value) ⇒ Object
- .write_config_file(path, hash) ⇒ Object
Class Method Details
.all ⇒ Object
27 28 |
# File 'lib/bs_plus/config.rb', line 27 def all OtherDefaults.merge(home_config).merge(local_config) end |
.fetch(key, &blk) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bs_plus/config.rb', line 30 def fetch key, &blk unless block_given? all.fetch key else all.fetch key do value = yield write key, value value end end end |
.home_config ⇒ Object
21 22 |
# File 'lib/bs_plus/config.rb', line 21 def home_config YAML.load_file(HomePath ).deep_symbolize_keys rescue {} end |
.init ⇒ Object
10 11 12 13 14 15 |
# File 'lib/bs_plus/config.rb', line 10 def init fetch(:username) {HighLine.new.ask('Please enter your browserstack username')} fetch(:password) {HighLine.new.ask('Please enter your password') {|h| h.echo = false }} end |
.local_config ⇒ Object
24 25 |
# File 'lib/bs_plus/config.rb', line 24 def local_config YAML.load_file(LocalPath).deep_symbolize_keys rescue {} end |
.method_missing(key) ⇒ Object
51 52 53 |
# File 'lib/bs_plus/config.rb', line 51 def method_missing key fetch key end |