iri 0.6.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce27b75cc4402cfb28991f6f061b2191e298dde147d77bf6b5c6215b96d1cc83
4
- data.tar.gz: 2f01f12f02dbdc96f7923c2a1c2d0ea18ccf9d7c3ae44c001626fc16d96b60c1
3
+ metadata.gz: 6f999bd94bb431514584216e518edd721ce449e2af0f7cc4921073bc0b3d33a2
4
+ data.tar.gz: 8b73e9a02dadc087f7024ccc020ce3a1f1e6f816a612edaca4fb4fa92507db24
5
5
  SHA512:
6
- metadata.gz: 38bc3965b37e014551e3048ec24736d3c56f2810e2b2cc32c50ef199ea19ff96e8396fdc9299a1c5d0aaa360901e5f7fdc37844f43800eddc04513cbe80f4e1f
7
- data.tar.gz: e6bdbddd987e10546f8c05939b68dc85ca79961da4deed79fb73eabf00b35b0dfae0ce1324491ae1c01c61bcdaefdd1abd765c3a666572b7581e7d65e9e1998f
6
+ metadata.gz: 35accdc23c65209ca3436dfa04cb6d026e745fd0d9a4893f7ad4683ba80ef06da5e7a54d8918fb4db7e0692c9e44384d0a606ee09b4186c038f517e83695ea5e
7
+ data.tar.gz: c74f2a7818bc367b283fe39e16a721525cd080fdd5f56c348fb52244b92273ef2e66d19e2bee71310453731c75605f6b3de3529abd2f15a2e9b2d3b1e80057b3
@@ -8,13 +8,13 @@ jobs:
8
8
  codecov:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
- - uses: actions/checkout@v3
11
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
12
12
  - uses: ruby/setup-ruby@v1
13
13
  with:
14
14
  ruby-version: 2.7
15
15
  - run: bundle update
16
16
  - run: bundle exec rake
17
- - uses: codecov/codecov-action@v3
17
+ - uses: codecov/codecov-action@v4.0.0-beta.3
18
18
  with:
19
19
  file: coverage/.resultset.json
20
20
  fail_ci_if_error: true
@@ -16,7 +16,7 @@ jobs:
16
16
  ruby: [2.7, 3.1]
17
17
  runs-on: ${{ matrix.os }}
18
18
  steps:
19
- - uses: actions/checkout@v3
19
+ - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
20
20
  - uses: ruby/setup-ruby@v1
21
21
  with:
22
22
  ruby-version: ${{ matrix.ruby }}
data/.rubocop.yml CHANGED
@@ -5,8 +5,7 @@ AllCops:
5
5
  NewCops: enable
6
6
 
7
7
  Metrics/ClassLength:
8
- Exclude:
9
- - 'test/*.rb'
8
+ Max: 200
10
9
  Layout/EmptyLineAfterGuardClause:
11
10
  Enabled: false
12
11
  Layout/MultilineMethodCallIndentation:
data/.rultor.yml CHANGED
@@ -1,11 +1,12 @@
1
1
  docker:
2
- image: yegor256/rultor-image:1.20.0
2
+ image: yegor256/rultor-image:1.22.0
3
3
  assets:
4
4
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
5
  install: |-
6
6
  pdd -f /dev/null
7
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
7
+ bundle install --no-color
8
8
  release:
9
+ pre: false
9
10
  script: |-
