Class: Downspout::Credential
- Inherits:
-
Object
- Object
- Downspout::Credential
- Defined in:
- lib/downspout/credential.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#pass_word ⇒ Object
Returns the value of attribute pass_word.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = nil) ⇒ Credential
constructor
A new instance of Credential.
Constructor Details
#initialize(options = nil) ⇒ Credential
Returns a new instance of Credential.
10 11 12 13 14 15 16 |
# File 'lib/downspout/credential.rb', line 10 def initialize( = nil ) if && .respond_to?(:keys) then .each do |key, value| self.send("#{key}=", value) if self.respond_to?("#{key}=") end end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
5 6 7 |
# File 'lib/downspout/credential.rb', line 5 def host @host end |
#pass_word ⇒ Object
Returns the value of attribute pass_word.
8 9 10 |
# File 'lib/downspout/credential.rb', line 8 def pass_word @pass_word end |
#port ⇒ Object
Returns the value of attribute port.
6 7 8 |
# File 'lib/downspout/credential.rb', line 6 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme.
4 5 6 |
# File 'lib/downspout/credential.rb', line 4 def scheme @scheme end |
#user_name ⇒ Object
Returns the value of attribute user_name.
7 8 9 |
# File 'lib/downspout/credential.rb', line 7 def user_name @user_name end |
Class Method Details
.create_from_uri(some_uri) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/downspout/credential.rb', line 31 def self.create_from_uri( some_uri ) if some_uri.userinfo.nil? then return nil end cred_hash = {} cred_hash[:scheme] = some_uri.scheme cred_hash[:host] = some_uri.host cred_hash[:port] = some_uri.port cred_hash[:user_name] = some_uri.user cred_hash[:pass_word] = some_uri.password cred = Credential.new( cred_hash ) return cred end |
.create_from_url(some_url) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/downspout/credential.rb', line 18 def self.create_from_url( some_url ) cred_hash = {} begin some_uri = URI::parse( some_url ) rescue NoMethodError => e # convert to Invalid URI as that's the more pertinent issue raise URI::InvalidURIError, e.to_s end return Credential.create_from_uri( some_uri ) end |