Class: Ledmon::Configurator
- Inherits:
-
Object
- Object
- Ledmon::Configurator
- Defined in:
- lib/ledmon/configurator.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #http_base_url ⇒ Object
-
#initialize ⇒ Configurator
constructor
A new instance of Configurator.
Constructor Details
#initialize ⇒ Configurator
Returns a new instance of Configurator.
5 6 7 8 9 10 11 12 |
# File 'lib/ledmon/configurator.rb', line 5 def initialize @config = TTY::Config.new config.filename = '.ledmon' config.append_path Dir.pwd config.env_prefix = 'ledmon' config.read if config.exist? end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
3 4 5 |
# File 'lib/ledmon/configurator.rb', line 3 def config @config end |
Class Method Details
.config_value(name, keys: nil, default: nil) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/ledmon/configurator.rb', line 14 def self.config_value(name, keys: nil, default: nil) keys = Array(keys || name).map(&:to_sym) define_method(name) do read_value(keys, default:) end define_method("#{name}=") do |value| write_value(keys, value:) end end |
Instance Method Details
#http_base_url ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ledmon/configurator.rb', line 35 def http_base_url port = if http_proto == 'https' && http_port != 443 ":#{http_port}" elsif http_proto == 'http' && http_port != 80 ":#{http_port}" else '' end "#{http_proto}://#{host}#{port}" end |