iri 0.7.0 → 0.9.0
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 +4 -4
- data/.0pdd.yml +22 -4
- data/.github/workflows/actionlint.yml +43 -0
- data/.github/workflows/codecov.yml +31 -7
- data/.github/workflows/copyrights.yml +32 -0
- data/.github/workflows/markdown-lint.yml +40 -0
- data/.github/workflows/pdd.yml +36 -0
- data/.github/workflows/rake.yml +28 -5
- data/.github/workflows/xcop.yml +32 -0
- data/.github/workflows/yamllint.yml +36 -0
- data/.gitignore +0 -1
- data/.rubocop.yml +27 -0
- data/.rultor.yml +25 -2
- data/Gemfile +8 -6
- data/Gemfile.lock +79 -0
- data/LICENSE.txt +1 -1
- data/README.md +18 -13
- data/Rakefile +1 -1
- data/iri.gemspec +2 -2
- data/lib/iri.rb +60 -2
- data/logo.svg +1 -1
- data/test/test__helper.rb +1 -1
- data/test/test_iri.rb +32 -2
- metadata +13 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6b0ead5ff4a49ffdb3c0dda53b2cd03d92746aa4a3338c0320b539be271e3f6b
|
|
4
|
+
data.tar.gz: 5c1b3de33446ec5e6f88dd077511ec5bb210692d4891da434cdbc778dba0107a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9d303b3a342e9d3f2517ae478f29ccbbd5bf4359afa7ed7237dd3e9b7991f9c060a6cc262f3af086364129d3b6de55901f42e0e9a3c42023539c6111fd3213d7
|
|
7
|
+
data.tar.gz: 274c64e316691fd65e05b14cef70bf18929a37225e2511492988d501a4d68253727cda1788d4596b123c5520178af0a7915b2a7a2672aeba65eb071acc00fa75
|
data/.0pdd.yml
CHANGED
|
@@ -1,9 +1,27 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
1
23
|
errors:
|
|
2
24
|
- yegor256@gmail.com
|
|
3
|
-
# alerts:
|
|
4
|
-
# github:
|
|
5
|
-
# - yegor256
|
|
6
|
-
|
|
7
25
|
tags:
|
|
8
26
|
- pdd
|
|
9
27
|
- bug
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: actionlint
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
branches:
|
|
27
|
+
- master
|
|
28
|
+
pull_request:
|
|
29
|
+
branches:
|
|
30
|
+
- master
|
|
31
|
+
jobs:
|
|
32
|
+
actionlint:
|
|
33
|
+
runs-on: ubuntu-24.04
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- name: Download actionlint
|
|
37
|
+
id: get_actionlint
|
|
38
|
+
# yamllint disable-line rule:line-length
|
|
39
|
+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
40
|
+
shell: bash
|
|
41
|
+
- name: Check workflow files
|
|
42
|
+
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
|
43
|
+
shell: bash
|
|
@@ -1,20 +1,44 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
1
22
|
---
|
|
2
23
|
name: codecov
|
|
3
|
-
on:
|
|
24
|
+
'on':
|
|
4
25
|
push:
|
|
5
26
|
branches:
|
|
6
27
|
- master
|
|
7
28
|
jobs:
|
|
8
29
|
codecov:
|
|
9
|
-
runs-on: ubuntu-
|
|
30
|
+
runs-on: ubuntu-24.04
|
|
10
31
|
steps:
|
|
11
|
-
- uses: actions/checkout@
|
|
32
|
+
- uses: actions/checkout@v4
|
|
12
33
|
- uses: ruby/setup-ruby@v1
|
|
13
34
|
with:
|
|
14
|
-
ruby-version:
|
|
15
|
-
|
|
35
|
+
ruby-version: 3.3
|
|
36
|
+
bundler-cache: true
|
|
37
|
+
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
|
38
|
+
- run: bundle install
|
|
16
39
|
- run: bundle exec rake
|
|
17
|
-
- uses: codecov/codecov-action@
|
|
40
|
+
- uses: codecov/codecov-action@v5
|
|
18
41
|
with:
|
|
19
|
-
|
|
42
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
43
|
+
files: coverage/.resultset.json
|
|
20
44
|
fail_ci_if_error: true
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: copyrights
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
pull_request:
|
|
27
|
+
jobs:
|
|
28
|
+
copyrights:
|
|
29
|
+
runs-on: ubuntu-24.04
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: yegor256/copyrights-action@0.0.8
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: markdown-lint
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
branches:
|
|
27
|
+
- master
|
|
28
|
+
pull_request:
|
|
29
|
+
branches:
|
|
30
|
+
- master
|
|
31
|
+
paths-ignore: ['paper/**', 'sandbox/**']
|
|
32
|
+
concurrency:
|
|
33
|
+
group: markdown-lint-${{ github.ref }}
|
|
34
|
+
cancel-in-progress: true
|
|
35
|
+
jobs:
|
|
36
|
+
markdown-lint:
|
|
37
|
+
runs-on: ubuntu-24.04
|
|
38
|
+
steps:
|
|
39
|
+
- uses: actions/checkout@v4
|
|
40
|
+
- uses: articulate/actions-markdownlint@v1
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: pdd
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
branches:
|
|
27
|
+
- master
|
|
28
|
+
pull_request:
|
|
29
|
+
branches:
|
|
30
|
+
- master
|
|
31
|
+
jobs:
|
|
32
|
+
pdd:
|
|
33
|
+
runs-on: ubuntu-24.04
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: volodya-lombrozo/pdd-action@master
|
data/.github/workflows/rake.yml
CHANGED
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
1
22
|
---
|
|
2
23
|
name: rake
|
|
3
|
-
on:
|
|
24
|
+
'on':
|
|
4
25
|
push:
|
|
5
26
|
branches:
|
|
6
27
|
- master
|
|
@@ -12,13 +33,15 @@ jobs:
|
|
|
12
33
|
name: test
|
|
13
34
|
strategy:
|
|
14
35
|
matrix:
|
|
15
|
-
os: [ubuntu-
|
|
16
|
-
ruby: [
|
|
36
|
+
os: [ubuntu-24.04, macos-15, windows-2022]
|
|
37
|
+
ruby: [3.3]
|
|
17
38
|
runs-on: ${{ matrix.os }}
|
|
18
39
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
40
|
+
- uses: actions/checkout@v4
|
|
20
41
|
- uses: ruby/setup-ruby@v1
|
|
21
42
|
with:
|
|
22
43
|
ruby-version: ${{ matrix.ruby }}
|
|
23
|
-
|
|
44
|
+
bundler-cache: true
|
|
45
|
+
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
|
46
|
+
- run: bundle install
|
|
24
47
|
- run: bundle exec rake
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: xcop
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
pull_request:
|
|
27
|
+
jobs:
|
|
28
|
+
xcop:
|
|
29
|
+
runs-on: ubuntu-24.04
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- uses: g4s8/xcop-action@master
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
23
|
+
name: yamllint
|
|
24
|
+
'on':
|
|
25
|
+
push:
|
|
26
|
+
branches:
|
|
27
|
+
- master
|
|
28
|
+
pull_request:
|
|
29
|
+
branches:
|
|
30
|
+
- master
|
|
31
|
+
jobs:
|
|
32
|
+
yamllint:
|
|
33
|
+
runs-on: ubuntu-24.04
|
|
34
|
+
steps:
|
|
35
|
+
- uses: actions/checkout@v4
|
|
36
|
+
- uses: ibiqlik/action-yamllint@v3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
1
23
|
AllCops:
|
|
2
24
|
DisplayCopNames: true
|
|
3
25
|
TargetRubyVersion: 2.2
|
|
4
26
|
SuggestExtensions: false
|
|
5
27
|
NewCops: enable
|
|
28
|
+
require:
|
|
29
|
+
- rubocop-minitest
|
|
30
|
+
- rubocop-performance
|
|
6
31
|
|
|
32
|
+
Minitest/EmptyLineBeforeAssertionMethods:
|
|
33
|
+
Enabled: false
|
|
7
34
|
Metrics/ClassLength:
|
|
8
35
|
Max: 200
|
|
9
36
|
Layout/EmptyLineAfterGuardClause:
|
data/.rultor.yml
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
+
# (The MIT License)
|
|
2
|
+
#
|
|
3
|
+
# Copyright (c) 2019-2025 Yegor Bugayenko
|
|
4
|
+
#
|
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
# of this software and associated documentation files (the 'Software'), to deal
|
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
# furnished to do so, subject to the following conditions:
|
|
11
|
+
#
|
|
12
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
# copies or substantial portions of the Software.
|
|
14
|
+
#
|
|
15
|
+
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
# SOFTWARE.
|
|
22
|
+
---
|
|
1
23
|
docker:
|
|
2
|
-
image: yegor256/rultor-
|
|
24
|
+
image: yegor256/rultor-ruby
|
|
3
25
|
assets:
|
|
4
26
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
|
5
27
|
install: |-
|
|
6
28
|
pdd -f /dev/null
|
|
7
|
-
|
|
29
|
+
bundle install --no-color
|
|
8
30
|
release:
|
|
31
|
+
pre: false
|
|
9
32
|
script: |-
|
|
10
33
|
[[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
|
|
11
34
|
bundle exec rake
|
data/Gemfile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
3
|
+
# Copyright (c) 2019-2025 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,11 @@
|
|
|
23
23
|
source 'https://rubygems.org'
|
|
24
24
|
gemspec
|
|
25
25
|
|
|
26
|
-
gem 'minitest', '5.
|
|
27
|
-
gem 'rake', '13.
|
|
28
|
-
gem 'rdoc', '6.
|
|
29
|
-
gem 'rubocop', '1.
|
|
30
|
-
gem 'rubocop-
|
|
26
|
+
gem 'minitest', '5.25.4', require: false
|
|
27
|
+
gem 'rake', '13.2.1', require: false
|
|
28
|
+
gem 'rdoc', '6.11.0', require: false
|
|
29
|
+
gem 'rubocop', '1.71.0', require: false
|
|
30
|
+
gem 'rubocop-minitest', '0.36.0', require: false
|
|
31
|
+
gem 'rubocop-performance', '1.23.1', require: false
|
|
32
|
+
gem 'rubocop-rspec', '3.4.0', require: false
|
|
31
33
|
gem 'simplecov', '0.22.0', require: false
|
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
iri (0.0.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
ast (2.4.2)
|
|
10
|
+
date (3.4.1)
|
|
11
|
+
docile (1.4.1)
|
|
12
|
+
json (2.9.1)
|
|
13
|
+
language_server-protocol (3.17.0.4)
|
|
14
|
+
minitest (5.25.4)
|
|
15
|
+
parallel (1.26.3)
|
|
16
|
+
parser (3.3.7.0)
|
|
17
|
+
ast (~> 2.4.1)
|
|
18
|
+
racc
|
|
19
|
+
psych (5.2.3)
|
|
20
|
+
date
|
|
21
|
+
stringio
|
|
22
|
+
racc (1.8.1)
|
|
23
|
+
rainbow (3.1.1)
|
|
24
|
+
rake (13.2.1)
|
|
25
|
+
rdoc (6.11.0)
|
|
26
|
+
psych (>= 4.0.0)
|
|
27
|
+
regexp_parser (2.10.0)
|
|
28
|
+
rubocop (1.71.0)
|
|
29
|
+
json (~> 2.3)
|
|
30
|
+
language_server-protocol (>= 3.17.0)
|
|
31
|
+
parallel (~> 1.10)
|
|
32
|
+
parser (>= 3.3.0.2)
|
|
33
|
+
rainbow (>= 2.2.2, < 4.0)
|
|
34
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
|
35
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
|
36
|
+
ruby-progressbar (~> 1.7)
|
|
37
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
|
38
|
+
rubocop-ast (1.38.0)
|
|
39
|
+
parser (>= 3.3.1.0)
|
|
40
|
+
rubocop-minitest (0.36.0)
|
|
41
|
+
rubocop (>= 1.61, < 2.0)
|
|
42
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
43
|
+
rubocop-performance (1.23.1)
|
|
44
|
+
rubocop (>= 1.48.1, < 2.0)
|
|
45
|
+
rubocop-ast (>= 1.31.1, < 2.0)
|
|
46
|
+
rubocop-rspec (3.4.0)
|
|
47
|
+
rubocop (~> 1.61)
|
|
48
|
+
ruby-progressbar (1.13.0)
|
|
49
|
+
simplecov (0.22.0)
|
|
50
|
+
docile (~> 1.1)
|
|
51
|
+
simplecov-html (~> 0.11)
|
|
52
|
+
simplecov_json_formatter (~> 0.1)
|
|
53
|
+
simplecov-html (0.13.1)
|
|
54
|
+
simplecov_json_formatter (0.1.4)
|
|
55
|
+
stringio (3.1.2)
|
|
56
|
+
unicode-display_width (3.1.4)
|
|
57
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
|
58
|
+
unicode-emoji (4.0.4)
|
|
59
|
+
|
|
60
|
+
PLATFORMS
|
|
61
|
+
arm64-darwin-22
|
|
62
|
+
arm64-darwin-23
|
|
63
|
+
arm64-darwin-24
|
|
64
|
+
x64-mingw-ucrt
|
|
65
|
+
x86_64-linux
|
|
66
|
+
|
|
67
|
+
DEPENDENCIES
|
|
68
|
+
iri!
|
|
69
|
+
minitest (= 5.25.4)
|
|
70
|
+
rake (= 13.2.1)
|
|
71
|
+
rdoc (= 6.11.0)
|
|
72
|
+
rubocop (= 1.71.0)
|
|
73
|
+
rubocop-minitest (= 0.36.0)
|
|
74
|
+
rubocop-performance (= 1.23.1)
|
|
75
|
+
rubocop-rspec (= 3.4.0)
|
|
76
|
+
simplecov (= 0.22.0)
|
|
77
|
+
|
|
78
|
+
BUNDLED WITH
|
|
79
|
+
2.5.16
|
data/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2019-
|
|
3
|
+
Copyright (c) 2019-2025 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# Immutable URI Builder for Ruby
|
|
2
2
|
|
|
3
3
|
[](https://www.elegantobjects.org)
|
|
4
4
|
[](http://www.rultor.com/p/yegor256/iri)
|
|
@@ -10,12 +10,11 @@
|
|
|
10
10
|
[](http://rubydoc.info/github/yegor256/iri/master/frames)
|
|
11
11
|
[](https://github.com/yegor256/iri/blob/master/LICENSE.txt)
|
|
12
12
|
[](https://codecov.io/github/yegor256/iri?branch=master)
|
|
13
|
-

|
|
14
13
|
[](https://hitsofcode.com/view/github/yegor256/iri)
|
|
15
14
|
|
|
16
15
|
The class [`Iri`](https://www.rubydoc.info/github/yegor256/iri/master/Iri)
|
|
17
16
|
helps you build a URI and then modify its
|
|
18
|
-
parts via a simple [fluent interface]
|
|
17
|
+
parts via a simple [fluent interface]:
|
|
19
18
|
|
|
20
19
|
```ruby
|
|
21
20
|
require '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
|
|
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
|
|
@@ -35,17 +34,18 @@ url = Iri.new('http://google.com/')
|
|
|
35
34
|
.to_s # convert it to a string
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
The full list of methods is
|
|
37
|
+
The full list of methods is
|
|
38
|
+
[here](https://www.rubydoc.info/github/yegor256/iri/master/Iri).
|
|
39
39
|
|
|
40
40
|
Install it:
|
|
41
41
|
|
|
42
42
|
```bash
|
|
43
|
-
|
|
43
|
+
gem install iri
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
Or add this to your `Gemfile`:
|
|
47
47
|
|
|
48
|
-
```
|
|
48
|
+
```ruby
|
|
49
49
|
gem 'iri'
|
|
50
50
|
```
|
|
51
51
|
|
|
@@ -65,18 +65,23 @@ Of course, it's better to create the `iri` object only once per request
|
|
|
65
65
|
and re-use it where you need. It's _immutable_, so you won't have any
|
|
66
66
|
side-effects.
|
|
67
67
|
|
|
68
|
-
PS. See how I use it in this Sinatra web app:
|
|
68
|
+
PS. See how I use it in this Sinatra web app:
|
|
69
|
+
[yegor256/0rsk](https://github.com/yegor256/0rsk).
|
|
69
70
|
|
|
70
71
|
## How to contribute
|
|
71
72
|
|
|
72
|
-
Read
|
|
73
|
+
Read
|
|
74
|
+
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
|
73
75
|
Make sure you build is green before you contribute
|
|
74
|
-
your pull request. You will need to have
|
|
76
|
+
your pull request. You will need to have
|
|
77
|
+
[Ruby](https://www.ruby-lang.org/en/) 2.3+ and
|
|
75
78
|
[Bundler](https://bundler.io/) installed. Then:
|
|
76
79
|
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
```bash
|
|
81
|
+
bundle update
|
|
82
|
+
bundle exec rake
|
|
80
83
|
```
|
|
81
84
|
|
|
82
85
|
If it's clean and you don't see any error messages, submit your pull request.
|
|
86
|
+
|
|
87
|
+
[fluent interface]: https://en.wikipedia.org/wiki/Fluent_interface
|
data/Rakefile
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
3
|
+
# Copyright (c) 2019-2025 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-
|
|
5
|
+
# Copyright (c) 2019-2025 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 @@ 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.
|
|
30
|
+
s.version = '0.9.0'
|
|
31
31
|
s.license = 'MIT'
|
|
32
32
|
s.summary = 'Simple Immutable Ruby URI Builder'
|
|
33
33
|
s.description = "Class Iri helps you build a URI and then modify its \
|
data/lib/iri.rb
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# (The MIT License)
|
|
4
4
|
#
|
|
5
|
-
# Copyright (c) 2019-
|
|
5
|
+
# Copyright (c) 2019-2025 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-
|
|
45
|
+
# Copyright:: Copyright (c) 2019-2025 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.
|
|
@@ -55,26 +58,49 @@ class Iri
|
|
|
55
58
|
# By default, this class will never throw any exceptions, even if your URI
|
|
56
59
|
# is not valid. It will just assume that the URI is"/". However,
|
|
57
60
|
# you can turn this mode off, by specifying safe as FALSE.
|
|
61
|
+
#
|
|
62
|
+
# @param [String] uri URI
|
|
63
|
+
# @param [Boolean] safe SHould it safe?
|
|
58
64
|
def initialize(uri = '', safe: true)
|
|
59
65
|
@uri = uri
|
|
60
66
|
@safe = safe
|
|
61
67
|
end
|
|
62
68
|
|
|
63
69
|
# Convert it to a string.
|
|
70
|
+
#
|
|
71
|
+
# @return [String] New URI
|
|
64
72
|
def to_s
|
|
65
73
|
@uri.to_s
|
|
66
74
|
end
|
|
67
75
|
|
|
68
76
|
# Inspect it, like a string can be inspected.
|
|
77
|
+
#
|
|
78
|
+
# @return [String] Details of it
|
|
69
79
|
def inspect
|
|
70
80
|
@uri.to_s.inspect
|
|
71
81
|
end
|
|
72
82
|
|
|
73
83
|
# Convert it to an object of class +URI+.
|
|
84
|
+
#
|
|
85
|
+
# @return [String] New URI
|
|
74
86
|
def to_uri
|
|
75
87
|
the_uri.clone
|
|
76
88
|
end
|
|
77
89
|
|
|
90
|
+
# Removes the host, the port, and the scheme and returns
|
|
91
|
+
# only the local address, for example, converting "https://google.com/foo"
|
|
92
|
+
# into "/foo".
|
|
93
|
+
#
|
|
94
|
+
# @return [String] Local part of the URI
|
|
95
|
+
def to_local
|
|
96
|
+
u = the_uri
|
|
97
|
+
[
|
|
98
|
+
u.path,
|
|
99
|
+
u.query ? "?#{u.query}" : '',
|
|
100
|
+
u.fragment ? "##{u.fragment}" : ''
|
|
101
|
+
].join
|
|
102
|
+
end
|
|
103
|
+
|
|
78
104
|
# Add a few query arguments.
|
|
79
105
|
#
|
|
80
106
|
# For example:
|
|
@@ -87,7 +113,10 @@ class Iri
|
|
|
87
113
|
#
|
|
88
114
|
# Iri.new('https://google.com').del(:q).add(q: 'test')
|
|
89
115
|
#
|
|
116
|
+
# @param [Hash] hash Hash of names/values to set into the query part
|
|
117
|
+
# @return [Iri] A new iri
|
|
90
118
|
def add(hash)
|
|
119
|
+
raise InvalidArguments unless hash.is_a?(Hash)
|
|
91
120
|
modify_query do |params|
|
|
92
121
|
hash.each do |k, v|
|
|
93
122
|
params[k.to_s] = [] unless params[k.to_s]
|
|
@@ -102,6 +131,8 @@ class Iri
|
|
|
102
131
|
#
|
|
103
132
|
# Iri.new('https://google.com?q=test').del(:q)
|
|
104
133
|
#
|
|
134
|
+
# @param [Array] keys List of keys to delete
|
|
135
|
+
# @return [Iri] A new iri
|
|
105
136
|
def del(*keys)
|
|
106
137
|
modify_query do |params|
|
|
107
138
|
keys.each do |k|
|
|
@@ -114,7 +145,10 @@ class Iri
|
|
|
114
145
|
#
|
|
115
146
|
# Iri.new('https://google.com?q=test').over(q: 'hey you!')
|
|
116
147
|
#
|
|
148
|
+
# @param [Hash] hash Hash of names/values to set into the query part
|
|
149
|
+
# @return [Iri] A new iri
|
|
117
150
|
def over(hash)
|
|
151
|
+
raise InvalidArguments unless hash.is_a?(Hash)
|
|
118
152
|
modify_query do |params|
|
|
119
153
|
hash.each do |k, v|
|
|
120
154
|
params[k.to_s] = [] unless params[k]
|
|
@@ -124,6 +158,9 @@ class Iri
|
|
|
124
158
|
end
|
|
125
159
|
|
|
126
160
|
# Replace the scheme.
|
|
161
|
+
#
|
|
162
|
+
# @param [String] val New scheme to set, like "https" or "http"
|
|
163
|
+
# @return [Iri] A new iri
|
|
127
164
|
def scheme(val)
|
|
128
165
|
modify do |c|
|
|
129
166
|
c.scheme = val
|
|
@@ -131,6 +168,9 @@ class Iri
|
|
|
131
168
|
end
|
|
132
169
|
|
|
133
170
|
# Replace the host.
|
|
171
|
+
#
|
|
172
|
+
# @param [String] val New host to set, like "google.com" or "192.168.0.1"
|
|
173
|
+
# @return [Iri] A new iri
|
|
134
174
|
def host(val)
|
|
135
175
|
modify do |c|
|
|
136
176
|
c.host = val
|
|
@@ -138,6 +178,9 @@ class Iri
|
|
|
138
178
|
end
|
|
139
179
|
|
|
140
180
|
# Replace the port.
|
|
181
|
+
#
|
|
182
|
+
# @param [String] val New TCP port to set, like "8080" or "443"
|
|
183
|
+
# @return [Iri] A new iri
|
|
141
184
|
def port(val)
|
|
142
185
|
modify do |c|
|
|
143
186
|
c.port = val
|
|
@@ -145,6 +188,9 @@ class Iri
|
|
|
145
188
|
end
|
|
146
189
|
|
|
147
190
|
# Replace the path part of the URI.
|
|
191
|
+
#
|
|
192
|
+
# @param [String] val New path to set, like "/foo/bar"
|
|
193
|
+
# @return [Iri] A new iri
|
|
148
194
|
def path(val)
|
|
149
195
|
modify do |c|
|
|
150
196
|
c.path = val
|
|
@@ -152,6 +198,9 @@ class Iri
|
|
|
152
198
|
end
|
|
153
199
|
|
|
154
200
|
# Replace the fragment part of the URI.
|
|
201
|
+
#
|
|
202
|
+
# @param [String] val New fragment to set, like "hello"
|
|
203
|
+
# @return [Iri] A new iri
|
|
155
204
|
def fragment(val)
|
|
156
205
|
modify do |c|
|
|
157
206
|
c.fragment = val.to_s
|
|
@@ -159,6 +208,9 @@ class Iri
|
|
|
159
208
|
end
|
|
160
209
|
|
|
161
210
|
# Replace the query part of the URI.
|
|
211
|
+
#
|
|
212
|
+
# @param [String] val New query to set, like "a=1&b=2"
|
|
213
|
+
# @return [Iri] A new iri
|
|
162
214
|
def query(val)
|
|
163
215
|
modify do |c|
|
|
164
216
|
c.query = val
|
|
@@ -172,6 +224,9 @@ class Iri
|
|
|
172
224
|
# Iri.new('https://google.com/a/b?q=test').cut('/hello')
|
|
173
225
|
#
|
|
174
226
|
# The result will contain "https://google.com/hello".
|
|
227
|
+
#
|
|
228
|
+
# @param [String] path New path to set, like "/foo"
|
|
229
|
+
# @return [Iri] A new iri
|
|
175
230
|
def cut(path = '/')
|
|
176
231
|
modify do |c|
|
|
177
232
|
c.query = nil
|
|
@@ -187,6 +242,9 @@ class Iri
|
|
|
187
242
|
# Iri.new('https://google.com/a/b?q=test').append('/hello')
|
|
188
243
|
#
|
|
189
244
|
# The result will contain "https://google.com/a/b/hello?q=test".
|
|
245
|
+
#
|
|
246
|
+
# @param [String] part New segment to add to existing path
|
|
247
|
+
# @return [Iri] A new iri
|
|
190
248
|
def append(part)
|
|
191
249
|
modify do |c|
|
|
192
250
|
tail = (c.path.end_with?('/') ? '' : '/') + CGI.escape(part.to_s)
|
data/logo.svg
CHANGED
data/test/test__helper.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Copyright (c) 2019-
|
|
3
|
+
# Copyright (c) 2019-2025 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-
|
|
5
|
+
# Copyright (c) 2019-2025 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-
|
|
30
|
+
# Copyright:: Copyright (c) 2019-2025 Yegor Bugayenko
|
|
31
31
|
# License:: MIT
|
|
32
32
|
class IriTest < Minitest::Test
|
|
33
33
|
def test_builds_uri
|
|
@@ -43,12 +43,42 @@ class IriTest < Minitest::Test
|
|
|
43
43
|
assert_equal('https://localhost:443/?q=books+about+tennis&limit=10', url)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
+
def test_converts_to_uri
|
|
47
|
+
assert_equal(
|
|
48
|
+
'https://alpha.local?t=1',
|
|
49
|
+
Iri.new('https://alpha.local').over(t: 1).to_uri.to_s
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_converts_to_local
|
|
54
|
+
{
|
|
55
|
+
'http://localhost:9292/' => '/',
|
|
56
|
+
'https://google.com/' => '/',
|
|
57
|
+
'https://google.com/foo' => '/foo',
|
|
58
|
+
'https://google.com/bar?x=900' => '/bar?x=900',
|
|
59
|
+
'https://google.com/what#yes' => '/what#yes',
|
|
60
|
+
'https://google.com/what?a=8&b=9#yes' => '/what?a=8&b=9#yes'
|
|
61
|
+
}.each { |a, b| assert_equal(b, Iri.new(a).to_local) }
|
|
62
|
+
end
|
|
63
|
+
|
|
46
64
|
def test_broken_uri
|
|
47
65
|
assert_raises Iri::InvalidURI do
|
|
48
66
|
Iri.new('https://example.com/>', safe: false).add(a: 1)
|
|
49
67
|
end
|
|
50
68
|
end
|
|
51
69
|
|
|
70
|
+
def test_incorrect_call_of_add
|
|
71
|
+
assert_raises Iri::InvalidArguments do
|
|
72
|
+
Iri.new('https://example.com/').add('hello5')
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def test_incorrect_call_of_over
|
|
77
|
+
assert_raises Iri::InvalidArguments do
|
|
78
|
+
Iri.new('https://example5.com/').over('boom44')
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
52
82
|
def test_broken_uri_in_safe_mode
|
|
53
83
|
Iri.new('https://example.com/>>>').add(a: 1)
|
|
54
84
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iri
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Class Iri helps you build a URI and then modify its parts via a simple
|
|
14
14
|
immutable fluent interface. It always returns a new object instead of changing the
|
|
@@ -21,13 +21,20 @@ extra_rdoc_files:
|
|
|
21
21
|
files:
|
|
22
22
|
- ".0pdd.yml"
|
|
23
23
|
- ".gitattributes"
|
|
24
|
+
- ".github/workflows/actionlint.yml"
|
|
24
25
|
- ".github/workflows/codecov.yml"
|
|
26
|
+
- ".github/workflows/copyrights.yml"
|
|
27
|
+
- ".github/workflows/markdown-lint.yml"
|
|
28
|
+
- ".github/workflows/pdd.yml"
|
|
25
29
|
- ".github/workflows/rake.yml"
|
|
30
|
+
- ".github/workflows/xcop.yml"
|
|
31
|
+
- ".github/workflows/yamllint.yml"
|
|
26
32
|
- ".gitignore"
|
|
27
33
|
- ".pdd"
|
|
28
34
|
- ".rubocop.yml"
|
|
29
35
|
- ".rultor.yml"
|
|
30
36
|
- Gemfile
|
|
37
|
+
- Gemfile.lock
|
|
31
38
|
- LICENSE.txt
|
|
32
39
|
- README.md
|
|
33
40
|
- Rakefile
|
|
@@ -42,7 +49,7 @@ licenses:
|
|
|
42
49
|
- MIT
|
|
43
50
|
metadata:
|
|
44
51
|
rubygems_mfa_required: 'true'
|
|
45
|
-
post_install_message:
|
|
52
|
+
post_install_message:
|
|
46
53
|
rdoc_options:
|
|
47
54
|
- "--charset=UTF-8"
|
|
48
55
|
require_paths:
|
|
@@ -58,8 +65,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
58
65
|
- !ruby/object:Gem::Version
|
|
59
66
|
version: '0'
|
|
60
67
|
requirements: []
|
|
61
|
-
rubygems_version: 3.
|
|
62
|
-
signing_key:
|
|
68
|
+
rubygems_version: 3.4.10
|
|
69
|
+
signing_key:
|
|
63
70
|
specification_version: 4
|
|
64
71
|
summary: Simple Immutable Ruby URI Builder
|
|
65
72
|
test_files: []
|