local_uri 1.1.1 → 1.2.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: 817a0d947dc2eca80eb0688d5cd777d5bbfa9c679fbfd8accbc402650ec4bfe1
4
- data.tar.gz: c68eb509ec868040808cce7e0523537487c07462bf4159daa7b4b88225a6d818
3
+ metadata.gz: 5a33a185234fc98f5a5e888352bb8f4dca2fcf4aa095135ed33b705104cb4c04
4
+ data.tar.gz: d1c8f14f22ffddbe4112bf3dbf76d85897a0ccaffe80f0c1efb1dfe97bdb7392
5
5
  SHA512:
6
- metadata.gz: 6d5fbee11f7c9ba22b253c4f73572981c8bc9b56377907ce1d8a27f5fe02949ac4a59f795d60e9341d8567c5591dd8e21dccd0dd8bd69be757cd3d4a61fb1431
7
- data.tar.gz: 45ffb979ebf5786cac6820d62d63b2f3fab366cc0289b86ff72da68db68b0e60d599429843f5ae1c83ba817285f4d0a9ef453d38b31f50672fe41698fc95f5d1
6
+ metadata.gz: d0a38930c7756fdf5237168492dc2435d382e4bc6d9f39508e2a0575444fff3aeecc60b9af10ac82d945b2bf4a61c8160a7f05121aafbffe89e5069623447066
7
+ data.tar.gz: 20513b9450a28f4fb1fdf8a722d0a3bf7a728557ddf2d6816c16916a970ebea86ab81e0c702d88274cf110c4c86d2b815b80295a53e8128bdb412b06cd3fbd7d
data/README.md CHANGED
@@ -71,6 +71,18 @@ uri.query.merge(booking: { people: 2 }).to_s # https://booking-widget.local.ch/e
71
71
  ```ruby
72
72
 
73
73
  uri = URI('https://local.ch?id=1&place[name]=casa')
74
- uri[:id] # '1'
75
- uri.dig(:place, :name) # 'casa'
74
+ uri.query[:id] # '1'
75
+ uri.query.dig(:place, :name) # 'casa'
76
76
  ```
77
+
78
+ #### Remove parts of a query
79
+
80
+ ```ruby
81
+ uri = URI('https://local.ch?one=1&two=2&three=3')
82
+ uri.query.except(:two, :three).to_s # https://local.ch?one=1
83
+ ```
84
+
85
+ `except(keys)` - Returns a uri which query includes everything except given keys.
86
+
87
+ `except!(keys)` - Removes the given keys from the query of the original uri and returns the uri itself.
88
+
@@ -16,13 +16,25 @@ module LocalUri
16
16
 
17
17
  def merge(*args, &block)
18
18
  @uri.dup.tap do |uri|
19
- uri.query_string = build_query_string(*args, &block)
19
+ uri.query_string = build_query_string(parsed_query.merge(*args, &block))
20
20
  end
21
21
  end
22
22
 
23
23
  def merge!(*args, &block)
24
24
  @uri.tap do |uri|
25
- uri.query_string = build_query_string(*args, &block)
25
+ uri.query_string = build_query_string(parsed_query.merge(*args, &block))
26
+ end
27
+ end
28
+
29
+ def except(*args, &block)
30
+ @uri.dup.tap do |uri|
31
+ uri.query_string = build_query_string(parsed_query.except(*args, &block))
32
+ end
33
+ end
34
+
35
+ def except!(*args, &block)
36
+ @uri.tap do |uri|
37
+ uri.query_string = build_query_string(parsed_query.except(*args, &block))
26
38
  end
27
39
  end
28
40
 
@@ -32,8 +44,8 @@ module LocalUri
32
44
  Rack::Utils.parse_nested_query(@uri.query_string).with_indifferent_access
33
45
  end
34
46
 
35
- def build_query_string(*args, &block)
36
- query_string = Rack::Utils.build_nested_query(parsed_query.merge(*args, &block))
47
+ def build_query_string(query)
48
+ query_string = Rack::Utils.build_nested_query(query)
37
49
  query_string.empty? ? nil : query_string
38
50
  end
39
51
  end
@@ -1,3 +1,3 @@
1
1
  module LocalUri
2
- VERSION = '1.1.1'.freeze
2
+ VERSION = '1.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: local_uri
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/local_uri/graphs/contributors
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-25 00:00:00.000000000 Z
11
+ date: 2020-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -138,7 +138,7 @@ files:
138
138
  homepage: https://github.com/local-ch/local_uri
139
139
  licenses: []
140
140
  metadata: {}
141
- post_install_message:
141
+ post_install_message:
142
142
  rdoc_options: []
143
143
  require_paths:
144
144
  - lib
@@ -153,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
153
153
  - !ruby/object:Gem::Version
154
154
  version: '0'
155
155
  requirements: []
156
- rubygems_version: 3.0.3
157
- signing_key:
156
+ rubygems_version: 3.0.6
157
+ signing_key:
158
158
  specification_version: 4
159
159
  summary: Useful and slight extension to Ruby's URI (Uniform Resource Identifiers)
160
160
  core module.