uniform_resource_identifier 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- uniform_resource_identifier (0.1.13)
4
+ uniform_resource_identifier (0.1.14)
5
5
  activesupport (>= 3.0.0)
6
6
  addressable (~> 2.2.6)
7
7
  i18n (~> 0.6.0)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.14
1
+ 0.1.15
@@ -45,6 +45,10 @@ class UniformResourceIdentifier
45
45
  }
46
46
  end
47
47
 
48
+ def blank?
49
+ @user_info.blank? && @host.blank? && @port.blank?
50
+ end
51
+
48
52
  # ======================================================================= #
49
53
  # = Attributes = #
50
54
  # ======================================================================= #
@@ -32,6 +32,11 @@ class UniformResourceIdentifier
32
32
  def to_h
33
33
  { :sld => @sld, :tld => @tld }
34
34
  end
35
+
36
+ def blank?
37
+ @sld.blank? && @tld.blank?
38
+ end
39
+
35
40
  # ======================================================================= #
36
41
  # = Attributes = #
37
42
  # ======================================================================= #
@@ -40,6 +40,10 @@ class UniformResourceIdentifier
40
40
  }
41
41
  end
42
42
 
43
+ def blank?
44
+ @subdomain.blank && @domain.blank?
45
+ end
46
+
43
47
  # ======================================================================= #
44
48
  # = Attributes = #
45
49
  # ======================================================================= #
@@ -28,6 +28,10 @@ class UniformResourceIdentifier
28
28
  :file => @file
29
29
  }
30
30
  end
31
+
32
+ def blank?
33
+ @directory.blank? && @file.blank?
34
+ end
31
35
  # ======================================================================= #
32
36
  # = Attributes = #
33
37
  # ======================================================================= #
@@ -18,8 +18,12 @@ class UniformResourceIdentifier
18
18
  end
19
19
  end
20
20
 
21
- def blank?
22
- @query.blank?
21
+ def [](key)
22
+ @query[key]
23
+ end
24
+
25
+ def []=(key, value)
26
+ @query[key] = value
23
27
  end
24
28
 
25
29
  def to_s
@@ -30,12 +34,8 @@ class UniformResourceIdentifier
30
34
  @query
31
35
  end
32
36
 
33
- def [](key)
34
- @query[key]
35
- end
36
-
37
- def []=(key, value)
38
- @query[key] = value
37
+ def blank?
38
+ @query.blank?
39
39
  end
40
40
  end
41
41
  end
@@ -38,6 +38,10 @@ class UniformResourceIdentifier
38
38
  }
39
39
  end
40
40
 
41
+ def blank?
42
+ @path.blank? && @query.blank? && @anchor.blank?
43
+ end
44
+
41
45
  # ======================================================================= #
42
46
  # = Attributes = #
43
47
  # ======================================================================= #
@@ -1,17 +1,15 @@
1
1
  RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
2
2
  match do |uri_string|
3
-
4
-
5
3
  false.should == true unless uri_specification.respond_to?(:to_hash)
6
4
  false.should == true if uri_specification == {}
7
-
5
+
8
6
  url = UniformResourceIdentifier.parse(uri_string)
9
7
  # uri_specification = uri_specification.to_hash # TODO: Needed?
10
-
8
+
11
9
  # ======================================================================= #
12
10
  # = Protocol/Scheme = #
13
11
  # ======================================================================= #
14
-
12
+
15
13
  if uri_specification.has_key?(:protocol)
16
14
  url.protocol.class.should == String
17
15
  url.protocol.to_s.should == uri_specification[:protocol]
@@ -21,19 +19,19 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
21
19
  # ======================================================================= #
22
20
  # = Authority = #
23
21
  # ======================================================================= #
24
-
22
+
25
23
  if uri_specification.has_key?(:authority)
26
24
  url.authority.class.should == UniformResourceIdentifier::Authority
27
25
  url.authority.to_s.should == uri_specification[:authority]
28
26
  end
29
-
27
+
30
28
  if uri_specification.has_key?(:user_info)
31
29
  url.authority.user_info.class.should == UniformResourceIdentifier::UserInfo
32
30
  url.authority.user_info.to_s.should == uri_specification[:user_info]
33
31
  url.user_info.class.should == UniformResourceIdentifier::UserInfo # Delegate
