addressable 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  # encoding:utf-8
2
2
  #--
3
- # Addressable, Copyright (c) 2006-2008 Bob Aman
3
+ # Addressable, Copyright (c) 2006-2010 Bob Aman
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining
6
6
  # a copy of this software and associated documentation files (the
@@ -27,8 +27,8 @@ if !defined?(Addressable::VERSION)
27
27
  module Addressable
28
28
  module VERSION #:nodoc:
29
29
  MAJOR = 2
30
- MINOR = 1
31
- TINY = 2
30
+ MINOR = 2
31
+ TINY = 0
32
32
 
33
33
  STRING = [MAJOR, MINOR, TINY].join('.')
34
34
  end
@@ -163,6 +163,10 @@ describe Addressable::URI, "when created from nil components" do
163
163
  @uri = Addressable::URI.new
164
164
  end
165
165
 
166
+ it "should have a nil site value" do
167
+ @uri.site.should == nil
168
+ end
169
+
166
170
  it "should have an empty path" do
167
171
  @uri.path.should == ""
168
172
  end
@@ -171,9 +175,16 @@ describe Addressable::URI, "when created from nil components" do
171
175
  @uri.to_s.should == ""
172
176
  end
173
177
 
174
- it "should still be an empty uri if the scheme is set to whitespace" do
175
- @uri.scheme = "\t \n"
176
- @uri.to_s.should == ""
178
+ it "should raise an error if the scheme is set to whitespace" do
179
+ (lambda do
180
+ @uri.scheme = "\t \n"
181
+ end).should raise_error(Addressable::URI::InvalidURIError)
182
+ end
183
+
184
+ it "should raise an error if the scheme is set to all digits" do
185
+ (lambda do
186
+ @uri.scheme = "123"
187
+ end).should raise_error(Addressable::URI::InvalidURIError)
177
188
  end
178
189
 
179
190
  it "should raise an error if set into an invalid state" do
@@ -210,6 +221,10 @@ describe Addressable::URI, "when created from string components" do
210
221
  )
211
222
  end
212
223
 
224
+ it "should have a site value of 'http://example.com'" do
225
+ @uri.site.should == "http://example.com"
226
+ end
227
+
213
228
  it "should be equal to the equivalent parsed URI" do
214
229
  @uri.should == Addressable::URI.parse("http://example.com")
215
230
  end
@@ -252,6 +267,10 @@ describe Addressable::URI, "when created with an authority and no port" do
252
267
  @uri.port.should == nil
253
268
  @uri.inferred_port.should == nil
254
269
  end
270
+
271
+ it "should have a site value of '//user@example.com'" do
272
+ @uri.site.should == "//user@example.com"
273
+ end
255
274
  end
256
275
 
257
276
  describe Addressable::URI, "when created with both a userinfo and a user" do
@@ -264,19 +283,35 @@ end
264
283
 
265
284
  describe Addressable::URI, "when created with a path that hasn't been " +
266
285
  "prefixed with a '/' but a host specified" do
267
- it "should prefix a '/' to the path" do
268
- Addressable::URI.new(
286
+ before do
287
+ @uri = Addressable::URI.new(
269
288
  :scheme => "http", :host => "example.com", :path => "path"
270
- ).should == Addressable::URI.parse("http://example.com/path")
289
+ )
290
+ end
291
+
292
+ it "should prefix a '/' to the path" do
293
+ @uri.should == Addressable::URI.parse("http://example.com/path")
294
+ end
295
+
296
+ it "should have a site value of 'http://example.com'" do
297
+ @uri.site.should == "http://example.com"
271
298
  end
272
299
  end
273
300
 
274
301
  describe Addressable::URI, "when created with a path that hasn't been " +
275
302
  "prefixed with a '/' but no host specified" do
276
- it "should prefix a '/' to the path" do
277
- Addressable::URI.new(
303
+ before do
304
+ @uri = Addressable::URI.new(
278
305
  :scheme => "http", :path => "path"
279
- ).should == Addressable::URI.parse("http:path")
306
+ )
307
+ end
308
+
309
+ it "should not prefix a '/' to the path" do
310
+ @uri.should == Addressable::URI.parse("http:path")
311
+ end
312
+
313
+ it "should have a site value of 'http:'" do
314
+ @uri.site.should == "http:"
280
315
  end
281
316
  end
282
317
 
