furi 0.2.3 → 0.2.5
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/CHANGELOG.md +24 -0
- data/README.md +14 -0
- data/lib/furi/uri.rb +13 -4
- data/lib/furi/utils.rb +11 -1
- data/lib/furi/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60584a8bc9851e0f203430c73a18b5b4c4d22c25484134caf8f256279203ed7e
|
4
|
+
data.tar.gz: ee1258bc6788c8d11bf8f5c7a48dced7c5338ad36409de0a3eb049c194cd3347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 161c291815412a22f32a2c6e6e8b32fc74241eba6e44442197f1a04d2c934522898014e8e7c6b0cc53c396f0a95076a193e23dd41a8abf38ea0b976058b76d00
|
7
|
+
data.tar.gz: ac25ee7829104064cde493e5310a7302d08593808f56674bc4cce7af4e1d6e5be3504300cd396d79276abe5a6153be52084613af8a7679d30fbc1afa2f007912
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,27 @@
|
|
1
|
+
# v0.2.4
|
2
|
+
|
3
|
+
* Improved `Furi.update` behavior for `path:` overrides:
|
4
|
+
|
5
|
+
* Supports **relative path resolution** (`..` and subpaths)
|
6
|
+
* Leading slashes in `path` now **replace** the original path
|
7
|
+
* `nil` path removes the path portion entirely, leaving only the host
|
8
|
+
|
9
|
+
**Examples:**
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
Furi.update("https://www.google.com/maps", path: "place/1.23,3.28")
|
13
|
+
# => "https://www.google.com/maps/place/1.23,3.28"
|
14
|
+
|
15
|
+
Furi.update("https://www.google.com/maps", path: "/account")
|
16
|
+
# => "https://www.google.com/account"
|
17
|
+
|
18
|
+
Furi.update("https://www.google.com/maps", path: "..")
|
19
|
+
# => "https://www.google.com/"
|
20
|
+
|
21
|
+
Furi.update("https://www.google.com/maps", path: nil)
|
22
|
+
# => "https://www.google.com"
|
23
|
+
```
|
24
|
+
|
1
25
|
# v0.2.3
|
2
26
|
|
3
27
|
* Ruby 3.0 support #2
|
data/README.md
CHANGED
@@ -58,6 +58,20 @@ Building an URI from initial parts:
|
|
58
58
|
``` ruby
|
59
59
|
Furi.build(protocol: '//', host: 'gusiev.com', path: '/assets/application.js')
|
60
60
|
# => "//gusiev.com/assets/application.js"
|
61
|
+
|
62
|
+
Furi.build(
|
63
|
+
location: 'https://calendar.google.com',
|
64
|
+
path: '/calendar/render',
|
65
|
+
query: {
|
66
|
+
action: 'TEMPLATE',
|
67
|
+
text: 'Seven Figure Club Meeting',
|
68
|
+
dates: [Time.now + 2.hours, Time.now + 3.hours].map do |t|
|
69
|
+
t.strftime("%Y%m%dT%H%M%SZ")
|
70
|
+
end.join('/'),
|
71
|
+
details: 'Seven Figure Club invites to the discussion with other founders to one of the topics you have expressed your interest to.',
|
72
|
+
add: ["bogdan@example.com", "brad@example.com"].join(',')
|
73
|
+
}
|
74
|
+
)
|
61
75
|
```
|
62
76
|
|
63
77
|
### Working with Object
|
data/lib/furi/uri.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
1
3
|
module Furi
|
2
4
|
class Uri
|
3
5
|
|
@@ -44,6 +46,12 @@ module Furi
|
|
44
46
|
case part.to_sym
|
45
47
|
when :query, :query_tokens, :query_string
|
46
48
|
merge_query(value)
|
49
|
+
when :path
|
50
|
+
if value && self[part]
|
51
|
+
self[part] = Pathname.new(self[part]).join(value).to_s
|
52
|
+
else
|
53
|
+
self[part] = value
|
54
|
+
end
|
47
55
|
else
|
48
56
|
self[part] = value
|
49
57
|
end
|
@@ -72,7 +80,10 @@ module Furi
|
|
72
80
|
def merge_query(query)
|
73
81
|
case query
|
74
82
|
when Hash
|
75
|
-
self.query =
|
83
|
+
self.query = Furi::Utils.deep_merge(
|
84
|
+
self.query,
|
85
|
+
Furi::Utils.stringify_keys(query)
|
86
|
+
)
|
76
87
|
when String, Array
|
77
88
|
self.query_tokens += Furi.query_tokens(query)
|
78
89
|
when nil
|
@@ -238,10 +249,8 @@ module Furi
|
|
238
249
|
query
|
239
250
|
when String, Array
|
240
251
|
self.query_tokens = value
|
241
|
-
@query = nil
|
242
252
|
when Hash
|
243
253
|
self.query_tokens = value
|
244
|
-
@query = value
|
245
254
|
when nil
|
246
255
|
else
|
247
256
|
raise QueryParseError, 'Query can only be Hash or String'
|
@@ -273,7 +282,7 @@ module Furi
|
|
273
282
|
end
|
274
283
|
|
275
284
|
def query_tokens=(tokens)
|
276
|
-
@query = nil
|
285
|
+
@query = tokens.is_a?(Hash) ? tokens : nil
|
277
286
|
@query_tokens = Furi.query_tokens(tokens)
|
278
287
|
end
|
279
288
|
|
data/lib/furi/utils.rb
CHANGED
@@ -10,7 +10,17 @@ module Furi
|
|
10
10
|
end
|
11
11
|
result
|
12
12
|
end
|
13
|
+
|
14
|
+
def deep_merge(current_hash, other_hash)
|
15
|
+
current_hash.merge(other_hash) do |key, this_val, other_val|
|
16
|
+
if this_val.is_a?(Hash) && other_val.is_a?(Hash)
|
17
|
+
deep_merge(this_val, other_val)
|
18
|
+
else
|
19
|
+
other_val
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
13
23
|
end
|
14
24
|
end
|
15
25
|
end
|
16
|
-
|
26
|
+
|
data/lib/furi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bogdan Gusiev
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: The philosophy of this gem is to make any URI modification or parsing
|
14
13
|
operation to take only one line of code and never more
|
@@ -39,7 +38,6 @@ metadata:
|
|
39
38
|
allowed_push_host: https://rubygems.org
|
40
39
|
homepage_uri: https://github.com/bogdan/furi
|
41
40
|
source_code_uri: https://github.com/bogdan/furi
|
42
|
-
post_install_message:
|
43
41
|
rdoc_options: []
|
44
42
|
require_paths:
|
45
43
|
- lib
|
@@ -54,8 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
52
|
- !ruby/object:Gem::Version
|
55
53
|
version: '0'
|
56
54
|
requirements: []
|
57
|
-
rubygems_version: 3.
|
58
|
-
signing_key:
|
55
|
+
rubygems_version: 3.6.7
|
59
56
|
specification_version: 4
|
60
57
|
summary: Make URI processing as easy as it should be
|
61
58
|
test_files: []
|