10
11
  [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
11
12
  bundle exec rake
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
@@ -23,9 +23,9 @@
23
23
  source 'https://rubygems.org'
24
24
  gemspec
25
25
 
26
- gem 'minitest', '5.18.0', require: false
27
- gem 'rake', '13.0.6', require: false
28
- gem 'rdoc', '6.5.0', require: false
29
- gem 'rubocop', '1.52.0', require: false
30
- gem 'rubocop-rspec', '2.22.0', require: false
26
+ gem 'minitest', '5.20.0', require: false
27
+ gem 'rake', '13.1.0', require: false
28
+ gem 'rdoc', '6.6.2', require: false
29
+ gem 'rubocop', '1.59.0', require: false
30
+ gem 'rubocop-rspec', '2.25.0', require: false
31
31
  gem 'simplecov', '0.22.0', require: false
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019-2023 Yegor Bugayenko
3
+ Copyright (c) 2019-2024 Yegor Bugayenko
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -10,7 +10,6 @@
10
10
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/iri/master/frames)
11
11
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/iri/blob/master/LICENSE.txt)
12
12
  [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/iri.svg)](https://codecov.io/github/yegor256/iri?branch=master)
13
- ![Lines of code](https://img.shields.io/tokei/lines/github/yegor256/iri)
14
13
  [![Hits-of-Code](https://hitsofcode.com/github/yegor256/iri)](https://hitsofcode.com/view/github/yegor256/iri)
15
14
 
16
15
  The class [`Iri`](https://www.rubydoc.info/github/yegor256/iri/master/Iri)
@@ -23,7 +22,7 @@ url = Iri.new('http://google.com/')
23
22
  .append('find').append('me') # -> http://google.com/find/me
24
23
  .add(q: 'books about OOP', limit: 50) # -> ?q=books+about+OOP&limit=50
25
24
  .del(:q) # remove this query parameter
26
- .del('limit') # remove this one too
25
+ .del('limit', 'speed') # also remove these two
27
26
  .over(q: 'books about tennis', limit: 10) # replace these params
28
27
  .scheme('https') # replace 'http' with 'https'
29
28
  .host('localhost') # replace the host name
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/iri.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2019-2023 Yegor Bugayenko
5
+ # Copyright (c) 2019-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -27,11 +27,13 @@ Gem::Specification.new do |s|
27
27
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
28
28
  s.required_ruby_version = '>=2.2'
29
29
  s.name = 'iri'
30
- s.version = '0.6.0'
30
+ s.version = '0.8.0'
31
31
  s.license = 'MIT'
32
32
  s.summary = 'Simple Immutable Ruby URI Builder'
33
- s.description = 'Class Iri helps you build a URI and then modify its \
34
- parts via a simple fluent interface.'
33
+ s.description = "Class Iri helps you build a URI and then modify its \
34
+ parts via a simple immutable fluent interface. It always returns a new \
35
+ object instead of changing the existing one. This makes the object \
36
+ safer and much easier for reuse."
35
37
  s.authors = ['Yegor Bugayenko']
36
38
  s.email = 'yegor256@gmail.com'
37
39
  s.homepage = 'https://github.com/yegor256/iri'
data/lib/iri.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2019-2023 Yegor Bugayenko
5
+ # Copyright (c) 2019-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -42,12 +42,15 @@ require 'cgi'
42
42
  # {README}[https://github.com/yegor256/iri/blob/master/README.md] file.
43
43
  #
44
44
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
45
- # Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
45
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
46
46
  # License:: MIT
47
47
  class Iri
48
48
  # When URI is not valid.
49
49
  class InvalidURI < StandardError; end
50
50
 
51
+ # When .add(), .over(), or .del() arguments are not valid.
52
+ class InvalidArguments < StandardError; end
53
+
51
54
  # Makes a new object.
52
55
  #
53
56
  # You can even ignore the argument, which will produce an empty URI.
@@ -65,6 +68,11 @@ class Iri
65
68
  @uri.to_s
66
69
  end
67
70
 
71
+ # Inspect it, like a string can be inspected.
72
+ def inspect
73
+ @uri.to_s.inspect
74
+ end
75
+
68
76
  # Convert it to an object of class +URI+.
69
77
  def to_uri
70
78
  the_uri.clone
@@ -83,6 +91,7 @@ class Iri
83
91
  # Iri.new('https://google.com').del(:q).add(q: 'test')
84
92
  #
85
93
  def add(hash)
94
+ raise InvalidArguments unless hash.is_a?(Hash)
86
95
  modify_query do |params|
87
96
  hash.each do |k, v|
88
97
  params[k.to_s] = [] unless params[k.to_s]
@@ -110,6 +119,7 @@ class Iri
110
119
  # Iri.new('https://google.com?q=test').over(q: 'hey you!')
111
120
  #
112
121
  def over(hash)
122
+ raise InvalidArguments unless hash.is_a?(Hash)
113
123
  modify_query do |params|
114
124
  hash.each do |k, v|
115
125
  params[k.to_s] = [] unless params[k]
data/test/test__helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2019-2023 Yegor Bugayenko
3
+ # Copyright (c) 2019-2024 Yegor Bugayenko
4
4
  #
5
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  # of this software and associated documentation files (the 'Software'), to deal
data/test/test_iri.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # (The MIT License)
4
4
  #
5
- # Copyright (c) 2019-2023 Yegor Bugayenko
5
+ # Copyright (c) 2019-2024 Yegor Bugayenko
6
6
  #
7
7
  # Permission is hereby granted, free of charge, to any person obtaining a copy
8
8
  # of this software and associated documentation files (the 'Software'), to deal
@@ -27,7 +27,7 @@ require_relative '../lib/iri'
27
27
 
28
28
  # Iri test.
29
29
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
30
- # Copyright:: Copyright (c) 2019-2023 Yegor Bugayenko
30
+ # Copyright:: Copyright (c) 2019-2024 Yegor Bugayenko
31
31
  # License:: MIT
32
32
  class IriTest < Minitest::Test
33
33
  def test_builds_uri
@@ -49,6 +49,18 @@ class IriTest < Minitest::Test
49
49
  end
50
50
  end
51
51
 
52
+ def test_incorrect_call_of_add
53
+ assert_raises Iri::InvalidArguments do
54
+ Iri.new('https://example.com/').add('hello5')
55
+ end
56
+ end
57
+
58
+ def test_incorrect_call_of_over
59
+ assert_raises Iri::InvalidArguments do
60
+ Iri.new('https://example5.com/').over('boom44')
61
+ end
62
+ end
63
+
52
64
  def test_broken_uri_in_safe_mode
53
65
  Iri.new('https://example.com/>>>').add(a: 1)
54
66
  end
@@ -60,6 +72,13 @@ class IriTest < Minitest::Test
60
72
  )
61
73
  end
62
74
 
75
+ def test_inspects_iri
76
+ assert_equal(
77
+ '"https://openai.com"',
78
+ Iri.new('https://openai.com').inspect
79
+ )
80
+ end
81
+
63
82
  def test_replaces_scheme
64
83
  assert_equal(
65
84
  'https://google.com/',
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-04 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: |-
14
- Class Iri helps you build a URI and then modify its \
15
- parts via a simple fluent interface.
13
+ description: Class Iri helps you build a URI and then modify its parts via a simple
14
+ immutable fluent interface. It always returns a new object instead of changing the
15
+ existing one. This makes the object safer and much easier for reuse.
16
16
  email: yegor256@gmail.com
17
17
  executables: []
18
18
  extensions: []
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0'
60
60
  requirements: []
61
- rubygems_version: 3.2.15
61
+ rubygems_version: 3.4.10
62
62
  signing_key:
63
63
  specification_version: 4
64
64
  summary: Simple Immutable Ruby URI Builder