@@ -733,6 +768,27 @@ describe Addressable::URI, "when parsed from " +
733
768
  @uri.join!(@uri).to_s.should == "http://example.com"
734
769
  end
735
770
 
771
+ it "should be equivalent to http://EXAMPLE.com" do
772
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com")
773
+ end
774
+
775
+ it "should be equivalent to http://EXAMPLE.com:80/" do
776
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
777
+ end
778
+
779
+ it "should have the same hash as http://example.com" do
780
+ @uri.hash.should == Addressable::URI.parse("http://example.com").hash
781
+ end
782
+
783
+ it "should have the same hash as http://EXAMPLE.com after assignment" do
784
+ @uri.host = "EXAMPLE.com"
785
+ @uri.hash.should == Addressable::URI.parse("http://EXAMPLE.com").hash
786
+ end
787
+
788
+ it "should have a different hash from http://EXAMPLE.com" do
789
+ @uri.hash.should_not == Addressable::URI.parse("http://EXAMPLE.com").hash
790
+ end
791
+
736
792
  # Section 6.2.3 of RFC 3986
737
793
  it "should be equivalent to http://example.com/" do
738
794
  @uri.should == Addressable::URI.parse("http://example.com/")
@@ -897,6 +953,12 @@ describe Addressable::URI, "when parsed from " +
897
953
  @uri.query.should == "x=y"
898
954
  end
899
955
 
956
+ it "should raise an error if the site value is set to something bogus" do
957
+ (lambda do
958
+ @uri.site = 42
959
+ end).should raise_error(TypeError)
960
+ end
961
+
900
962
  it "should raise an error if the request URI is set to something bogus" do
