Class: PG::AWS_RDS_IAM::ConnectionInfo::URI
- Inherits:
-
Object
- Object
- PG::AWS_RDS_IAM::ConnectionInfo::URI
- Defined in:
- lib/pg/aws_rds_iam/connection_info/uri.rb
Instance Attribute Summary collapse
-
#auth_token_generator_name ⇒ Object
readonly
Returns the value of attribute auth_token_generator_name.
Class Method Summary collapse
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(connection_string) ⇒ URI
constructor
A new instance of URI.
- #password=(value) ⇒ Object
- #port ⇒ Object
- #to_s ⇒ Object
- #user ⇒ Object
Constructor Details
#initialize(connection_string) ⇒ URI
Returns a new instance of URI.
20 21 22 23 24 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 20 def initialize(connection_string) @uri = ::URI.parse(connection_string) @query = @uri.query ? ::URI.decode_www_form(@uri.query).to_h : {} @auth_token_generator_name = @query.delete("aws_rds_iam_auth_token_generator") end |
Instance Attribute Details
#auth_token_generator_name ⇒ Object (readonly)
Returns the value of attribute auth_token_generator_name.
18 19 20 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 18 def auth_token_generator_name @auth_token_generator_name end |
Class Method Details
.match?(connection_string) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 7 def self.match?(connection_string) regexp = if defined?(::URI::RFC2396_PARSER) ::URI::RFC2396_PARSER.regexp[:ABS_URI_REF] else ::URI::ABS_URI_REF end /\A#{regexp}\z/.match?(connection_string) end |
Instance Method Details
#host ⇒ Object
30 31 32 33 34 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 30 def host return @query["host"] if @uri.host.nil? || @uri.host.empty? @uri.host end |
#password=(value) ⇒ Object
40 41 42 43 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 40 def password=(value) @uri.password = nil @query["password"] = value end |
#port ⇒ Object
36 37 38 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 36 def port @uri.port || @query["port"] end |
#to_s ⇒ Object
45 46 47 48 49 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 45 def to_s @uri.query = ::URI.encode_www_form(@query) @uri.to_s.sub(%r{^#{@uri.scheme}:(?!//)}, "#{@uri.scheme}://") end |
#user ⇒ Object
26 27 28 |
# File 'lib/pg/aws_rds_iam/connection_info/uri.rb', line 26 def user @uri.user || @query["user"] end |