addressable 2.3.4 → 2.3.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of addressable might be problematic. Click here for more details.

@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7469c2a80add393372ae8c44de978834410a65fc
4
+ data.tar.gz: ff31775eb9800b5aa84260a06c7fb6b6c93c855e
5
+ SHA512:
6
+ metadata.gz: d0542072bdbf9520eed193aa4b8fddb95bd8869662ec23566529bb6ecf9688ccaba3dd4b77bdcea889862d7947a71b9bf4770dbc6eb872cc84b976f781bfd5f2
7
+ data.tar.gz: 39ca65c92ecdc6d4891c794e56876e7a3923182c1de78691c9e0b794eea0d93ffe100766706825a5abefd911ac3f392687992eb04de9bbfd44d33b428fb2d6d4
@@ -1,3 +1,9 @@
1
+ # Addressable 2.3.5
2
+ - added Addressable::URI#empty? method
3
+ - Addressable::URI#hostname methods now strip square brackets from IPv6 hosts
4
+ - compatibility with Net::HTTP in Ruby 2.0.0
5
+ - Addressable::URI#route_from should always give relative URIs
6
+
1
7
  # Addressable 2.3.4
2
8
  - fixed issue with encoding altering its inputs
3
9
  - query string normalization now leaves ';' characters alone
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ end
10
10
  group :test, :development do
11
11
  gem 'rake', '>= 0.7.3'
12
12
  gem 'rspec', '>= 2.9.0'
13
+ gem 'coveralls', :require => false
13
14
  end
14
15
 
15
16
  gem 'idn', :platform => :mri_18
data/README.md CHANGED
@@ -3,12 +3,19 @@
3
3
  <dl>
4
4
  <dt>Homepage</dt><dd><a href="http://addressable.rubyforge.org/">addressable.rubyforge.org</a></dd>
5
5
  <dt>Author</dt><dd><a href="mailto:bob@sporkmonger.com">Bob Aman</a></dd>
6
- <dt>Copyright</dt><dd>Copyright © 2010 Bob Aman</dd>
6
+ <dt>Copyright</dt><dd>Copyright © 2006-2013 Bob Aman</dd>
7
7
  <dt>License</dt><dd>Apache 2.0</dd>
8
8
  </dl>
9
9
 