901
963
  (lambda do
902
964
  @uri.request_uri = 42
@@ -994,6 +1056,42 @@ describe Addressable::URI, "when parsed from " +
994
1056
  it "should have the same hash as an equal URI" do
995
1057
  @uri.hash.should == Addressable::URI.parse("http://example.com/").hash
996
1058
  end
1059
+
1060
+ it "should be equivalent to http://EXAMPLE.com" do
1061
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com")
1062
+ end
1063
+
1064
+ it "should be equivalent to http://EXAMPLE.com:80/" do
1065
+ @uri.should == Addressable::URI.parse("http://EXAMPLE.com:80/")
1066
+ end
1067
+
1068
+ it "should have the same hash as http://example.com/" do
1069
+ @uri.hash.should == Addressable::URI.parse("http://example.com/").hash
1070
+ end
1071
+
1072
+ it "should have the same hash as http://example.com after assignment" do
1073
+ @uri.path = ""
1074
+ @uri.hash.should == Addressable::URI.parse("http://example.com").hash
1075
+ end
1076
+
1077
+ it "should have the same hash as http://example.com/? after assignment" do
1078
+ @uri.query = ""
1079
+ @uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
1080
+ end
1081
+
1082
+ it "should have the same hash as http://example.com/? after assignment" do
1083
+ @uri.query_values = {}
1084
+ @uri.hash.should == Addressable::URI.parse("http://example.com/?").hash
1085
+ end
1086
+
1087
+ it "should have the same hash as http://example.com/# after assignment" do
1088
+ @uri.fragment = ""
1089
+ @uri.hash.should == Addressable::URI.parse("http://example.com/#").hash
1090
+ end
1091
+
1092
+ it "should have a different hash from http://example.com" do
1093
+ @uri.hash.should_not == Addressable::URI.parse("http://example.com").hash
1094
+ end
997
1095
  end
998
1096
 
999
1097
  describe Addressable::URI, "when parsed from " +
@@ -1953,10 +2051,10 @@ describe Addressable::URI, "when parsed from " +
1953
2051
  end
1954
2052
 
1955
2053
  describe Addressable::URI, "when parsed from " +
1956
- "'ssh+svn://developername@rubyforge.org/var/svn/project'" do
2054
+ "'ssh+svn://developername@RUBYFORGE.ORG/var/svn/project'" do
1957
2055
  before do
1958
2056
  @uri = Addressable::URI.parse(
1959
- "ssh+svn://developername@rubyforge.org/var/svn/project"
2057
+ "ssh+svn://developername@RUBYFORGE.ORG/var/svn/project"
1960
2058
  )
1961
2059
  end
1962
2060
 
@@ -1968,6 +2066,10 @@ describe Addressable::URI, "when parsed from " +
1968
2066
  @uri.normalized_scheme.should == "svn+ssh"
1969
2067
  end
1970
2068
 
2069
+ it "should have a normalized site of 'svn+ssh'" do
2070
+ @uri.normalized_site.should == "svn+ssh://developername@rubyforge.org"
2071
+ end
2072
+
1971
2073
  it "should not be considered to be ip-based" do
1972
2074
  @uri.should_not be_ip_based
1973
2075
  end
@@ -2195,6 +2297,22 @@ describe Addressable::URI, "when parsed from " +
2195
2297
  "bogus%21://user:pass@example.com/path/to/resource?query=x#fragment"
2196
2298
  end
2197
2299
 
2300
+ it "should have the correct site segment after assignment" do
2301
+ @uri.site = "https://newuser:newpass@example.com:443"
2302
+ @uri.scheme.should == "https"
2303
+ @uri.authority.should == "newuser:newpass@example.com:443"
2304
+ @uri.user.should == "newuser"
2305
+ @uri.password.should == "newpass"
2306
+ @uri.userinfo.should == "newuser:newpass"
2307
+ @uri.normalized_userinfo.should == "newuser:newpass"
2308
+ @uri.host.should == "example.com"
2309
+ @uri.port.should == 443
2310
+ @uri.inferred_port.should == 443
2311
+ @uri.to_s.should ==
2312
+ "https://newuser:newpass@example.com:443" +
2313
+ "/path/to/resource?query=x#fragment"
2314
+ end
2315
+
2198
2316
  it "should have the correct authority segment after assignment" do
2199
2317
  @uri.authority = "newuser:newpass@example.com:80"
2200
2318
  @uri.authority.should == "newuser:newpass@example.com:80"
@@ -2255,6 +2373,20 @@ describe Addressable::URI, "when parsed from " +
2255
2373
  "http://user:pass@example.com/newpath/to/resource?query=x#fragment"
2256
2374
  end
2257
2375
 
2376
+ it "should have the correct scheme and authority after nil assignment" do
2377
+ @uri.site = nil
2378
+ @uri.scheme.should == nil
2379
+ @uri.authority.should == nil
2380
+ @uri.to_s.should == "/path/to/resource?query=x#fragment"
2381
+ end
2382
+
2383
+ it "should have the correct scheme and authority after assignment" do
2384
+ @uri.site = "file://"
2385
+ @uri.scheme.should == "file"
2386
+ @uri.authority.should == ""
2387
+ @uri.to_s.should == "file:///path/to/resource?query=x#fragment"
2388
+ end
2389
+
2258
2390
  it "should have the correct path after nil assignment" do
2259
2391
  @uri.path = nil
2260
2392
  @uri.path.should == ""
@@ -2343,12 +2475,14 @@ describe Addressable::URI, "when parsed from " +
2343
2475
  it "should have the correct values after a merge" do
2344
2476
  @uri.merge(:authority => "foo:bar@baz:42").to_s.should ==
2345
2477
  "http://foo:bar@baz:42/path/to/resource?query=x#fragment"
2478
+ # Ensure the operation was not destructive
2346
2479
  @uri.to_s.should ==
2347
2480
  "http://user:pass@example.com/path/to/resource?query=x#fragment"
2348
2481
  end
2349
2482
 
2350
2483
  it "should have the correct values after a destructive merge" do
2351
2484
  @uri.merge!(:authority => "foo:bar@baz:42")
2485
+ # Ensure the operation was destructive
2352
2486
  @uri.to_s.should ==
2353
2487
  "http://foo:bar@baz:42/path/to/resource?query=x#fragment"
2354
2488
  end
@@ -2359,6 +2493,12 @@ describe Addressable::URI, "when parsed from " +
2359
2493
  end).should raise_error(Addressable::URI::InvalidURIError)
2360
2494
  end
2361
2495
 
2496
+ it "should fail to merge with bogus values" do
2497
+ (lambda do
2498
+ @uri.merge(:authority => "bar@baz:bogus")
2499
+ end).should raise_error(Addressable::URI::InvalidURIError)
2500
+ end
2501
+
2362
2502
  it "should fail to merge with bogus parameters" do