34
32
  url.user_info.to_s.should == uri_specification[:user_info] # Delegate
35
33
  end
36
-
34
+
37
35
  if uri_specification.has_key?(:username)
38
36
  url.authority.user_info.username.class.should == String
39
37
  url.authority.user_info.username.to_s.should == uri_specification[:username]
@@ -42,7 +40,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
42
40
  url.username.class.should == String # Delegate
43
41
  url.username.to_s.should == uri_specification[:username] # Delegate
44
42
  end
45
-
43
+
46
44
  if uri_specification.has_key?(:password)
47
45
  url.authority.user_info.password.class.should == String
48
46
  url.authority.user_info.password.to_s.should == uri_specification[:password]
@@ -51,14 +49,14 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
51
49
  url.password.class.should == String # Delegate
52
50
  url.password.to_s.should == uri_specification[:password] # Delegate
53
51
  end
54
-
52
+
55
53
  if uri_specification.has_key?(:host)
56
54
  url.authority.host.class.should == UniformResourceIdentifier::Host
57
55
  url.authority.host.to_s.should == uri_specification[:host]
58
56
  url.host.class.should == UniformResourceIdentifier::Host # Delegate
59
57
  url.host.to_s.should == uri_specification[:host] # Delegate
60
58
  end
61
-
59
+
62
60
  if uri_specification.has_key?(:subdomain)
63
61
  url.authority.host.subdomain.class.should == String
64
62
  url.authority.host.subdomain.to_s.should == uri_specification[:subdomain]
@@ -67,7 +65,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
67
65
  url.subdomain.class.should == String # Delegate
68
66
  url.subdomain.to_s.should == uri_specification[:subdomain] # Delegate
69
67
  end
70
-
68
+
71
69
  if uri_specification.has_key?(:domain)
72
70
  url.authority.host.domain.class.should == UniformResourceIdentifier::Domain
73
71
  url.authority.host.domain.to_s.should == uri_specification[:domain]
@@ -76,7 +74,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
76
74
  url.domain.class.should == UniformResourceIdentifier::Domain # Delegate
77
75
  url.domain.to_s.should == uri_specification[:domain] # Delegate
78
76
  end
79
-
77
+
80
78
  if uri_specification.has_key?(:sld)
81
79
  url.authority.host.domain.sld.class.should == String
82
80
  url.authority.host.sld.to_s.should == uri_specification[:sld]
@@ -85,7 +83,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
85
83
  url.sld.class.should == String # Delegate
86
84
  url.sld.to_s.should == uri_specification[:sld] # Delegate
87
85
  end
88
-
86
+
89
87
  if uri_specification.has_key?(:tld)
90
88
  url.authority.host.domain.tld.class.should == String
91
89
  url.authority.host.tld.to_s.should == uri_specification[:tld]
@@ -94,30 +92,30 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
94
92
  url.tld.class.should == String # Delegate
95
93
  url.tld.to_s.should == uri_specification[:tld] # Delegate
96
94
  end
97
-
95
+
98
96
  if uri_specification.has_key?(:port)
99
97
  url.authority.port.class.should == Fixnum
100
98
  url.authority.port.to_s.should == uri_specification[:port]
101
99
  url.port.class.should == Fixnum # Delegate
102
100
  url.port.to_s.should == uri_specification[:port] # Delegate
103
101
  end
104
-
102
+
105
103
  # ======================================================================= #
106
104
  # = Relative = #
107
105
  # ======================================================================= #
108
-
106
+
109
107
  if uri_specification.has_key?(:relative)
110
108
  url.relative.class.should == UniformResourceIdentifier::Relative
111
109
  url.relative.to_s.should == uri_specification[:relative]
112
110
  end
113
-
111
+
114
112
  if uri_specification.has_key?(:path)
115
113
  url.relative.path.class.should == UniformResourceIdentifier::Path
116
114
  url.relative.path.to_s.should == uri_specification[:path]
117
115
  url.path.class.should == UniformResourceIdentifier::Path # Delegate
118
116
  url.path.to_s.should == uri_specification[:path] # Delegate
119
117
  end
120
-
118
+
121
119
  if uri_specification.has_key?(:directory)
122
120
  url.relative.path.directory.class.should == String
