iri 0.3.0 → 0.4.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: 8673c781f1957a3ae681e9b324fb65331b0d2fd3790256f02b7ca63ca97e543e
4
- data.tar.gz: c32ca8b48268204469d8a8aa870aa73c7cbae81e74f767863e34f6547dab60ec
3
+ metadata.gz: 507a30295665ced7270e86cb999cd72423fb47d9c16c96d27c18bb1ab5a16e79
4
+ data.tar.gz: cc1a925c9d497989e0d5ddfc8710969b0908931a6c8c4412acbe8037c13433e1
5
5
  SHA512:
6
- metadata.gz: 74d0e96a473993791365dbd5e35239effab3d13cb8b0d51ed395a5475d040c1a5fc980ae1900e4c8f8218fc3fd4b712d6f7e8b38fa67af1590d713f0db061e98
7
- data.tar.gz: 8d761157337ea934988ca0ceca6478381c6d3c57c475c73940809a9def8ce0be7210fb2af049d9ded1e6977db846856be52747573ecb782d1519afcbe9c6ef82
6
+ metadata.gz: 175f87bb42e6d6900d6d60013f3793b00f747905edd64b9d42b1c95887e13b5cb7996a7448075d324df098c62070427d7f496b172a4080feea50f923b4a39487
7
+ data.tar.gz: 104e8a187054002113e61a52f248128e6df6ce6c48da15599d2a0e03d0decc7c51060add60347a4bd1f4a0be2375888a516cd2ac41a4112a8200604a410e488d
@@ -1,12 +1,15 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.6.0
4
+ cache: bundler
4
5
  branches:
5
6
  only:
6
7
  - master
7
8
  install:
8
- - bundle install
9
+ - travis_retry bundle update
10
+ - gem install pdd
9
11
  script:
10
- - set -e
11
- - rake
12
-
12
+ - pdd -f /dev/null
13
+ - bundle exec rake
14
+ after_success:
15
+ - "bash <(curl -s https://codecov.io/bash)"
data/README.md CHANGED
@@ -8,13 +8,17 @@
8
8
  [![Maintainability](https://api.codeclimate.com/v1/badges/7018d2fe438103828685/maintainability)](https://codeclimate.com/github/yegor256/iri/maintainability)
9
9
  [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/iri/master/frames)
10
10
 
11
+ [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/iri.svg)](https://codecov.io/github/yegor256/iri?branch=master)
12
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/iri)](https://hitsofcode.com/view/github/yegor256/iri)
13
+
11
14
  Class `Iri` helps you build a URI and then modify its
12
15
  parts via a simple fluent interface:
13
16
 
14
17
  ```ruby
15
18
  require 'iri'
16
19
  url = Iri.new('http://google.com/')
17
- .add(q: 'books about OOP', limit: 50)
20
+ .append('find').append('me') # -> http://google.com/find/me
21
+ .add(q: 'books about OOP', limit: 50) # -> ?q=books+about+OOP&limit=50
18
22
  .del(:q) # remove this query parameter
19
23
  .del('limit') # remove this one too
20
24
  .over(q: 'books about tennis', limit: 10) # replace these params
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.5'
32
32
  s.required_ruby_version = '>=2.5'
33
33
  s.name = 'iri'
34
- s.version = '0.3.0'
34
+ s.version = '0.4.0'
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
@@ -161,6 +161,17 @@ class Iri
161
161
  end
162
162
  end
163
163
 
164
+ # Append something new to the path:
165
+ #
166
+ # Iri.new('https://google.com/a/b?q=test').append('/hello')
167
+ #
168
+ # The result will contain "https://google.com/a/b/hello?q=test".
169
+ def append(part)
170
+ modify do |c|
171
+ c.path = c.path + '/' + CGI.escape(part)
172
+ end
173
+ end
174
+
164
175
  private
165
176
 
166
177
  def modify
@@ -117,6 +117,13 @@ class IriTest < Minitest::Test
117
117
  )
118
118
  end
119
119
 
120
+ def test_appends_path
121
+ assert_equal(
122
+ 'http://google/a/b/z+%2F+7?x=3',
123
+ Iri.new('http://google/a/b?x=3').append('z / 7').to_s
124
+ )
125
+ end
126
+
120
127
  def test_replaces_query_param
121
128
  assert_equal(
122
129
  '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.3.0
4
+ version: 0.4.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: 2019-04-21 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest