furi 0.2.5 → 0.2.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60584a8bc9851e0f203430c73a18b5b4c4d22c25484134caf8f256279203ed7e
4
- data.tar.gz: ee1258bc6788c8d11bf8f5c7a48dced7c5338ad36409de0a3eb049c194cd3347
3
+ metadata.gz: 5923ee7cbb73b1b035612324a274790d95ec2cef4369558fc6874e28da4fe77b
4
+ data.tar.gz: bebdc6c2ab8ae6b5a8cc262c2c70d53a8d1721020fcd7581a713f9f2f629b010
5
5
  SHA512:
6
- metadata.gz: 161c291815412a22f32a2c6e6e8b32fc74241eba6e44442197f1a04d2c934522898014e8e7c6b0cc53c396f0a95076a193e23dd41a8abf38ea0b976058b76d00
7
- data.tar.gz: ac25ee7829104064cde493e5310a7302d08593808f56674bc4cce7af4e1d6e5be3504300cd396d79276abe5a6153be52084613af8a7679d30fbc1afa2f007912
6
+ metadata.gz: 9b9a3c1d0116faa7828205294fc22b6eb2045536ffdd3c3665d7d8ea8dc4de3ac88bd43904f82c9c33948e943c073e9c0a44dc5a6c6a80e4b30252fd690b49f4
7
+ data.tar.gz: 5ef899e9301205592801d7f037d7193d4f1f13c057198fa3eff06e559e86bcdb8b209df0e77e24aad04f8d555ff4aaf443e8373adc3f79dc17360c24e330787a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ # v0.2.7
2
+
3
+ * Add `origin` part (location + path, without query string and anchor)
4
+
5
+ ```ruby
6
+ Furi.parse("http://gusiev.com/articles/index.html?a=1#top").origin
7
+ # => "http://gusiev.com/articles/index.html"
8
+
9
+ Furi.replace("http://gusiev.com/index.html?a=1#top", origin: "http://gusiev.com/blog.html")
10
+ # => "http://gusiev.com/blog.html?a=1#top"
11
+ ```
12
+
13
+ # v0.2.6
14
+
15
+ * Support `filename` part replacement and extraction
16
+
17
+ # v0.2.5
18
+
19
+ * Fix replacement of path starting with `/`
20
+
1
21
  # v0.2.4
2
22
 
3
23
  * Improved `Furi.update` behavior for `path:` overrides:
data/Gemfile CHANGED
@@ -5,7 +5,6 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in furi.gemspec
6
6
  gemspec
7
7
 
8
- gem "pry-byebug", "~> 3.9"
9
8
  gem "rake", "~> 13.0"
10
9
  gem "rspec", "~> 3.10"
11
10
  gem "bump"
data/lib/furi/uri.rb CHANGED
@@ -207,6 +207,18 @@ module Furi
207
207
  end
208
208
  end
209
209
 
210
+ def origin
211
+ [location, path].join
212
+ end
213
+
214
+ def origin=(string)
215
+ string ||= ""
216
+ string = parse_protocol(string)
217
+ authority, path = string.split("/", 2)
218
+ self.authority = authority
219
+ self.path = path ? "/#{path}" : nil
220
+ end
221
+
210
222
  def location=(string)
211
223
  string ||= ""
212
224
  string = string.gsub(%r(/\Z), '')
@@ -327,9 +339,21 @@ module Furi
327
339
  self.path = string + file.to_s
328
340
  end
329
341
 
342
+ def filename
343
+ return nil unless file
344
+ file_tokens.first
345
+ end
346
+
347
+ def filename=(value)
348
+ t = file_tokens
349
+ t[0] = value
350
+ self.file = t.join(".")
351
+ end
352
+
330
353
  def extension
331
354
  return nil unless file
332
- file_tokens.size > 1 ? file_tokens.last : nil
355
+ tokens = file_tokens[1..-1]
356
+ tokens.any? ? tokens.join(".") : nil
333
357
  end
334
358
 
335
359
  def extension=(string)
@@ -341,7 +365,7 @@ module Furi
341
365
  tokens.push(string)
342
366
  else
343
367
  if string
344
- tokens[-1] = string
368
+ tokens = [tokens.first, string]
345
369
  else
346
370
  tokens.pop
347
371
  end
data/lib/furi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Furi
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.7"
3
3
  end
data/lib/furi.rb CHANGED
@@ -9,13 +9,16 @@ module Furi
9
9
 
10
10
  ESSENTIAL_PARTS = [
11
11
  :anchor, :protocol, :query_tokens,
12
- :path, :host, :port, :username, :password
12
+ :path, :host, :port, :username, :password,
13
+ :filename,
13
14
  ]
15
+
14
16
  COMBINED_PARTS = [
15
17
  :hostinfo, :userinfo, :authority, :ssl, :domain, :domainname,
16
- :domainzone, :request, :location, :query,
18
+ :domainzone, :request, :location, :origin, :query,
17
19
  :directory, :extension, :file
18
20
  ]
21
+
19
22
  PARTS = ESSENTIAL_PARTS + COMBINED_PARTS
20
23
 
21
24
  ALIASES = {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev