furi 0.2.2 → 0.2.3

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
- SHA1:
3
- metadata.gz: e47171efdec80d8610e7dea95a1eed17876ea14b
4
- data.tar.gz: 33a2e11ef018c0d5c9d6695ced7c15e9f3dd3fb4
2
+ SHA256:
3
+ metadata.gz: 37ea1203ca474e34d99624eb7e7cf43935197a4cec1a0a49e110b8674f5a1cec
4
+ data.tar.gz: 5ef6f167bd64ac72f6a8b78324c871a88734f06e39faecd4e7aaee1abe5a2f0a
5
5
  SHA512:
6
- metadata.gz: 7e0c644b931d878b69b6d902aad0772aefa16a5ff4066db3bab871912dbe1e0b4ed91b41d4fb1b921ddfe36119f60293081e6b924cab8747865c1aa1451d3ebe
7
- data.tar.gz: 1bbc865cbe5551b416a28243260e01e01409b600f32fd83b8b3a3da320cc7f9f6ce1bdc82363d92a1b8dd1941de99356e38a4d2903a57ad2f8ef956db4a22f23
6
+ metadata.gz: db8b15ea5e9d25852df4be4e83a67bf60d8ed85d703fba1fa7a1ee28fbe7d2e547dc4ea182d52ef396316f92ef3634264750b4d76d0016c51c6a9afe78b19e11
7
+ data.tar.gz: 9617142f8e989e885c8bd17a874fa221b6df1f2bea1398a786e9291f4d87d9d6ae4913f8904c3273902b8c0a1d008b0ec3f0aa8918aef34d9d5538fca93a0861
@@ -0,0 +1,19 @@
1
+ name: CI
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ fail-fast: false
9
+ matrix:
10
+ ruby: [2.4, 2.5, 2.6, 2.7, 3.0]
11
+ name: Ruby ${{ matrix.ruby }}
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: ${{ matrix.ruby }}
18
+ bundler-cache: true
19
+ - run: bundle exec rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ # v0.2.3
2
+
3
+ * Ruby 3.0 support #2
4
+ * Escaping special characters in anchor
5
+
data/Gemfile CHANGED
@@ -1,4 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in furi.gemspec
4
6
  gemspec