2363
2503
  (lambda do
2364
2504
  @uri.merge(42)
@@ -2388,6 +2528,36 @@ describe Addressable::URI, "when parsed from " +
2388
2528
  end
2389
2529
  end
2390
2530
 
2531
+ describe Addressable::URI, "when parsed from " +
2532
+ "'http://example.com/?q&&x=b'" do
2533
+ before do
2534
+ @uri = Addressable::URI.parse("http://example.com/?q&&x=b")
2535
+ end
2536
+
2537
+ it "should have a query of 'q&&x=b'" do
2538
+ @uri.query.should == "q&&x=b"
2539
+ end
2540
+
2541
+ it "should have query_values of {'q' => true, 'x' => 'b'}" do
2542
+ @uri.query_values.should == {'q' => true, 'x' => 'b'}
2543
+ end
2544
+ end
2545
+
2546
+ describe Addressable::URI, "when parsed from " +
2547
+ "'http://example.com/?q='" do
2548
+ before do
2549
+ @uri = Addressable::URI.parse("http://example.com/?q=")
2550
+ end
2551
+
2552
+ it "should have a query of 'q='" do
2553
+ @uri.query.should == "q="
2554
+ end
2555
+
2556
+ it "should have query_values of {'q' => ''}" do
2557
+ @uri.query_values.should == {'q' => ''}
2558
+ end
2559
+ end
2560
+
2391
2561
  describe Addressable::URI, "when parsed from " +
2392
2562
  "'http://user@example.com'" do
2393
2563
  before do
@@ -2661,6 +2831,14 @@ describe Addressable::URI, "when parsed from " +
2661
2831
  @uri.host.should == nil
2662
2832
  end
2663
2833
 
2834
+ it "should have a site of nil" do
2835
+ @uri.site.should == nil
2836
+ end
2837
+
2838
+ it "should have a normalized_site of nil" do
2839
+ @uri.normalized_site.should == nil
2840
+ end
2841
+
2664
2842
  it "should have a path of ''" do
2665
2843
  @uri.path.should == ""
2666
2844
  end
@@ -3864,6 +4042,21 @@ describe Addressable::URI, "when assigning query values" do
3864
4042
  }
3865
4043
  @uri.query.should == "a=a&b[c]&b[d]=d"
3866
4044
  end
4045
+
4046
+ it "should correctly assign {}" do
4047
+ @uri.query_values = {}
4048
+ @uri.query.should == ''
4049
+ end
4050
+
4051
+ it "should correctly assign nil" do
4052
+ @uri.query_values = nil
4053
+ @uri.query.should == nil
4054
+ end
4055
+
4056
+ it "should correctly sort {'ab' => 'c', :ab => 'a', :a => 'x'}" do
4057
+ @uri.query_values = {'ab' => 'c', :ab => 'a', :a => 'x'}
4058
+ @uri.query.should == "a=x&ab=a&ab=c"
4059
+ end
3867
4060
  end
3868
4061
 
3869
4062
  describe Addressable::URI, "when assigning path values" do
@@ -21,6 +21,7 @@ namespace :gem do
21
21
  s.add_development_dependency("rake", ">= 0.7.3")
22
22
  s.add_development_dependency("rspec", ">= 1.0.8")
23
23
  s.add_development_dependency("launchy", ">= 0.3.2")
24
+ s.add_development_dependency("diff-lcs", ">= 1.1.2")
24
25
 
25
26
  s.require_path = "lib"
26
27
 
@@ -36,6 +37,21 @@ namespace :gem do
36
37
  p.need_zip = true
37
38
  end
38
39
 
40
+ desc "Generates .gemspec file"
41
+ task :gemspec do
42
+ spec_string = GEM_SPEC.to_ruby
43
+
44
+ begin
45
+ Thread.new { eval("$SAFE = 3\n#{spec_string}", binding) }.join
46
+ rescue
47
+ abort "unsafe gemspec: #{$!}"
48
+ else
49
+ File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
50
+ file.write spec_string
51
+ end
52
+ end
53
+ end
54
+
39
55
  desc "Show information about the gem"
40
56
  task :debug do
41
57
  puts GEM_SPEC.to_ruby
@@ -23,7 +23,4 @@ namespace :doc do
23
23
  end
24
24
  end
25
25
 
26
- desc "Alias to doc:rdoc"
27
- task "doc" => "doc:rdoc"
28
-
29
26
  task "clobber" => ["doc:clobber_rdoc", "doc:clobber_ri"]
