Class: Malone::Configuration
- Inherits:
-
Object
- Object
- Malone::Configuration
- Defined in:
- lib/malone.rb
Instance Attribute Summary collapse
-
#auth ⇒ Object
Returns the value of attribute auth.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#force_tls ⇒ Object
Returns the value of attribute force_tls.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#tls ⇒ Object
Returns the value of attribute tls.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
-
#initialize(options) ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize(options) ⇒ Configuration
Returns a new instance of Configuration.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/malone.rb', line 78 def initialize() opts = .dup @tls = true url = opts.delete(:url) || ENV["MALONE_URL"] if url uri = URI(url) opts[:host] ||= uri.host opts[:port] ||= uri.port.to_i opts[:user] ||= unescaped(uri.user) opts[:password] ||= unescaped(uri.password) additional_opts = Hash[uri.query.to_s.split('&').map { |e| e.split('=')}] if additional_opts.has_key?('force_tls') @force_tls = true elsif additional_opts.has_key?('tls') @tls = true end end opts.each do |key, val| send(:"#{key}=", val) end end |
Instance Attribute Details
#auth ⇒ Object
Returns the value of attribute auth.
76 77 78 |
# File 'lib/malone.rb', line 76 def auth @auth end |
#domain ⇒ Object
Returns the value of attribute domain.
73 74 75 |
# File 'lib/malone.rb', line 73 def domain @domain end |
#force_tls ⇒ Object
Returns the value of attribute force_tls.
75 76 77 |
# File 'lib/malone.rb', line 75 def force_tls @force_tls end |
#host ⇒ Object
Returns the value of attribute host.
69 70 71 |
# File 'lib/malone.rb', line 69 def host @host end |
#password ⇒ Object
Returns the value of attribute password.
72 73 74 |
# File 'lib/malone.rb', line 72 def password @password end |
#port ⇒ Object
Returns the value of attribute port.
70 71 72 |
# File 'lib/malone.rb', line 70 def port @port end |
#tls ⇒ Object
Returns the value of attribute tls.
74 75 76 |
# File 'lib/malone.rb', line 74 def tls @tls end |
#user ⇒ Object
Returns the value of attribute user.
71 72 73 |
# File 'lib/malone.rb', line 71 def user @user end |