You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/06/18 23:57:54 UTC
[16/50] [abbrv] qpid-proton git commit: PROTON-781: Added the URL
class to the Ruby core APIs.
PROTON-781: Added the URL class to the Ruby core APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/29151486
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/29151486
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/29151486
Branch: refs/heads/cjansen-cpp-client
Commit: 29151486c1dfebda79bb6ad977e354dc46948da7
Parents: 6774347
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Wed Mar 4 16:36:39 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 16:28:44 2015 -0400
----------------------------------------------------------------------
proton-c/bindings/ruby/lib/core/url.rb | 77 ++++++++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 78 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/29151486/proton-c/bindings/ruby/lib/core/url.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/core/url.rb b/proton-c/bindings/ruby/lib/core/url.rb
new file mode 100644
index 0000000..a68811a
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/core/url.rb
@@ -0,0 +1,77 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+module Qpid::Proton
+
+ class URL
+
+ attr_reader :scheme
+ attr_reader :username
+ attr_reader :password
+ attr_reader :host
+ attr_reader :port
+ attr_reader :path
+
+ def initialize(url = nil, options = {})
+ options[:defaults] = true
+
+ if url
+ @url = Cproton.pn_url_parse(url)
+ if @url.nil?
+ raise ArgumentError.new("invalid url: #{url}")
+ end
+ else
+ @url = Cproton.pn_url
+ end
+ @scheme = Cproton.pn_url_get_scheme(@url)
+ @username = Cproton.pn_url_get_username(@url)
+ @password = Cproton.pn_url_get_password(@url)
+ @host = Cproton.pn_url_get_host(@url)
+ @port = Cproton.pn_url_get_port(@url)
+ @path = Cproton.pn_url_get_path(@url)
+ defaults
+ end
+
+ def port=(port)
+ if port.nil?
+ Cproton.pn_url_set_port(@url, nil)
+ else
+ Cproton.pn_url_set_port(@url, port)
+ end
+ end
+
+ def port
+ Cproton.pn_url_get_port(@url).to_i
+ end
+
+ def to_s
+ "#{@scheme}://#{@username.nil? ? '' : @username}#{@password.nil? ? '' : '@' + @password + ':'}#{@host}:#{@port}/#{@path}"
+ end
+
+ private
+
+ def defaults
+ @scheme = @scheme || "ampq"
+ @host = @host || "0.0.0.0"
+ @port = @port || 5672
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/29151486/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 33fe9b6..11a555f 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -78,6 +78,7 @@ require "core/ssl_details"
require "core/ssl"
require "core/transport"
require "core/base_handler"
+require "core/url"
# Messenger API classes
require "messenger/subscription"
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org