10
- [![Build Status](https://secure.travis-ci.org/sporkmonger/addressable.png)](http://travis-ci.org/sporkmonger/addressable)
11
- [![Dependency Status](https://gemnasium.com/sporkmonger/addressable.png)](https://gemnasium.com/sporkmonger/addressable)
10
+ [![Gem Version](https://badge.fury.io/rb/addressable.png)][gem]
11
+ [![Build Status](https://secure.travis-ci.org/sporkmonger/addressable.png?branch=master)][travis]
12
+ [![Dependency Status](https://gemnasium.com/sporkmonger/addressable.png?travis)][gemnasium]
13
+ [![Coverage Status](https://coveralls.io/repos/sporkmonger/addressable/badge.png?branch=master)][coveralls]
14
+
15
+ [gem]: https://rubygems.org/gems/addressable
16
+ [travis]: http://travis-ci.org/sporkmonger/addressable
17
+ [gemnasium]: https://gemnasium.com/sporkmonger/addressable
18
+ [coveralls]: https://coveralls.io/r/sporkmonger/addressable
12
19
 
13
20
  # Description
14
21
 
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -487,6 +487,7 @@ module Addressable
487
487
  # #=> "http://example.com/?one=1{&two}&three=3"
488
488
  def partial_expand(mapping, processor=nil)
489
489
  result = self.pattern.dup
490
+ mapping = normalize_keys(mapping)
490
491
  result.gsub!( EXPRESSION ) do |capture|
491
492
  transform_partial_capture(mapping, capture, processor)
492
493
  end
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -1089,12 +1089,32 @@ module Addressable
1089
1089
  end
1090
1090
 
1091
1091
  ##
1092
+ # This method is same as URI::Generic#host except
1093
+ # brackets for IPv6 (and 'IPvFuture') addresses are removed.
1094
+ #
1092
1095
  # @see Addressable::URI#host
1093
- alias_method :hostname, :host
1096
+ #
1097
+ # @return [String] The hostname for this URI.
1098
+ def hostname
1099
+ v = self.host
1100
+ /\A\[(.*)\]\z/ =~ v ? $1 : v
1101
+ end
1094
1102
 
1095
1103
  ##
1104
+ # This method is same as URI::Generic#host= except
1105
+ # the argument can be a bare IPv6 address (or 'IPvFuture').
1106
+ #
1096
1107
  # @see Addressable::URI#host=
1097
- alias_method :hostname=, :host=
1108
+ #
1109
+ # @param [String, #to_str] new_hostname The new hostname for this URI.
1110
+ def hostname=(new_hostname)
1111
+ if new_hostname && !new_hostname.respond_to?(:to_str)
1112
+ raise TypeError, "Can't convert #{new_hostname.class} into String."
1113
+ end
1114
+ v = new_hostname ? new_hostname.to_str : nil
1115
+ v = "[#{v}]" if /\A\[.*\]\z/ !~ v && /:/ =~ v
1116
+ self.host = v
1117
+ end
1098
1118
 
1099
1119
  ##
1100
1120
  # The authority component for this URI.
@@ -1175,7 +1195,7 @@ module Addressable
1175
1195
 
1176
1196
  ##
1177
1197
  # The origin for this URI, serialized to ASCII, as per
1178
- # draft-ietf-websec-origin-00, section 5.2.
1198
+ # RFC 6454, section 6.2.
1179
1199
  #
1180
1200
  # @return [String] The serialized origin.
1181
1201
  def origin
@@ -1771,7 +1791,7 @@ module Addressable
1771
1791
  end
1772
1792
  joined_fragment = uri.fragment
1773
1793
 
1774
- return Addressable::URI.new(
1794
+ return self.class.new(
1775
1795
  :scheme => joined_scheme,
1776
1796
  :user => joined_user,
1777
1797
  :password => joined_password,
@@ -1827,7 +1847,7 @@ module Addressable
1827
1847
  end
1828
1848
  end
1829
1849
 
1830
- uri = Addressable::URI.new
1850
+ uri = self.class.new
1831
1851
  uri.defer_validation do
1832
1852
  # Bunch of crazy logic required because of the composite components
1833
1853
  # like userinfo and authority.
@@ -1911,9 +1931,16 @@ module Addressable
1911
1931
  components[:query] = nil
1912
1932
  end
1913
1933
  else
1914
- if uri.path != SLASH
1915
- components[:path] = components[:path].gsub(
1916
- Regexp.new("^" + Regexp.escape(uri.path)), EMPTY_STR)
1934
+ if uri.path != SLASH and components[:path]
1935
+ self_splitted_path = split_path(components[:path])
1936
+ uri_splitted_path = split_path(uri.path)
1937
+ self_dir = self_splitted_path.shift
1938
+ uri_dir = uri_splitted_path.shift
1939
+ while !self_splitted_path.empty? && !uri_splitted_path.empty? and self_dir == uri_dir
1940
+ self_dir = self_splitted_path.shift
1941
+ uri_dir = uri_splitted_path.shift
1942
+ end
1943
+ components[:path] = (uri_splitted_path.fill('..') + [self_dir] + self_splitted_path).join(SLASH)
1917
1944
  end
1918
1945
  end
1919
1946
  end
@@ -1968,7 +1995,7 @@ module Addressable
1968
1995
  end
1969
1996
  end
1970
1997
 
1971
- return Addressable::URI.new(
1998
+ return self.class.new(
1972
1999
  :scheme => normalized_scheme,
1973
2000
  :authority => normalized_authority,
1974
2001
  :path => normalized_path,
@@ -2065,7 +2092,7 @@ module Addressable
2065
2092
  #
2066
2093
  # @return [Addressable::URI] The cloned URI.
2067
2094
  def dup
2068
- duplicated_uri = Addressable::URI.new(
2095
+ duplicated_uri = self.class.new(
2069
2096
  :scheme => self.scheme ? self.scheme.dup : nil,
2070
2097
  :user => self.user ? self.user.dup : nil,
2071
2098
  :password => self.password ? self.password.dup : nil,
@@ -2121,6 +2148,15 @@ module Addressable
2121
2148
  replace_self(self.omit(*components))
2122
2149
  end
2123
2150
 
2151
+ ##
2152
+ # Determines if the URI is an empty string.
2153
+ #
2154
+ # @return [TrueClass, FalseClass]
2155
+ # Returns <code>true</code> if empty, <code>false</code> otherwise.
2156
+ def empty?
2157
+ return self.to_s.empty?
2158
+ end
2159
+
2124
2160
  ##
2125
2161
  # Converts the URI to a <code>String</code>.
2126
2162
  #
@@ -2239,7 +2275,7 @@ module Addressable
2239
2275
  # Ensures that the URI is valid.
2240
2276
  def validate
2241
2277
  return if !!@validation_deferred
2242
- if self.scheme != nil &&
2278
+ if self.scheme != nil && self.ip_based? &&
2243
2279
  (self.host == nil || self.host.empty?) &&
2244
2280
  (self.path == nil || self.path.empty?)
2245
2281
  raise InvalidURIError,
@@ -2283,5 +2319,19 @@ module Addressable
2283
2319
  @fragment = uri.fragment
2284
2320
  return self
2285
2321
  end
2322
+
2323
+ ##
2324
+ # Splits path string with "/"(slash).
2325
+ # It is considered that there is empty string after last slash when
2326
+ # path ends with slash.
2327
+ #
2328
+ # @param [String] path The path to split.
2329
+ #
2330
+ # @return [Array<String>] An array of parts of path.
2331
+ def split_path(path)
2332
+ splitted = path.split(SLASH)
2333
+ splitted << EMPTY_STR if path.end_with? SLASH
2334
+ splitted
2335
+ end
2286
2336
  end
2287
2337
  end
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Copyright (C) 2006-2011 Bob Aman
3
+ # Copyright (C) 2006-2013 Bob Aman
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ if !defined?(Addressable::VERSION)
22
22
  module VERSION
23
23
  MAJOR = 2
24
24
  MINOR = 3
25
- TINY = 4
25
+ TINY = 5
26
26
 
27
27
  STRING = [MAJOR, MINOR, TINY].join('.')
28
28
  end
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- # Copyright (C) 2006-2011 Bob Aman
2
+ # Copyright (C) 2006-2013 Bob Aman
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
+ require "spec_helper"
18
+
17
19
  # Have to use RubyGems to load the idn gem.
18
20
  require "rubygems"
19
21
 
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- # Copyright (C) 2006-2011 Bob Aman
2
+ # Copyright (C) 2006-2013 Bob Aman
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
+ require "spec_helper"
18
+
17
19
  require "addressable/uri"
18
20
  require "net/http"
19
21
 
@@ -1,3 +1,21 @@
1
+ # coding: utf-8
2
+ # Copyright (C) 2006-2013 Bob Aman
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+
16
+
17
+ require "spec_helper"
18
+
1
19
  require "addressable/template"
2
20
 
3
21
  shared_examples_for 'expands' do |tests|
@@ -736,7 +754,45 @@ describe Addressable::Template do
736
754
  }
737
755
  end
738
756
  end
739
- describe "Partial expand" do
757
+ describe "Partial expand with symbols" do
758
+ context "partial_expand with two simple values" do
759
+ subject{
760
+ Addressable::Template.new("http://example.com/{one}/{two}/")
761
+ }
762
+ it "builds a new pattern" do
763
+ subject.partial_expand(:one => "1").pattern.should ==
764
+ "http://example.com/1/{two}/"
765
+ end
766
+ end
767
+ context "partial_expand query with missing param in middle" do
768
+ subject{
769
+ Addressable::Template.new("http://example.com/{?one,two,three}/")
770
+ }
771
+ it "builds a new pattern" do
772
+ subject.partial_expand(:one => "1", :three => "3").pattern.should ==
773
+ "http://example.com/?one=1{&two}&three=3/"
774
+ end
775
+ end
776
+ context "partial_expand with query string" do
777
+ subject{
778
+ Addressable::Template.new("http://example.com/{?two,one}/")
779
+ }
780
+ it "builds a new pattern" do
781
+ subject.partial_expand(:one => "1").pattern.should ==
782
+ "http://example.com/{?two}&one=1/"
783
+ end
784
+ end
785
+ context "partial_expand with path operator" do
786
+ subject{
787
+ Addressable::Template.new("http://example.com{/one,two}/")
788
+ }
789
+ it "builds a new pattern" do
790
+ subject.partial_expand(:one => "1").pattern.should ==
791
+ "http://example.com/1{/two}/"
792
+ end
793
+ end
794
+ end
795
+ describe "Partial expand with strings" do
740
796
  context "partial_expand with two simple values" do
741
797
  subject{
742
798
  Addressable::Template.new("http://example.com/{one}/{two}/")
@@ -1,5 +1,5 @@
1
1
  # coding: utf-8
2
- # Copyright (C) 2006-2011 Bob Aman
2
+ # Copyright (C) 2006-2013 Bob Aman
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
5
5
  # you may not use this file except in compliance with the License.
@@ -14,6 +14,8 @@
14
14
  # limitations under the License.
15
15
 
16
16
 
17
+ require "spec_helper"
18
+
17
19
  require "addressable/uri"
18
20
 
19
21
  if !"".respond_to?("force_encoding")
@@ -41,14 +43,18 @@ if !"".respond_to?("force_encoding")
41
43
  end
42
44
  end
43
45
 
44
- module URI
45
- class HTTP
46
- def initialize(uri)
47
- @uri = uri
48
- end
46
+ module Fake
47
+ module URI
48
+ class HTTP
49
+ def initialize(uri)
50
+ @uri = uri
51
+ end
49
52
 
50
- def to_s
51
- return @uri.to_s
53
+ def to_s
54
+ return @uri.to_s
55
+ end
56
+
57
+ alias :to_str :to_s
52
58
  end
53
59
  end
54
60
  end
@@ -179,6 +185,10 @@ describe Addressable::URI, "when created from nil components" do
179
185
  @uri.default_port.should == nil
180
186
  end
181
187
 
188
+ it "should be empty" do
189
+ @uri.should be_empty
190
+ end
191
+
182
192
  it "should raise an error if the scheme is set to whitespace" do
183
193
  (lambda do
184
194
  @uri.scheme = "\t \n"
@@ -333,11 +343,14 @@ describe Addressable::URI, "when initialized from individual components" do
333
343
  "http://user:password@example.com:8080/path?query=value#fragment"
334
344
  end
335
345
 
346
+ it "should not be empty" do
347
+ @uri.should_not be_empty
348
+ end
349
+
336
350
  it "should not be frozen" do
337
351
  @uri.should_not be_frozen
338
352
  end
339
353
 
340
-
341
354
  it "should allow destructive operations" do
342
355
  expect { @uri.normalize! }.not_to raise_error
343
356
  end
@@ -459,6 +472,10 @@ describe Addressable::URI, "when initialized from " +
459
472
  "http://user:password@example.com:8080/path?query=value#fragment"
460
473
  end
461
474
 
475
+ it "should not be empty" do
476
+ @uri.should_not be_empty
477
+ end
478
+
462
479
  it "should not be frozen" do
463
480
  @uri.should_not be_frozen
464
481
  end
@@ -576,6 +593,10 @@ describe Addressable::URI, "when parsed from a frozen string" do
576
593
  "http://user:password@example.com:8080/path?query=value#fragment"
577
594
  end
578
595
 
596
+ it "should not be empty" do
597
+ @uri.should_not be_empty
598
+ end
599
+
579
600
  it "should not be frozen" do
580
601
  @uri.should_not be_frozen
581
602
  end
@@ -690,6 +711,10 @@ describe Addressable::URI, "when frozen" do
690
711
  @uri.to_s.should == ''
691
712
  end
692
713
 
714
+ it "should be empty" do
715
+ @uri.should be_empty
716
+ end
717
+
693
718
  it "should be frozen" do
694
719
  @uri.should be_frozen
695
720
  end
@@ -822,6 +847,10 @@ describe Addressable::URI, "when frozen" do
822
847
  @uri.normalize.to_s.should == 'http://example.com/path?a=1#123'
823
848
  end
824
849
 
850
+ it "should not be empty" do
851
+ @uri.should_not be_empty
852
+ end
853
+
825
854
  it "should be frozen" do
826
855
  @uri.should be_frozen
827
856
  end
@@ -977,7 +1006,7 @@ end
977
1006
  describe Addressable::URI, "when parsed from something that looks " +
978
1007
  "like a URI object" do
979
1008
  it "should parse without error" do
980
- uri = Addressable::URI.parse(URI::HTTP.new("http://example.com/"))
1009
+ uri = Addressable::URI.parse(Fake::URI::HTTP.new("http://example.com/"))
981
1010
  (lambda do
982
1011
  Addressable::URI.parse(uri)
983
1012
  end).should_not raise_error
@@ -1210,6 +1239,50 @@ describe Addressable::URI, "when parsed from " +
1210
1239
  end
1211
1240
  end
1212
1241
 
1242
+ # Section 2 of RFC 6068
1243
+ describe Addressable::URI, "when parsed from " +
1244
+ "'mailto:?to=addr1@an.example,addr2@an.example'" do
1245
+ before do
1246
+ @uri = Addressable::URI.parse(
1247
+ "mailto:?to=addr1@an.example,addr2@an.example"
1248
+ )
1249
+ end
1250
+
1251
+ it "should use the 'mailto' scheme" do
1252
+ @uri.scheme.should == "mailto"
1253
+ end
1254
+
1255
+ it "should not be considered to be ip-based" do
1256
+ @uri.should_not be_ip_based
1257
+ end
1258
+
1259
+ it "should not have an inferred_port" do
1260
+ @uri.inferred_port.should == nil
1261
+ end
1262
+
1263
+ it "should have a path of ''" do
1264
+ @uri.path.should == ""
1265
+ end
1266
+
1267
+ it "should not have a request URI" do
1268
+ @uri.request_uri.should == nil
1269
+ end
1270
+
1271
+ it "should have the To: field value parameterized" do
1272
+ @uri.query_values(Hash)["to"].should == (
1273
+ "addr1@an.example,addr2@an.example"
1274
+ )
1275
+ end
1276
+
1277
+ it "should be considered to be in normal form" do
1278
+ @uri.normalize.should be_eql(@uri)
1279
+ end
1280
+
1281
+ it "should have a 'null' origin" do
1282
+ @uri.origin.should == 'null'
1283
+ end
1284
+ end
1285
+
1213
1286
  # Section 1.1.2 of RFC 3986
1214
1287
  describe Addressable::URI, "when parsed from " +
1215
1288
  "'news:comp.infosystems.www.servers.unix'" do
@@ -1564,9 +1637,9 @@ describe Addressable::URI, "when parsed from " +
1564
1637
  Addressable::URI.parse("/path/")
1565
1638
  end
1566
1639
 
1567
- it "should have a route of '/' from 'http://example.com/path/'" do
1640
+ it "should have a route of '..' from 'http://example.com/path/'" do
1568
1641
  @uri.route_from("http://example.com/path/").should ==
1569
- Addressable::URI.parse("/")
1642
+ Addressable::URI.parse("..")
1570
1643
  end
1571
1644
 
1572
1645
  it "should have a route of '#' to 'http://example.com/'" do
@@ -1771,6 +1844,28 @@ describe Addressable::URI, "when parsing IPv6 addresses" do
1771
1844
  end
1772
1845
  end
1773
1846
 
1847
+ describe Addressable::URI, "when parsing IPv6 address" do
1848
+ subject { Addressable::URI.parse("http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/") }
1849
+ its(:host) { should == '[3ffe:1900:4545:3:200:f8ff:fe21:67cf]' }
1850
+ its(:hostname) { should == '3ffe:1900:4545:3:200:f8ff:fe21:67cf' }
1851
+ end
1852
+
1853
+ describe Addressable::URI, "when assigning IPv6 address" do
1854
+ it "should allow to set bare IPv6 address as hostname" do
1855
+ uri = Addressable::URI.parse("http://[::1]/")
1856
+ uri.hostname = '3ffe:1900:4545:3:200:f8ff:fe21:67cf'
1857
+ uri.to_s.should == 'http://[3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'
1858
+ end
1859
+
1860
+ it "should not allow to set bare IPv6 address as host" do
1861
+ uri = Addressable::URI.parse("http://[::1]/")
1862
+ pending "not checked"
1863
+ (lambda do
1864
+ uri.host = '3ffe:1900:4545:3:200:f8ff:fe21:67cf'
1865
+ end).should raise_error(Addressable::URI::InvalidURIError)
1866
+ end
1867
+ end
1868
+
1774
1869
  describe Addressable::URI, "when parsing IPvFuture addresses" do
1775
1870
  it "should not raise an error for " +
1776
1871
  "'http://[v9.3ffe:1900:4545:3:200:f8ff:fe21:67cf]/'" do
@@ -2438,10 +2533,10 @@ describe Addressable::URI, "when parsed from " +
2438
2533
  Addressable::URI.parse("http://example.com:8080/")
2439
2534
  end
2440
2535
 
2441
- it "should have a route of '/' from " +
2536
+ it "should have a route of '../../' from " +
2442
2537
  "'http://example.com:8080/path/to/'" do
2443
2538
  @uri.route_from("http://example.com:8080/path/to/").should ==
2444
- Addressable::URI.parse("/")
2539
+ Addressable::URI.parse("../../")
2445
2540
  end
2446
2541
 
2447
2542
  it "should have a route of 'http://example.com:8080/' from " +
@@ -2722,6 +2817,25 @@ describe Addressable::URI, "when parsed from " +
2722
2817
  Addressable::URI.parse("resource/")
2723
2818
  end
2724
2819
 
2820
+ it "should have a route of '../' from " +
2821
+ "'http://example.com/path/to/resource/sub'" do
2822
+ @uri.route_from("http://example.com/path/to/resource/sub").should ==
2823
+ Addressable::URI.parse("../")
2824
+ end
2825
+
2826
+
2827
+ it "should have a route of 'resource/' from " +
2828
+ "'http://example.com/path/to/another'" do
2829
+ @uri.route_from("http://example.com/path/to/another").should ==
2830
+ Addressable::URI.parse("resource/")
2831
+ end
2832
+
2833
+ it "should have a route of 'resource/' from " +
2834
+ "'http://example.com/path/to/res'" do
2835
+ @uri.route_from("http://example.com/path/to/res").should ==
2836
+ Addressable::URI.parse("resource/")
2837
+ end
2838
+
2725
2839
  it "should have a route of 'resource/' from " +
2726
2840
  "'http://example.com:80/path/to/'" do
2727
2841
  @uri.route_from("http://example.com:80/path/to/").should ==
@@ -2740,10 +2854,10 @@ describe Addressable::URI, "when parsed from " +
2740
2854
  Addressable::URI.parse("http://example.com/path/to/resource/")
2741
2855
  end
2742
2856
 
2743
- it "should have a route of '/path/to/resource/' from " +
2857
+ it "should have a route of '../../path/to/resource/' from " +
2744
2858
  "'http://example.com/to/resource/'" do
2745
2859
  @uri.route_from("http://example.com/to/resource/").should ==
2746
- Addressable::URI.parse("/path/to/resource/")
2860
+ Addressable::URI.parse("../../path/to/resource/")
2747
2861
  end
2748
2862
 
2749
2863
  it "should correctly convert to a hash" do
@@ -3282,13 +3396,13 @@ describe Addressable::URI, "when parsed from " +
3282
3396
  @uri.normalize.should be_eql(@uri)
3283
3397
  end
3284
3398
 
3285
- it "should have a route of '/path/' to " +
3399
+ it "should have a route of '../../' to " +
3286
3400
  "'http://user:pass@example.com/path/'" do
3287
3401
  @uri.route_to("http://user:pass@example.com/path/").should ==
3288
- Addressable::URI.parse("/path/")
3402
+ Addressable::URI.parse("../../")
3289
3403
  end
3290
3404
 
3291
- it "should have a route of '/path/to/resource?query=x#fragment' " +
3405
+ it "should have a route of 'to/resource?query=x#fragment' " +
3292
3406
  "from 'http://user:pass@example.com/path/'" do
3293
3407
  @uri.route_from("http://user:pass@example.com/path/").should ==
3294
3408
  Addressable::URI.parse("to/resource?query=x#fragment")
@@ -5694,3 +5808,29 @@ describe Addressable::URI, "when assigning path values" do
5694
5808
  end).should_not raise_error(Addressable::URI::InvalidURIError)
5695
5809
  end
5696
5810
  end
5811
+
5812
+ describe Addressable::URI, "when initializing a subclass of Addressable::URI" do
5813
+ before do
5814
+ @uri = Class.new(Addressable::URI).new
5815
+ end
5816
+
5817
+ it "should have the same class after being parsed" do
5818
+ @uri.class.should == Addressable::URI.parse(@uri).class
5819
+ end
5820
+
5821
+ it "should have the same class as its duplicate" do
5822
+ @uri.class.should == @uri.dup.class
5823
+ end
5824
+
5825
+ it "should have the same class after being normalized" do
5826
+ @uri.class.should == @uri.normalize.class
5827
+ end
5828
+
5829
+ it "should have the same class after being merged" do
5830
+ @uri.class.should == @uri.merge(:path => 'path').class
5831
+ end
5832
+
5833
+ it "should have the same class after being joined" do
5834
+ @uri.class.should == @uri.join('path').class
5835
+ end
5836
+ end
@@ -0,0 +1,2 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
metadata CHANGED
@@ -1,72 +1,61 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.4
5
- prerelease:
4
+ version: 2.3.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bob Aman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-15 00:00:00.000000000 Z
11
+ date: 2013-06-27 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 0.7.3
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 0.7.3
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.9.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.9.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: launchy
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: 0.3.2
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: 0.3.2
62
- description: ! 'Addressable is a replacement for the URI implementation that is part
63
- of
64
-
65
- Ruby''s standard library. It more closely conforms to the relevant RFCs and
66
-
55
+ description: |
56
+ Addressable is a replacement for the URI implementation that is part of
57
+ Ruby's standard library. It more closely conforms to the relevant RFCs and
67
58
  adds support for IRIs and URI templates.
68
-
69
- '
70
59
  email: bob@sporkmonger.com
71
60
  executables: []
72
61
  extensions: []
@@ -83,6 +72,7 @@ files:
83
72
  - spec/addressable/net_http_compat_spec.rb
84
73
  - spec/addressable/template_spec.rb
85
74
  - spec/addressable/uri_spec.rb
75
+ - spec/spec_helper.rb
86
76
  - data/unicode.data
87
77
  - tasks/clobber.rake
88
78
  - tasks/gem.rake
@@ -100,6 +90,7 @@ files:
100
90
  homepage: http://addressable.rubyforge.org/
101
91
  licenses:
102
92
  - Apache License 2.0
93
+ metadata: {}
103
94
  post_install_message:
104
95
  rdoc_options:
105
96
  - --main
@@ -107,21 +98,19 @@ rdoc_options:
107
98
  require_paths:
108
99
  - lib
109
100
  required_ruby_version: !ruby/object:Gem::Requirement
110
- none: false
111
101
  requirements:
112
- - - ! '>='
102
+ - - '>='
113
103
  - !ruby/object:Gem::Version
114
104
  version: '0'
115
105
  required_rubygems_version: !ruby/object:Gem::Requirement
116
- none: false
117
106
  requirements:
118
- - - ! '>='
107
+ - - '>='
119
108
  - !ruby/object:Gem::Version
120
109
  version: '0'
121
110
  requirements: []
122
111
  rubyforge_project: addressable
123
- rubygems_version: 1.8.24
112
+ rubygems_version: 2.0.3
124
113
  signing_key:
125
- specification_version: 3
114
+ specification_version: 4
126
115
  summary: URI Implementation
127
116
  test_files: []