123
121
  url.relative.path.directory.to_s.should == uri_specification[:directory]
@@ -126,7 +124,7 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
126
124
  url.directory.class.should == String # Delegate
127
125
  url.directory.to_s.should == uri_specification[:directory] # Delegate
128
126
  end
129
-
127
+
130
128
  if uri_specification.has_key?(:file)
131
129
  url.relative.path.file.class.should == String
132
130
  url.relative.path.file.to_s.should == uri_specification[:file]
@@ -135,14 +133,14 @@ RSpec::Matchers.define(:have_uri_specification) do |uri_specification|
135
133
  url.file.class.should == String # Delegate
136
134
  url.file.to_s.should == uri_specification[:file] # Delegate
137
135
  end
138
-
136
+
139
137
  if uri_specification.has_key?(:query)
140
138
  url.relative.query.class.should == UniformResourceIdentifier::Query
141
139
  url.relative.query.to_s.should == uri_specification[:query]
142
140
  url.query.class.should == UniformResourceIdentifier::Query # Delegate
143
141
  url.query.to_s.should == uri_specification[:query] # Delegate
144
142
  end
145
-
143
+
146
144
  if uri_specification.has_key?(:anchor)
147
145
  url.relative.anchor.class.should == String
148
146
  url.relative.anchor.to_s.should == uri_specification[:anchor]
@@ -16,10 +16,6 @@ class UniformResourceIdentifier
16
16
  end
17
17
  end
18
18
 
19
- def blank?
20
- @username.blank? && @password.blank?
21
- end
22
-
23
19
  def to_s
24
20
  "#{@username}:#{@password}"
25
21
  end
@@ -30,6 +26,10 @@ class UniformResourceIdentifier
30
26
  :password => @password
31
27
  }
32
28
  end
29
+
30
+ def blank?
31
+ @username.blank? && @password.blank?
32
+ end
33
33
  # ======================================================================= #
34
34
  # = Attributes = #
35
35
  # ======================================================================= #
@@ -62,6 +62,10 @@ describe UniformResourceIdentifier do
62
62
  # :query => "q1=0&test1=true&test2=value&arr[]=one&arr[]=two&hsh[foo]=bar&test3=val3",
63
63
  :anchor => "top"
64
64
  )
65
+
66
+ url.should have_uri_specification(
67
+ :host => "www.test.com"
68
+ )
65
69
  end
66
70
  end
67
71
 
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.14
4
+ version: 0.1.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-31 00:00:00.000000000Z
12
+ date: 2011-11-01 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: public_suffix_service
16
- requirement: &70309375717880 !ruby/object:Gem::Requirement
16
+ requirement: &70151749127200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.9.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70309375717880
24
+ version_requirements: *70151749127200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activesupport
27
- requirement: &70309375717280 !ruby/object:Gem::Requirement
27
+ requirement: &70151749126720 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70309375717280
35
+ version_requirements: *70151749126720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: addressable
38
- requirement: &70309375716720 !ruby/object:Gem::Requirement
38
+ requirement: &70151749126180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.2.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70309375716720
46
+ version_requirements: *70151749126180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: i18n
49
- requirement: &70309375716140 !ruby/object:Gem::Requirement
49
+ requirement: &70151749125720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 0.6.0
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70309375716140
57
+ version_requirements: *70151749125720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70309375715620 !ruby/object:Gem::Requirement
60
+ requirement: &70151749125260 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70309375715620
68
+ version_requirements: *70151749125260
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70309375715140 !ruby/object:Gem::Requirement
71
+ requirement: &70151749124780 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.6.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70309375715140
79
+ version_requirements: *70151749124780
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: fuubar
82
- requirement: &70309375714640 !ruby/object:Gem::Requirement
82
+ requirement: &70151749124260 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.0.6
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70309375714640
90
+ version_requirements: *70151749124260
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: watchr
93
- requirement: &70309375688880 !ruby/object:Gem::Requirement
93
+ requirement: &70151749123780 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: 0.7.0
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70309375688880
101
+ version_requirements: *70151749123780
102
102
  description: ! '`uniform_resource_identifier` splits URIs according to RFC 3986 using
103
103
  regexp, attempts to check the public suffix using `public_suffix_service`, and serializes
104
104
  the query string using `active_support` and `addressable`'