@@ -26,7 +26,7 @@ end
26
26
 
27
27
  namespace :doc do
28
28
  desc "Publish RDoc to RubyForge"
29
- task :release => ["doc:rdoc"] do
29
+ task :release => ["doc"] do
30
30
  require "rake/contrib/sshpublisher"
31
31
  require "yaml"
32
32
 
@@ -0,0 +1,26 @@
1
+ require "rake"
2
+
3
+ begin
4
+ require "yard"
5
+ require "yard/rake/yardoc_task"
6
+
7
+ namespace :doc do
8
+ desc "Generate Yardoc documentation"
9
+ YARD::Rake::YardocTask.new do |yardoc|
10
+ yardoc.name = "yard"
11
+ yardoc.options = ["--verbose"]
12
+ yardoc.files = [
13
+ "lib/**/*.rb", "ext/**/*.c", "README", "CHANGELOG", "LICENSE"
14
+ ]
15
+ end
16
+ end
17
+
18
+ task "clobber" => ["doc:clobber_yard"]
19
+
20
+ desc "Alias to doc:yard"
21
+ task "doc" => "doc:yard"
22
+ rescue LoadError
23
+ # If yard isn't available, it's not the end of the world
24
+ desc "Alias to doc:rdoc"
25
+ task "doc" => "doc:rdoc"
26
+ end
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 2
9
+ - 0
10
+ version: 2.2.0
5
11
  platform: ruby
6
12
  authors:
7
13
  - Bob Aman
@@ -9,39 +15,73 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-04-23 00:00:00 -07:00
18
+ date: 2010-08-09 00:00:00 -07:00
13
19
  default_executable:
14
20
  dependencies:
15
21
  - !ruby/object:Gem::Dependency
16
22
  name: rake
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
20
26
  requirements:
21
27
  - - ">="
22
28
  - !ruby/object:Gem::Version
29
+ hash: 5
30
+ segments:
31
+ - 0
32
+ - 7
33
+ - 3
23
34
  version: 0.7.3
24
- version:
35
+ type: :development
36
+ version_requirements: *id001
25
37
  - !ruby/object:Gem::Dependency
26
38
  name: rspec
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
30
42
  requirements:
31
43
  - - ">="
32
44
  - !ruby/object:Gem::Version
45
+ hash: 7
46
+ segments:
47
+ - 1
48
+ - 0
49
+ - 8
33
50
  version: 1.0.8
34
- version:
51
+ type: :development
52
+ version_requirements: *id002
35
53
  - !ruby/object:Gem::Dependency
36
54
  name: launchy
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
40
58
  requirements:
41
59
  - - ">="
42
60
  - !ruby/object:Gem::Version
61
+ hash: 23
62
+ segments:
63
+ - 0
64
+ - 3
65
+ - 2
43
66
  version: 0.3.2
44
- version:
67
+ type: :development
68
+ version_requirements: *id003
69
+ - !ruby/object:Gem::Dependency
70
+ name: diff-lcs
71
+ prerelease: false
72
+ requirement: &id004 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ hash: 23
78
+ segments:
79
+ - 1
80
+ - 1
81
+ - 2
82
+ version: 1.1.2
83
+ type: :development
84
+ version_requirements: *id004
45
85
  description: |
46
86
  Addressable is a replacement for the URI implementation that is part of
47
87
  Ruby's standard library. It more closely conforms to the relevant RFCs and
@@ -70,6 +110,7 @@ files:
70
110
  - tasks/rdoc.rake
71
111
  - tasks/rubyforge.rake
72
112
  - tasks/spec.rake
113
+ - tasks/yard.rake
73
114
  - website/index.html
74
115
  - CHANGELOG
75
116
  - LICENSE
@@ -86,21 +127,27 @@ rdoc_options:
86
127
  require_paths:
87
128
  - lib
88
129
  required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
89
131
  requirements:
90
132
  - - ">="
91
133
  - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
92
137
  version: "0"
93
- version:
94
138
  required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
95
140
  requirements:
96
141
  - - ">="
97
142
  - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
98
146
  version: "0"
99
- version:
100
147
  requirements: []
101
148
 
102
149
  rubyforge_project: addressable
103
- rubygems_version: 1.3.5
150
+ rubygems_version: 1.3.7
104
151
  signing_key:
105
152
  specification_version: 3
106
153
  summary: URI Implementation