iri 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rultor.yml +7 -9
- data/.travis.yml +1 -1
- data/LICENSE.txt +21 -0
- data/README.md +12 -6
- data/iri.gemspec +1 -1
- data/lib/iri.rb +2 -1
- data/test/test_iri.rb +11 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 868c45e578542b837497a14f57e1c158be827ced06a7aad6be1bb8ac21d166f5
|
4
|
+
data.tar.gz: f6235d5ddca9789a0161cad29d23ff435f05461855a0fa38b0cd81db2c8d0687
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a5ccbeedf58b255986664220256354e71903a65d7fe381bfd4ff097fea88de1ae813fb1693e9115c88358822bf861ff6efe938e58b0b76a60f563abd1ffef86
|
7
|
+
data.tar.gz: 21df9fcf433747a5fbccd0319fb8974a650d277e7164884f315301dfbe30fd0c1d192fc3ce4614a58f8dfb8678e4e7767819e5cee384d16a30a49113a93821b7
|
data/.rultor.yml
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
assets:
|
2
|
-
rubygems.yml:
|
2
|
+
rubygems.yml: yegor256/home#assets/rubygems.yml
|
3
3
|
install: |-
|
4
4
|
export GEM_HOME=~/.ruby
|
5
5
|
export GEM_PATH=$GEM_HOME:$GEM_PATH
|
6
|
+
bundle install
|
6
7
|
release:
|
7
8
|
script: |-
|
8
|
-
bundle install
|
9
9
|
bundle exec rake
|
10
10
|
rm -rf *.gem
|
11
11
|
sed -i "s/0\.0\.0/${tag}/g" iri.gemspec
|
@@ -14,13 +14,11 @@ release:
|
|
14
14
|
gem build iri.gemspec
|
15
15
|
chmod 0600 ../rubygems.yml
|
16
16
|
gem push *.gem --config-file ../rubygems.yml
|
17
|
-
commanders:
|
18
|
-
- yegor256
|
19
|
-
architect:
|
20
|
-
- yegor256
|
21
17
|
merge:
|
22
|
-
commanders: []
|
23
18
|
script: |-
|
24
|
-
bundle install
|
25
19
|
bundle exec rake
|
26
|
-
deploy:
|
20
|
+
deploy:
|
21
|
+
script: |-
|
22
|
+
echo Nothing to deploy
|
23
|
+
exit 1
|
24
|
+
|
data/.travis.yml
CHANGED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 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
|
13
|
+
in all 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 NON-INFRINGEMENT. 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.
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
<img src="/logo.svg" width="64px" height="64px"/>
|
2
2
|
|
3
|
-
[![EO principles respected here](
|
3
|
+
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
|
4
4
|
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/iri)](http://www.rultor.com/p/yegor256/iri)
|
5
|
-
[![We recommend RubyMine](
|
5
|
+
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
6
6
|
|
7
7
|
[![Build Status](https://travis-ci.org/yegor256/iri.svg)](https://travis-ci.org/yegor256/iri)
|
8
8
|
[![Build status](https://ci.appveyor.com/api/projects/status/5hj65olpn2tds4al?svg=true)](https://ci.appveyor.com/project/yegor256/iri)
|
@@ -10,11 +10,13 @@
|
|
10
10
|
[![Maintainability](https://api.codeclimate.com/v1/badges/7018d2fe438103828685/maintainability)](https://codeclimate.com/github/yegor256/iri/maintainability)
|
11
11
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/iri/master/frames)
|
12
12
|
|
13
|
+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/iri/blob/master/LICENSE.txt)
|
13
14
|
[![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/iri.svg)](https://codecov.io/github/yegor256/iri?branch=master)
|
14
15
|
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/iri)](https://hitsofcode.com/view/github/yegor256/iri)
|
15
16
|
|
16
|
-
|
17
|
-
|
17
|
+
The class [`Iri`](https://www.rubydoc.info/github/yegor256/iri/master/Iri)
|
18
|
+
helps you build a URI and then modify its
|
19
|
+
parts via a simple [fluent interface](https://en.wikipedia.org/wiki/Fluent_interface):
|
18
20
|
|
19
21
|
```ruby
|
20
22
|
require 'iri'
|
@@ -45,7 +47,9 @@ gem 'iri'
|
|
45
47
|
```
|
46
48
|
|
47
49
|
Pay attention, it is not a parser. The only functionality this gem provides
|
48
|
-
is _building_ URIs.
|
50
|
+
is _building_ URIs.
|
51
|
+
|
52
|
+
It is very convenient to use inside
|
49
53
|
[HAML](http://haml.info/tutorial.html), for example:
|
50
54
|
|
51
55
|
```haml
|
@@ -54,7 +58,9 @@ is _building_ URIs. It is very convenient to use inside
|
|
54
58
|
%a{href: iri.over(offset: offset - 10)} Previous Page
|
55
59
|
```
|
56
60
|
|
57
|
-
|
61
|
+
Of course, it's better to create the `iri` object only once per request
|
62
|
+
and re-use it where you need. It's _immutable_, so you won't have any
|
63
|
+
side-effects.
|
58
64
|
|
59
65
|
PS. See how I use it in this Sinatra web app: [yegor256/0rsk](https://github.com/yegor256/0rsk).
|
60
66
|
|
data/iri.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
|
|
31
31
|
s.rubygems_version = '2.5'
|
32
32
|
s.required_ruby_version = '>=2.2'
|
33
33
|
s.name = 'iri'
|
34
|
-
s.version = '0.4.
|
34
|
+
s.version = '0.4.3'
|
35
35
|
s.license = 'MIT'
|
36
36
|
s.summary = 'Simple Immutable Ruby URI Builder'
|
37
37
|
s.description = 'Class Iri helps you build a URI and then modify its \
|
data/lib/iri.rb
CHANGED
@@ -168,7 +168,8 @@ class Iri
|
|
168
168
|
# The result will contain "https://google.com/a/b/hello?q=test".
|
169
169
|
def append(part)
|
170
170
|
modify do |c|
|
171
|
-
|
171
|
+
tail = (c.path.end_with?('/') ? '' : '/') + CGI.escape(part.to_s)
|
172
|
+
c.path = c.path + tail
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
data/test/test_iri.rb
CHANGED
@@ -128,6 +128,17 @@ class IriTest < Minitest::Test
|
|
128
128
|
)
|
129
129
|
end
|
130
130
|
|
131
|
+
def test_appends_empty_path
|
132
|
+
assert_equal(
|
133
|
+
'http://google.com/hello/',
|
134
|
+
Iri.new('http://google.com/hello').append('').append('').to_s
|
135
|
+
)
|
136
|
+
assert_equal(
|
137
|
+
'http://google.com/test',
|
138
|
+
Iri.new('http://google.com/hello').cut.append('test').to_s
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
131
142
|
def test_replaces_query_param
|
132
143
|
assert_equal(
|
133
144
|
'http://google/?a=hey&b=2&c=3',
|
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.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -110,6 +110,7 @@ files:
|
|
110
110
|
- ".rultor.yml"
|
111
111
|
- ".travis.yml"
|
112
112
|
- Gemfile
|
113
|
+
- LICENSE.txt
|
113
114
|
- README.md
|
114
115
|
- Rakefile
|
115
116
|
- appveyor.yml
|