iri 0.11.0 → 0.11.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '090ea814be7932c9f11a51f40052f4f6000447d48d3f0f0ebccb80b21e025482'
4
- data.tar.gz: 0e4f69a33dc33844dab9a1e17c7dfe06d4d686ffa52e0c6e2337aa903f359c88
3
+ metadata.gz: 85b6c4103f0ea74aa2c3a24441bb5be82ef0236a1ef2ee2f31848b4f7e8b9156
4
+ data.tar.gz: 305382fc068d8fe5f3b1b081236296ff45b9c700ec87666a2c00e2f9558130d9
5
5
  SHA512:
6
- metadata.gz: a8cdae3530a4804eceecd692c5e62f14cdb2cce5c50ece9e4fdc2f31fa4919429a51308e15a2035963e8a84fae5714800a875c7e78cce583da2771fdef743a0e
7
- data.tar.gz: 0af176ae76374db851c2da1b80e7b101988d94da232b485f957f1e6b10c682108d450edda87751227e0e350d533815073dce2f3d68d810c3b27754fc7276a1f6
6
+ metadata.gz: 0017afd7454f2c2ce1651a9d8d57209812e760aaa2b6582c183e9eb0142f66dd3ca464296c15aa8391d7947a5c39dd7ee172d8dd86285966df5e9a1e3ea255e2
7
+ data.tar.gz: 54d925acb96ba79905e2fd03ec2c300f1121b37923789a4054150e5e65c3c98b042117452121ce0567e368c596cee0c18628dace289d8f8947e4688e055889dc
@@ -5,7 +5,11 @@
5
5
  name: copyrights
6
6
  'on':
7
7
  push:
8
+ branches:
9
+ - master
8
10
  pull_request:
11
+ branches:
12
+ - master
9
13
  jobs:
10
14
  copyrights:
11
15
  timeout-minutes: 15
@@ -5,7 +5,11 @@
5
5
  name: xcop
6
6
  'on':
7
7
  push:
8
+ branches:
9
+ - master
8
10
  pull_request:
11
+ branches:
12
+ - master
9
13
  jobs:
10
14
  xcop:
11
15
  timeout-minutes: 15
data/iri.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
9
9
  s.required_ruby_version = '>=2.2'
10
10
  s.name = 'iri'
11
- s.version = '0.11.0'
11
+ s.version = '0.11.2'
12
12
  s.license = 'MIT'
13
13
  s.summary = 'Simple Immutable Ruby URI Builder'
14
14
  s.description = "Class Iri helps you build a URI and then modify its \
data/lib/iri.rb CHANGED
@@ -62,7 +62,7 @@ class Iri
62
62
  # @raise [InvalidURI] If the URI is malformed and safe is false
63
63
  def initialize(uri = '', local: false, safe: true)
64
64
  raise ArgumentError, "The uri can't be nil" if uri.nil?
65
- @uri = uri
65
+ @uri = uri.to_s
66
66
  @local = local
67
67
  @safe = safe
68
68
  end
@@ -217,6 +217,8 @@ class Iri
217
217
  # @see #port
218
218
  def scheme(val)
219
219
  raise ArgumentError, "The scheme can't be nil" if val.nil?
220
+ val = val.to_s
221
+ raise ArgumentError, "The scheme can't be empty" if val.empty?
220
222
  modify do |c|
221
223
  c.scheme = val
222
224
  end
@@ -234,6 +236,8 @@ class Iri
234
236
  # @see #port
235
237
  def host(val)
236
238
  raise ArgumentError, "The host can't be nil" if val.nil?
239
+ val = val.to_s
240
+ raise ArgumentError, "The host can't be empty" if val.empty?
237
241
  modify do |c|
238
242
  c.host = val
239
243
  end
@@ -251,6 +255,10 @@ class Iri
251
255
  # @see #host
252
256
  def port(val)
253
257
  raise ArgumentError, "The port can't be nil" if val.nil?