7
+
8
+ gem "pry-byebug", "~> 3.9"
9
+ gem "rake", "~> 13.0"
10
+ gem "rspec", "~> 3.10"
11
+ gem "bump"
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Furi
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/furi.svg)](https://badge.fury.io/rb/furi)
4
+ [![Build Status](https://github.com/bogdan/furi/workflows/CI/badge.svg?branch=master)](https://github.com/bogdan/furi/actions)
5
+ [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Ffuri.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Ffuri?ref=badge_shield)
6
+
3
7
  Furi is a Friendly URI parsing library.
4
8
  Furi's philosophy is to make any operation possible in ONE LINE OF CODE.
5
9
 
@@ -9,7 +13,7 @@ If there is an operation that takes more than one line of code to do with Furi,
9
13
 
10
14
  Add this line to your application's Gemfile:
11
15
 
12
- ```ruby
16
+ ``` ruby
13
17
  gem 'furi'
14
18
  ```
15
19
 
@@ -24,11 +28,10 @@ Or install it yourself as:
24
28
  ## Usage
25
29
 
26
30
  I'll say it again: any operation should take exacly one line of code!
27
- Here are basic:
31
+ Here are basic:
28
32
 
29
33
  ### Utility Methods
30
34
 
31
-
32
35
  Parsing the URI fragments:
33
36
 
34
37
  ``` ruby
@@ -39,31 +42,29 @@ Furi.port!("http://gusiev.com") # => 80
39
42
 
40
43
  Updating the URI parts:
41
44
 
42
- ```
45
+ ``` ruby
43
46
  Furi.update("http://gusiev.com", protocol: '') # => "//gusiev.com"
44
- Furi.update("http://gusiev.com?source=google", query: {email: "a@b.com"})
47
+ Furi.update("http://gusiev.com?source=google", query: {email: "a@b.com"})
45
48
  # => "http://gusiev.com?source=google&email=a@b.com"
46
- Furi.replace("http://gusiev.com?source=google", query: {email: "a@b.com"})
49
+ Furi.replace("http://gusiev.com?source=google", query: {email: "a@b.com"})
47
50
  # => "http://gusiev.com?email=a@b.com"
48
51
 
49
52
  Furi.defaults("http://gusiev.com", subdomain: 'www') # => "http://www.gusiev.com"
50
53
  Furi.defaults("http://blog.gusiev.com", subdomain: 'www') # => "http://blog.gusiev.com"
51
-
52
54
  ```
53
55
 
54
56
  Building an URI from initial parts:
55
57
 
56
58
  ``` ruby
57
-
58
- Furi.build(protocol: '//', host: 'gusiev.com', path: '/assets/application.js')
59
+ Furi.build(protocol: '//', host: 'gusiev.com', path: '/assets/application.js')
59
60
  # => "//gusiev.com/assets/application.js"
60
61
  ```
61
62
 
62
63
  ### Working with Object
63
64
 
64
65
  ``` ruby
65
- uri = Furi.parse("gusiev.com")
66
- # => #<Furi::Uri "gusiev.com">
66
+ uri = Furi.parse("gusiev.com")
67
+ # => #<Furi::Uri "gusiev.com">
67
68
 
68
69
  uri.port # => nil
69
70
  uri.port! # => 80
@@ -92,12 +93,12 @@ uri.merge_query(person: {email: 'a@b.com'})
92
93
  ## Reference
93
94
 
94
95
  ```
95
- location resource
96
- | ___|___
97
- _______|_______ / \
98
- / \ / \
99
- / authority request \
100
- / __________|_________ | \
96
+ location resource
97
+ | ___|___
98
+ _______|_______ / \
99
+ / \ / \
100
+ / authority request \
101
+ / __________|_________ | \
101
102
  / / \ ______|______ \
102
103
  / userinfo hostinfo / \ \
103
104
  / __|___ ___|___ / \ \
@@ -109,25 +110,29 @@ uri.merge_query(person: {email: 'a@b.com'})
109
110
  \_/ \_/ \___/ \_/ \__________/\ / \_/
110
111
  | | | | | \___/ |
111
112
  protocol subdomain | domainzone directory | extension
112
- | | filename |
113
- domainname / \_____/
114
- \___/ |
115
- | file
116
- domain
113
+ | | filename |
114
+ domainname / \_____/
115
+ \___/ |
116
+ | file
117
+ domain
117
118
  ```
118
119
 
119
-
120
120
  Originated from [URI.js](http://medialize.github.io/URI.js/about-uris.html) parsing library.
121
121
  Giving credit...
122
122
 
123
-
124
123
  ## TODO
125
124
 
126
- * Improve URI.join algorithm to match the one used in Addressible library
125
+ * Improve URI.join algorithm to match the one used in Addressable library
127
126
  * Implement filename
127
+ * Encoding/Decoding special characters:
128
+ * path
129
+ * query
130
+ * fragment
128
131
 
129
132
  ## Contributing
130
133
 
131
134
  Contribute in the way you want. Branch names and other bla-bla-bla do not matter.
132
135
 
136
+ ## License
133
137
 
138
+ [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fbogdan%2Ffuri.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fbogdan%2Ffuri?ref=badge_large)
data/Rakefile CHANGED
@@ -1,13 +1,8 @@
1
- require "bundler/gem_tasks"
2
-
1
+ # frozen_string_literal: true
3
2
 
4
- begin
5
- require 'rspec/core/rake_task'
6
- RSpec::Core::RakeTask.new(:spec)
7
- rescue LoadError
8
- end
9
-
10
- task :default => :spec do
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
11
5
 
12
- end
6
+ RSpec::Core::RakeTask.new(:spec)
13
7
 
8
+ task default: :spec
data/furi.gemspec CHANGED
@@ -1,7 +1,6 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'furi/version'
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/furi/version"
5
4
 
6
5
  Gem::Specification.new do |spec|
7
6
  spec.name = "furi"
@@ -9,17 +8,17 @@ Gem::Specification.new do |spec|
9
8
  spec.authors = ["Bogdan Gusiev"]
10
9
  spec.email = ["agresso@gmail.com"]
11
10
  spec.summary = %q{Make URI processing as easy as it should be}
12
- spec.description = %q{The phylosophy of this gem is to make any URI modification or parsing operation to take only one line of code and never more}
13
- spec.homepage = ""
11
+ spec.description = %q{The philosophy of this gem is to make any URI modification or parsing operation to take only one line of code and never more}
12
+ spec.homepage = "https://github.com/bogdan/furi"
14
13
  spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
15
 
16
- spec.files = `git ls-files -z`.split("\x0")
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
16
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = spec.homepage
20
19
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "pry-byebug"
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+ spec.require_paths = ["lib"]
25
24
  end
data/lib/furi.rb CHANGED
@@ -172,7 +172,9 @@ module Furi
172
172
  def self.join(*uris)
173
173
  uris.map do |uri|
174
174
  Furi.parse(uri)
175
- end.reduce(:join)
175
+ end.reduce do |memo, uri|
176
+ memo.send(:join, uri)
177
+ end
176
178
  end
177
179
 
178
180
  class Error < StandardError
data/lib/furi/uri.rb CHANGED
@@ -135,7 +135,7 @@ module Furi
135
135
  end
136
136
 
137
137
  def hostinfo
138
- return host unless explicit_port?
138
+ return host unless custom_port?
139
139
  if port && !host
140
140
  raise Furi::FormattingError, "can not build URI with port but without host"
141
141
  end
@@ -178,7 +178,7 @@ module Furi
178
178
  result << "?" << query_string
179
179
  end
180
180
  if anchor
181
- result << "#" << anchor
181
+ result << encoded_anchor
182
182
  end
183
183
  result.join
184
184
  end
@@ -420,7 +420,7 @@ module Furi
420
420
 
421
421
  def resource
422
422
  return nil unless request
423
- [request, anchor].compact.join("#")
423
+ request + encoded_anchor
424
424
  end
425
425
 
426
426
  def resource=(value)
@@ -483,6 +483,14 @@ module Furi
483
483
  authority
484
484
  end
485
485
 
486
+ def custom_port?
487
+ port && port != default_port
488
+ end
489
+
490
+ def mailto?
491
+ protocol == "mailto"
492
+ end
493
+
486
494
  protected
487
495
 
488
496
  def file_tokens
@@ -493,10 +501,6 @@ module Furi
493
501
  !!@query
494
502
  end
495
503
 
496
- def explicit_port?
497
- port && port != default_port
498
- end
499
-
500
504
  def parse_uri_string(string)
501
505
  if string.empty?
502
506
  raise Furi::FormattingError, "can not be an empty string"
@@ -531,7 +535,7 @@ module Furi
531
535
  def parse_anchor_and_query(string)
532
536
  string ||= ''
533
537
  string, *anchor = string.split("#")
534
- self.anchor = anchor.join("#")
538
+ self.anchor = ::URI::DEFAULT_PARSER.unescape(anchor.join("#"))
535
539
  if string && string.include?("?")
536
540
  string, query_string = string.split("?", 2)
537
541
  self.query_tokens = query_string
@@ -583,8 +587,9 @@ module Furi
583
587
  end
584
588
  end
585
589
 
586
- def mailto?
587
- protocol == "mailto"
590
+ def encoded_anchor
591
+ return "" unless anchor
592
+ "#" + ::URI::DEFAULT_PARSER.escape(anchor)
588
593
  end
589
594
  end
590
595
  end
data/lib/furi/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Furi
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
metadata CHANGED
@@ -1,72 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: furi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Gusiev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rspec
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: pry-byebug
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- description: The phylosophy of this gem is to make any URI modification or parsing
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: The philosophy of this gem is to make any URI modification or parsing
70
14
  operation to take only one line of code and never more
71
15
  email:
72
16
  - agresso@gmail.com
@@ -74,8 +18,10 @@ executables: []
74
18
  extensions: []
75
19
  extra_rdoc_files: []
76
20
  files:
21
+ - ".github/workflows/ci.yml"
77
22
  - ".gitignore"
78
23
  - ".rspec"
24
+ - CHANGELOG.md
79
25
  - Gemfile
80
26
  - LICENSE.txt
81
27
  - README.md
@@ -86,14 +32,14 @@ files:
86
32
  - lib/furi/uri.rb
87
33
  - lib/furi/utils.rb
88
34
  - lib/furi/version.rb
89
- - spec/furi/uri_spec.rb
90
- - spec/furi_spec.rb
91
- - spec/spec_helper.rb
92
- homepage: ''
35
+ homepage: https://github.com/bogdan/furi
93
36
  licenses:
94
37
  - MIT
95
- metadata: {}
96
- post_install_message:
38
+ metadata:
39
+ allowed_push_host: https://rubygems.org
40
+ homepage_uri: https://github.com/bogdan/furi
41
+ source_code_uri: https://github.com/bogdan/furi
42
+ post_install_message:
97
43
  rdoc_options: []
98
44
  require_paths:
99
45
  - lib
@@ -101,19 +47,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
101
47
  requirements:
102
48
  - - ">="
103
49
  - !ruby/object:Gem::Version
104
- version: '0'
50
+ version: 2.4.0
105
51
  required_rubygems_version: !ruby/object:Gem::Requirement
106
52
  requirements:
107
53
  - - ">="
108
54
  - !ruby/object:Gem::Version
109
55
  version: '0'
110
56
  requirements: []
111
- rubyforge_project:
112
- rubygems_version: 2.6.7
113
- signing_key:
57
+ rubygems_version: 3.2.0
58
+ signing_key:
114
59
  specification_version: 4
115
60
  summary: Make URI processing as easy as it should be
116
- test_files:
117
- - spec/furi/uri_spec.rb
118
- - spec/furi_spec.rb
119
- - spec/spec_helper.rb
61
+ test_files: []