local_uri 1.1.1 → 1.2.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/README.md +14 -2
- data/lib/local_uri/query.rb +16 -4
- data/lib/local_uri/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a33a185234fc98f5a5e888352bb8f4dca2fcf4aa095135ed33b705104cb4c04
|
4
|
+
data.tar.gz: d1c8f14f22ffddbe4112bf3dbf76d85897a0ccaffe80f0c1efb1dfe97bdb7392
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
|
data/lib/local_uri/query.rb
CHANGED
@@ -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(
|
36
|
-
query_string = Rack::Utils.build_nested_query(
|
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
|
data/lib/local_uri/version.rb
CHANGED
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.
|
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:
|
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.
|
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.
|