258
+ val = val.to_i
259
+ raise ArgumentError, "The port can'be negative" if val.negative?
260
+ raise ArgumentError, "The port can'be zero" if val.zero?
261
+ raise ArgumentError, "The port can'be larger than 65536" if val > 65_536
254
262
  modify do |c|
255
263
  c.port = val
256
264
  end
@@ -268,6 +276,8 @@ class Iri
268
276
  # @see #fragment
269
277
  def path(val)
270
278
  raise ArgumentError, "The path can't be nil" if val.nil?
279
+ val = val.to_s
280
+ raise ArgumentError, "The path can't be empty" if val.empty?
271
281
  modify do |c|
272
282
  c.path = val
273
283
  end
@@ -285,6 +295,7 @@ class Iri
285
295
  # @see #query
286
296
  def fragment(val)
287
297
  raise ArgumentError, "The fragment can't be nil" if val.nil?
298
+ val = val.to_s
288
299
  modify do |c|
289
300
  c.fragment = val.to_s
290
301
  end
@@ -306,6 +317,7 @@ class Iri
306
317
  # @see #over
307
318
  def query(val)
308
319
  raise ArgumentError, "The query can't be nil" if val.nil?
320
+ val = val.to_s
309
321
  modify do |c|
310
322
  c.query = val
311
323
  end
@@ -331,6 +343,8 @@ class Iri
331
343
  # @see #fragment
332
344
  def cut(path = '/')
333
345
  raise ArgumentError, "The path can't be nil" if path.nil?
346
+ path = path.to_s
347
+ raise ArgumentError, "The path can't be empty" if path.empty?
334
348
  modify do |c|
335
349
  c.query = nil
336
350
  c.path = path
@@ -360,6 +374,8 @@ class Iri
360
374
  # @see #path
361
375
  def append(part)
362
376
  raise ArgumentError, "The part can't be nil" if part.nil?
377
+ part = part.to_s
378
+ raise ArgumentError, "The part can't be empty" if part.empty?
363
379
  modify do |c|
364
380
  tail = (c.path.end_with?('/') ? '' : '/') + CGI.escape(part.to_s)
365
381
  c.path = c.path + tail
data/test/test_iri.rb CHANGED
@@ -19,9 +19,9 @@ class IriTest < Minitest::Test
19
19
  .over(q: 'books about tennis', limit: 10)
20
20
  .scheme('https')
21
21
  .host('localhost')
22
- .port('443')
22
+ .port(8080)
23
23
  .to_s
24
- assert_equal('https://localhost:443/?q=books+about+tennis&limit=10', url)
24
+ assert_equal('https://localhost:8080/?q=books+about+tennis&limit=10', url)
25
25
  end
26
26
 
27
27
  def test_converts_to_uri
@@ -31,6 +31,13 @@ class IriTest < Minitest::Test
31
31
  )
32
32
  end
33
33
 
34
+ def test_hides_https_port_number
35
+ assert_equal(
36
+ 'https://google.com/abc',
37
+ Iri.new('https://google.com').port(443).append('abc').to_s
38
+ )
39
+ end
40
+
34
41
  def test_converts_to_local
35
42
  {
36
43
  'http://localhost:9292/' => '/',
@@ -156,7 +163,7 @@ class IriTest < Minitest::Test
156
163
  def test_appends_path
157
164
  assert_equal(
158
165
  'http://google/a/b/z+%2F+7/42?x=3',
159
- Iri.new('http://google/a/b?x=3').append('z / 7').append(42).to_s
166
+ Iri.new('http://google/a/b?x=3').append('z / 7').append(42.to_s).to_s
160
167
  )
161
168
  end
162
169
 
@@ -168,10 +175,6 @@ class IriTest < Minitest::Test
168
175
  end
169
176
 
170
177
  def test_appends_empty_path
171
- assert_equal(
172
- 'http://google.com/hello/',
173
- Iri.new('http://google.com/hello').append('').append('').to_s
174
- )
175
178
  assert_equal(
176
179
  'http://google.com/test',
177
180
  Iri.new('http://google.com/hello').cut.append('test').to_s
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko