Class: Malone::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/malone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options)
  opts = options.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

#authObject

Returns the value of attribute auth.



76
77
78
# File 'lib/malone.rb', line 76

def auth
  @auth
end

#domainObject

Returns the value of attribute domain.



73
74
75
# File 'lib/malone.rb', line 73

def domain
  @domain
end

#force_tlsObject

Returns the value of attribute force_tls.



75
76
77
# File 'lib/malone.rb', line 75

def force_tls
  @force_tls
end

#hostObject

Returns the value of attribute host.



69
70
71
# File 'lib/malone.rb', line 69

def host
  @host
end

#passwordObject

Returns the value of attribute password.



72
73
74
# File 'lib/malone.rb', line 72

def password
  @password
end

#portObject

Returns the value of attribute port.



70
71
72
# File 'lib/malone.rb', line 70

def port
  @port
end

#tlsObject

Returns the value of attribute tls.



74
75
76
# File 'lib/malone.rb', line 74

def tls
  @tls
end

#userObject

Returns the value of attribute user.



71
72
73
# File 'lib/malone.rb', line 71

def user
  @user
end