uniform_resource_identifier 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,26 +1,23 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniform_resource_identifier (0.1.14)
5
- activesupport (>= 3.0.0)
6
- addressable (~> 2.2.6)
7
- i18n (~> 0.6.0)
8
- public_suffix_service (~> 0.9.0)
4
+ uniform_resource_identifier (0.1.21)
5
+ activesupport (>= 3.0)
6
+ addressable (~> 2.2)
7
+ i18n (~> 0.6)
8
+ public_suffix (~> 1.1)
9
9
 
10
10
  GEM
11
11
  remote: http://rubygems.org/
12
12
  specs:
13
- activesupport (3.1.1)
13
+ activesupport (3.2.3)
14
+ i18n (~> 0.6)
14
15
  multi_json (~> 1.0)
15
- addressable (2.2.6)
16
+ addressable (2.2.7)
16
17
  diff-lcs (1.1.3)
17
- fuubar (0.0.6)
18
- rspec (~> 2.0)
19
- rspec-instafail (~> 0.1.8)
20
- ruby-progressbar (~> 0.0.10)
21
18
  i18n (0.6.0)
22
- multi_json (1.0.3)
23
- public_suffix_service (0.9.0)
19
+ multi_json (1.3.1)
20
+ public_suffix (1.1.0)
24
21
  rspec (2.6.0)
25
22
  rspec-core (~> 2.6.0)
26
23
  rspec-expectations (~> 2.6.0)
@@ -28,17 +25,15 @@ GEM
28
25
  rspec-core (2.6.4)
29
26
  rspec-expectations (2.6.0)
30
27
  diff-lcs (~> 1.1.2)
31
- rspec-instafail (0.1.9)
32
28
  rspec-mocks (2.6.0)
33
- ruby-progressbar (0.0.10)
34
29
  watchr (0.7)
35
30
 
36
31
  PLATFORMS
32
+ java
37
33
  ruby
38
34
 
39
35
  DEPENDENCIES
40
- bundler (~> 1.0.0)
41
- fuubar (~> 0.0.6)
42
- rspec (~> 2.6.0)
36
+ bundler (~> 1.0)
37
+ rspec (~> 2.6)
43
38
  uniform_resource_identifier!
44
- watchr (~> 0.7.0)
39
+ watchr (~> 0.7)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.21
1
+ 0.1.22
@@ -1,13 +1,13 @@
1
1
  require 'uniform_resource_identifier/parsable'
2
2
  require 'active_support/core_ext/hash'
3
- require 'public_suffix_service'
3
+ require 'public_suffix'
4
4
 
5
5
  class UniformResourceIdentifier
6
6
  class Domain
7
7
  extend Parsable
8
8
 
9
9
  def initialize(domain=nil)
10
- if domain.respond_to?(:to_str)
10
+ if domain.respond_to?(:to_str)
11
11
  begin
12
12
  pss = PublicSuffix.parse(domain)
13
13
 
@@ -1,7 +1,7 @@
1
1
  require 'uniform_resource_identifier/parsable'
2
2
  require 'uniform_resource_identifier/domain'
3
3
  require 'active_support/core_ext/hash'
4
- require 'public_suffix_service'
4
+ require 'public_suffix'
5
5
 
6
6
  class UniformResourceIdentifier
7
7
  class Host
@@ -25,9 +25,10 @@ class UniformResourceIdentifier
25
25
  end
26
26
 
27
27
  def to_s
28
- query = "/#{@path}" if @path.blank? || !@path.to_s.starts_with?("/")
28
+ query = "/#{@path}" if @path.blank? || !@path.to_s[/^\//]
29
29
  query = "?#{@query}" unless @query.blank?
30
30
  anchor = "##{@anchor}" unless @anchor.blank?
31
+
31
32
  "#{path}#{query}#{anchor}"
32
33
  end
33
34
 
@@ -4,7 +4,6 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
4
4
  false.should == true if uri_specification == {}
5
5
 
6
6
  url = UniformResourceIdentifier.parse(uri_string)
7
- # uri_specification = uri_specification.to_hash # TODO: Needed?
8
7
 
9
8
  # ======================================================================= #
10
9
  # = Protocol/Scheme = #
@@ -16,6 +15,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
16
15
  url.scheme.class.should == String # Alias
17
16
  url.scheme.to_s.should == uri_specification[:protocol] # Alias
18
17
  end
18
+
19
19
  # ======================================================================= #
20
20
  # = Authority = #
21
21
  # ======================================================================= #
@@ -147,5 +147,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
147
147
  url.anchor.class.should == String # Delegate
148
148
  url.anchor.to_s.should == uri_specification[:anchor] # Delegate
149
149
  end
150
+
151
+ true.should == true
150
152
  end
151
153
  end
@@ -1,4 +1,6 @@
1
+ print "#{RUBY_VERSION} - #{RUBY_PLATFORM} - #{RUBY_RELEASE_DATE} -=- "
2
+
1
3
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
4
 
3
5
  require 'uniform_resource_identifier'
4
- require 'uniform_resource_identifier/rspec_matcher'
6
+ require 'uniform_resource_identifier/rspec_matcher'
@@ -38,146 +38,143 @@ describe UniformResourceIdentifier do
38
38
  subject { UniformResourceIdentifier }
39
39
 
40
40
  let(:url) do
41
- "http://usr:pwd@www.test.com:81/dir/dir.2/foo/bar/index.htm?q1=0&&test1&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3#top"
41
+ 'http://usr:pwd@www.test.com:81/dir/dir.2/foo/bar/index.htm?q1=0&&test1&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3#top'
42
42
  end
43
43
 
44
- describe "#parse" do
45
- it "should correctly parse the given URL" do
44
+ describe '#parse' do
45
+ it 'should correctly parse the given URL' do
46
46
  url.should have_uri_specification(
47
- :protocol => "http",
48
- :authority => "usr:pwd@www.test.com:81",
49
- :user_info => "usr:pwd",
50
- :username => "usr",
51
- :password => "pwd",
52
- :host => "www.test.com",
53
- :subdomain => "www",
54
- :domain => "test.com",
55
- :sld => "test",
56
- :tld => "com",
57
- :port => "81",
58
- # :relative => "/dir/dir.2/foo/bar/index.htm?q1=0&test1=true&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3#top",
59
- :path => "/dir/dir.2/foo/bar/index.htm",
60
- :directory => "/dir/dir.2/foo/bar/",
61
- :file => "index.htm",
62
- # :query => "q1=0&test1=true&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3",
63
- :anchor => "top"
47
+ :protocol => 'http',
48
+ :authority => 'usr:pwd@www.test.com:81',
49
+ :user_info => 'usr:pwd',
50
+ :username => 'usr',
51
+ :password => 'pwd',
52
+ :host => 'www.test.com',
53
+ :subdomain => 'www',
54
+ :domain => 'test.com',
55
+ :sld => 'test',
56
+ :tld => 'com',
57
+ :port => '81',
58
+ :relative => '/dir/dir.2/foo/bar/index.htm?arr%5B%5D=one&arr%5B%5D=two&hsh%5Bfoo%5D=bar&q1=0&test1=true&test2=value&test3=val3#top',
59
+ :path => '/dir/dir.2/foo/bar/index.htm',
60
+ :directory => '/dir/dir.2/foo/bar/',
61
+ :file => 'index.htm',
62
+ :query => 'arr%5B%5D=one&arr%5B%5D=two&hsh%5Bfoo%5D=bar&q1=0&test1=true&test2=value&test3=val3',
63
+ :anchor => 'top'
64
64
  )
65
65
 
66
- url.should have_uri_specification(
67
- :host => "www.test.com"
68
- )
66
+ url.should have_uri_specification(:host => 'www.test.com')
69
67
  end
70
68
  end
71
69
 
72
- describe "#to_s" do
73
- it "should return the normalized URI" do
74
- # subject.parse(url).to_s.should == "http://usr:pwd@www.test.com:81/dir/dir.2/foo/bar/index.htm?q1=0&test1=true&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3#top"
75
- subject.parse(url).to_s.should == "http://usr:pwd@www.test.com:81/dir/dir.2/foo/bar/index.htm?arr%5B%5D=one&arr%5B%5D=two&hsh%5Bfoo%5D=bar&q1=0&test1=true&test2=value&test3=val3#top"
70
+ describe '#to_s' do
71
+ it 'should return the normalized URI' do
72
+ subject.parse(url).to_s.should == 'http://usr:pwd@www.test.com:81/dir/dir.2/foo/bar/index.htm?arr%5B%5D=one&arr%5B%5D=two&hsh%5Bfoo%5D=bar&q1=0&test1=true&test2=value&test3=val3#top'
76
73
  end
77
74
  end
78
75
 
79
- describe "#to_h" do
80
- it "should return the correct Hash result" do
76
+ describe '#to_h' do
77
+ it 'should return the correct Hash result' do
81
78
  subject.parse(url).to_h.should == {
82
- :protocol =>"http",
79
+ :protocol =>'http',
83
80
  :authority => {
84
81
  :user_info => {
85
- :username => "usr",
86
- :password => "pwd"
82
+ :username => 'usr',
83
+ :password => 'pwd'
87
84
  },
88
85
  :host => {
89
- :subdomain => "www",
86
+ :subdomain => 'www',
90
87
  :domain => {
91
- :sld => "test",
92
- :tld => "com"
88
+ :sld => 'test',
89
+ :tld => 'com'
93
90
  }
94
91
  },
95
92
  :port => 81
96
93
  },
97
94
  :relative => {
98
95
  :path => {
99
- :directory => "/dir/dir.2/foo/bar/",
100
- :file => "index.htm"
96
+ :directory => '/dir/dir.2/foo/bar/',
97
+ :file => 'index.htm'
101
98
  },
102
99
  :query => { # TODO: Should the query_values be strings?
103
- "q1" => "0",
104
- "test1" => true,
105
- "test2" => "value",
106
- "arr" => ["one", "two"],
107
- "hsh" => {
108
- "foo" => "bar"
100
+ 'q1' => '0',
101
+ 'test1' => true,
102
+ 'test2' => 'value',
103
+ 'arr' => ['one', 'two'],
104
+ 'hsh' => {
105
+ 'foo' => 'bar'
109
106
  },
110
- "test3" => "val3"
107
+ 'test3' => 'val3'
111
108
  },
112
- :anchor=>"top"
109
+ :anchor=>'top'
113
110
  }
114
111
  }
115
112
  end
116
113
  end
117
114
 
118
- describe "The example from the README" do
119
- it "should be correct, to say the least." do
120
- url = "foo://usr:pwd@www.example.co.uk:8042/over/there.htm?name=ferret#nose"
115
+ describe 'The example from the README' do
116
+ it 'should be correct, to say the least.' do
117
+ url = 'foo://usr:pwd@www.example.co.uk:8042/over/there.htm?name=ferret#nose'
121
118
  uri = UniformResourceIdentifier.parse(url)
122
119
 
123
- uri.protocol.should == "foo"
120
+ uri.protocol.should == 'foo'
124
121
 
125
- uri.authority.to_s.should == "usr:pwd@www.example.co.uk:8042"
122
+ uri.authority.to_s.should == 'usr:pwd@www.example.co.uk:8042'
126
123
 
127
- uri.authority.user_info.to_s.should == "usr:pwd"
128
- uri.user_info.to_s.should == "usr:pwd"
124
+ uri.authority.user_info.to_s.should == 'usr:pwd'
125
+ uri.user_info.to_s.should == 'usr:pwd'
129
126
 
130
- uri.authority.user_info.username.should == "usr"
131
- uri.authority.user_info.password.should == "pwd"
132
- uri.user_info.username.should == "usr"
133
- uri.user_info.password.should == "pwd"
134
- uri.username.should == "usr"
135
- uri.password.should == "pwd"
127
+ uri.authority.user_info.username.should == 'usr'
128
+ uri.authority.user_info.password.should == 'pwd'
129
+ uri.user_info.username.should == 'usr'
130
+ uri.user_info.password.should == 'pwd'
131
+ uri.username.should == 'usr'
132
+ uri.password.should == 'pwd'
136
133
 
137
- uri.authority.host.to_s.should == "www.example.co.uk"
138
- uri.host.to_s.should == "www.example.co.uk"
134
+ uri.authority.host.to_s.should == 'www.example.co.uk'
135
+ uri.host.to_s.should == 'www.example.co.uk'
139
136
 
140
- uri.authority.host.subdomain.should == "www"
141
- uri.authority.subdomain.should == "www"
142
- uri.subdomain.should == "www"
137
+ uri.authority.host.subdomain.should == 'www'
138
+ uri.authority.subdomain.should == 'www'
139
+ uri.subdomain.should == 'www'
143
140
 
144
- uri.authority.host.domain.to_s.should == "example.co.uk"
145
- uri.authority.domain.to_s.should == "example.co.uk"
146
- uri.domain.to_s.should == "example.co.uk"
141
+ uri.authority.host.domain.to_s.should == 'example.co.uk'
142
+ uri.authority.domain.to_s.should == 'example.co.uk'
143
+ uri.domain.to_s.should == 'example.co.uk'
147
144
 
148
- uri.authority.host.domain.sld.should == "example"
149
- uri.authority.domain.sld.should == "example"
150
- uri.domain.sld.should == "example"
151
- uri.sld.should == "example"
145
+ uri.authority.host.domain.sld.should == 'example'
146
+ uri.authority.domain.sld.should == 'example'
147
+ uri.domain.sld.should == 'example'
148
+ uri.sld.should == 'example'
152
149
 
153
- uri.authority.host.domain.tld.should == "co.uk"
154
- uri.authority.domain.tld.should == "co.uk"
155
- uri.domain.tld.should == "co.uk"
156
- uri.tld.should == "co.uk"
150
+ uri.authority.host.domain.tld.should == 'co.uk'
151
+ uri.authority.domain.tld.should == 'co.uk'
152
+ uri.domain.tld.should == 'co.uk'
153
+ uri.tld.should == 'co.uk'
157
154
 
158
155
  uri.authority.port.should == 8042
159
156
  uri.port.should == 8042
160
157
 
161
- uri.relative.to_s.should == "/over/there.htm?name=ferret#nose"
158
+ uri.relative.to_s.should == '/over/there.htm?name=ferret#nose'
162
159
 
163
- uri.relative.path.to_s.should == "/over/there.htm"
164
- uri.path.to_s.should == "/over/there.htm"
160
+ uri.relative.path.to_s.should == '/over/there.htm'
161
+ uri.path.to_s.should == '/over/there.htm'
165
162
 
166
- uri.relative.path.directory.to_s.should == "/over/"
167
- uri.relative.directory.to_s.should == "/over/"
168
- uri.directory.to_s.should == "/over/"
163
+ uri.relative.path.directory.to_s.should == '/over/'
164
+ uri.relative.directory.to_s.should == '/over/'
165
+ uri.directory.to_s.should == '/over/'
169
166
 
170
- uri.relative.path.file.to_s.should == "there.htm"
171
- uri.relative.file.to_s.should == "there.htm"
172
- uri.file.to_s.should == "there.htm"
167
+ uri.relative.path.file.to_s.should == 'there.htm'
168
+ uri.relative.file.to_s.should == 'there.htm'
169
+ uri.file.to_s.should == 'there.htm'
173
170
 
174
- uri.relative.query.to_h.should == { "name" => "ferret" }
175
- uri.relative.query.to_s.should == "name=ferret"
176
- uri.query.to_h.should == { "name" => "ferret" }
177
- uri.query.to_s.should == "name=ferret"
171
+ uri.relative.query.to_h.should == { 'name' => 'ferret' }
172
+ uri.relative.query.to_s.should == 'name=ferret'
173
+ uri.query.to_h.should == { 'name' => 'ferret' }
174
+ uri.query.to_s.should == 'name=ferret'
178
175
 
179
- uri.relative.anchor.should == "nose"
180
- uri.anchor.should == "nose"
176
+ uri.relative.anchor.should == 'nose'
177
+ uri.anchor.should == 'nose'
181
178
  end
182
179
  end
183
180
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uniform_resource_identifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-16 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: public_suffix
16
- requirement: &70138700565880 !ruby/object:Gem::Requirement
16
+ requirement: &70228205651440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70138700565880
24
+ version_requirements: *70228205651440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70138700565400 !ruby/object:Gem::Requirement
27
+ requirement: &70228205650960 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70138700565400
35
+ version_requirements: *70228205650960
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: addressable
38
- requirement: &70138700564940 !ruby/object:Gem::Requirement
38
+ requirement: &70228205650500 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '2.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70138700564940
46
+ version_requirements: *70228205650500
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n
49
- requirement: &70138700564480 !ruby/object:Gem::Requirement
49
+ requirement: &70228205650040 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0.6'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70138700564480
57
+ version_requirements: *70228205650040
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70138700564020 !ruby/object:Gem::Requirement
60
+ requirement: &70228205649580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '1.0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70138700564020
68
+ version_requirements: *70228205649580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70138700563560 !ruby/object:Gem::Requirement
71
+ requirement: &70228205649120 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '2.6'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70138700563560
79
+ version_requirements: *70228205649120
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: watchr
82
- requirement: &70138700563100 !ruby/object:Gem::Requirement
82
+ requirement: &70228205648660 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,9 +87,9 @@ dependencies:
87
87
  version: '0.7'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70138700563100
90
+ version_requirements: *70228205648660
91
91
  description: ! '`uniform_resource_identifier` splits URIs according to RFC 3986 using
92
- regexp, attempts to check the public suffix using `public_suffix_service`, and serializes
92
+ regexp, attempts to check the public suffix using `public_suffix`, and serializes
93
93
  the query string using `active_support` and `addressable`'
94
94
  email: c00lryguy@gmail.com
95
95
  executables: []