addressable 2.5.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +40 -0
- data/Gemfile +13 -17
- data/README.md +14 -15
- data/Rakefile +5 -3
- data/addressable.gemspec +37 -0
- data/lib/addressable.rb +2 -0
- data/lib/addressable/idna.rb +2 -0
- data/lib/addressable/idna/native.rb +4 -2
- data/lib/addressable/idna/pure.rb +54 -53
- data/lib/addressable/template.rb +63 -83
- data/lib/addressable/uri.rb +128 -64
- data/lib/addressable/version.rb +3 -1
- data/spec/addressable/idna_spec.rb +23 -7
- data/spec/addressable/net_http_compat_spec.rb +2 -0
- data/spec/addressable/security_spec.rb +2 -0
- data/spec/addressable/template_spec.rb +75 -2
- data/spec/addressable/uri_spec.rb +408 -215
- data/spec/spec_helper.rb +12 -0
- data/tasks/clobber.rake +2 -0
- data/tasks/gem.rake +8 -7
- data/tasks/git.rake +2 -0
- data/tasks/metrics.rake +2 -0
- data/tasks/profile.rake +72 -0
- data/tasks/rspec.rake +3 -1
- data/tasks/yard.rake +2 -0
- metadata +22 -16
- data/spec/addressable/rack_mount_compat_spec.rb +0 -104
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/setup'
|
2
4
|
require 'rspec/its'
|
3
5
|
|
@@ -14,8 +16,18 @@ rescue LoadError
|
|
14
16
|
add_filter "spec/"
|
15
17
|
add_filter "vendor/"
|
16
18
|
end
|
19
|
+
end if Gem.loaded_specs.key?("simplecov")
|
20
|
+
|
21
|
+
class TestHelper
|
22
|
+
def self.native_supported?
|
23
|
+
mri = RUBY_ENGINE == "ruby"
|
24
|
+
windows = RUBY_PLATFORM.include?("mingw")
|
25
|
+
|
26
|
+
mri && !windows
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
RSpec.configure do |config|
|
20
31
|
config.warnings = true
|
32
|
+
config.filter_run_when_matching :focus
|
21
33
|
end
|
data/tasks/clobber.rake
CHANGED
data/tasks/gem.rake
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rubygems/package_task"
|
2
4
|
|
3
5
|
namespace :gem do
|
@@ -9,7 +11,6 @@ namespace :gem do
|
|
9
11
|
|
10
12
|
s.files = PKG_FILES.to_a
|
11
13
|
|
12
|
-
s.has_rdoc = true
|
13
14
|
s.extra_rdoc_files = %w( README.md )
|
14
15
|
s.rdoc_options.concat ["--main", "README.md"]
|
15
16
|
|
@@ -18,10 +19,10 @@ namespace :gem do
|
|
18
19
|
exit(1)
|
19
20
|
end
|
20
21
|
|
21
|
-
s.required_ruby_version =
|
22
|
+
s.required_ruby_version = ">= 2.0"
|
22
23
|
|
23
|
-
s.add_runtime_dependency
|
24
|
-
s.add_development_dependency
|
24
|
+
s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 5.0"
|
25
|
+
s.add_development_dependency "bundler", ">= 1.0", "< 3.0"
|
25
26
|
|
26
27
|
s.require_path = "lib"
|
27
28
|
|
@@ -40,7 +41,7 @@ namespace :gem do
|
|
40
41
|
desc "Generates .gemspec file"
|
41
42
|
task :gemspec do
|
42
43
|
spec_string = GEM_SPEC.to_ruby
|
43
|
-
File.open("#{GEM_SPEC.name}.gemspec",
|
44
|
+
File.open("#{GEM_SPEC.name}.gemspec", "w") do |file|
|
44
45
|
file.write spec_string
|
45
46
|
end
|
46
47
|
end
|
@@ -70,9 +71,9 @@ namespace :gem do
|
|
70
71
|
desc "Reinstall the gem"
|
71
72
|
task :reinstall => [:uninstall, :install]
|
72
73
|
|
73
|
-
desc
|
74
|
+
desc "Package for release"
|
74
75
|
task :release => ["gem:package", "gem:gemspec"] do |t|
|
75
|
-
v = ENV[
|
76
|
+
v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
|
76
77
|
abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
|
77
78
|
pkg = "pkg/#{GEM_SPEC.full_name}"
|
78
79
|
|
data/tasks/git.rake
CHANGED
data/tasks/metrics.rake
CHANGED
data/tasks/profile.rake
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :profile do
|
4
|
+
desc "Profile Template match memory allocations"
|
5
|
+
task :template_match_memory do
|
6
|
+
require "memory_profiler"
|
7
|
+
require "addressable/template"
|
8
|
+
|
9
|
+
start_at = Time.now.to_f
|
10
|
+
template = Addressable::Template.new("http://example.com/{?one,two,three}")
|
11
|
+
report = MemoryProfiler.report do
|
12
|
+
30_000.times do
|
13
|
+
template.match(
|
14
|
+
"http://example.com/?one=one&two=floo&three=me"
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end_at = Time.now.to_f
|
19
|
+
print_options = { scale_bytes: true, normalize_paths: true }
|
20
|
+
puts "\n\n"
|
21
|
+
|
22
|
+
if ENV["CI"]
|
23
|
+
report.pretty_print(print_options)
|
24
|
+
else
|
25
|
+
t_allocated = report.scale_bytes(report.total_allocated_memsize)
|
26
|
+
t_retained = report.scale_bytes(report.total_retained_memsize)
|
27
|
+
|
28
|
+
puts "Total allocated: #{t_allocated} (#{report.total_allocated} objects)"
|
29
|
+
puts "Total retained: #{t_retained} (#{report.total_retained} objects)"
|
30
|
+
puts "Took #{end_at - start_at} seconds"
|
31
|
+
|
32
|
+
FileUtils.mkdir_p("tmp")
|
33
|
+
report.pretty_print(to_file: "tmp/memprof.txt", **print_options)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Profile URI parse memory allocations"
|
38
|
+
task :memory do
|
39
|
+
require "memory_profiler"
|
40
|
+
require "addressable/uri"
|
41
|
+
if ENV["IDNA_MODE"] == "pure"
|
42
|
+
Addressable.send(:remove_const, :IDNA)
|
43
|
+
load "addressable/idna/pure.rb"
|
44
|
+
end
|
45
|
+
|
46
|
+
start_at = Time.now.to_f
|
47
|
+
report = MemoryProfiler.report do
|
48
|
+
30_000.times do
|
49
|
+
Addressable::URI.parse(
|
50
|
+
"http://google.com/stuff/../?with_lots=of¶ms=asdff#!stuff"
|
51
|
+
).normalize
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end_at = Time.now.to_f
|
55
|
+
print_options = { scale_bytes: true, normalize_paths: true }
|
56
|
+
puts "\n\n"
|
57
|
+
|
58
|
+
if ENV["CI"]
|
59
|
+
report.pretty_print(**print_options)
|
60
|
+
else
|
61
|
+
t_allocated = report.scale_bytes(report.total_allocated_memsize)
|
62
|
+
t_retained = report.scale_bytes(report.total_retained_memsize)
|
63
|
+
|
64
|
+
puts "Total allocated: #{t_allocated} (#{report.total_allocated} objects)"
|
65
|
+
puts "Total retained: #{t_retained} (#{report.total_retained} objects)"
|
66
|
+
puts "Took #{end_at - start_at} seconds"
|
67
|
+
|
68
|
+
FileUtils.mkdir_p("tmp")
|
69
|
+
report.pretty_print(to_file: "tmp/memprof.txt", **print_options)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
data/tasks/rspec.rake
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "rspec/core/rake_task"
|
2
4
|
|
3
5
|
namespace :spec do
|
4
6
|
RSpec::Core::RakeTask.new(:simplecov) do |t|
|
5
7
|
t.pattern = FileList['spec/**/*_spec.rb']
|
6
|
-
t.rspec_opts = [
|
8
|
+
t.rspec_opts = %w[--color --format documentation] unless ENV["CI"]
|
7
9
|
end
|
8
10
|
|
9
11
|
namespace :simplecov do
|
data/tasks/yard.rake
CHANGED
metadata
CHANGED
@@ -1,53 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: addressable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bob Aman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: public_suffix
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '2.0'
|
20
17
|
- - ">="
|
21
18
|
- !ruby/object:Gem::Version
|
22
19
|
version: 2.0.2
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "~>"
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: '2.0'
|
30
27
|
- - ">="
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 2.0.2
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.0'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.0'
|
40
43
|
type: :development
|
41
44
|
prerelease: false
|
42
45
|
version_requirements: !ruby/object:Gem::Requirement
|
43
46
|
requirements:
|
44
|
-
- - "
|
47
|
+
- - ">="
|
45
48
|
- !ruby/object:Gem::Version
|
46
49
|
version: '1.0'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '3.0'
|
47
53
|
description: |
|
48
|
-
Addressable is
|
49
|
-
Ruby's standard library. It
|
50
|
-
|
54
|
+
Addressable is an alternative implementation to the URI implementation that is
|
55
|
+
part of Ruby's standard library. It is flexible, offers heuristic parsing, and
|
56
|
+
additionally provides extensive support for IRIs and URI templates.
|
51
57
|
email: bob@sporkmonger.com
|
52
58
|
executables: []
|
53
59
|
extensions: []
|
@@ -59,6 +65,7 @@ files:
|
|
59
65
|
- LICENSE.txt
|
60
66
|
- README.md
|
61
67
|
- Rakefile
|
68
|
+
- addressable.gemspec
|
62
69
|
- data/unicode.data
|
63
70
|
- lib/addressable.rb
|
64
71
|
- lib/addressable/idna.rb
|
@@ -69,7 +76,6 @@ files:
|
|
69
76
|
- lib/addressable/version.rb
|
70
77
|
- spec/addressable/idna_spec.rb
|
71
78
|
- spec/addressable/net_http_compat_spec.rb
|
72
|
-
- spec/addressable/rack_mount_compat_spec.rb
|
73
79
|
- spec/addressable/security_spec.rb
|
74
80
|
- spec/addressable/template_spec.rb
|
75
81
|
- spec/addressable/uri_spec.rb
|
@@ -78,6 +84,7 @@ files:
|
|
78
84
|
- tasks/gem.rake
|
79
85
|
- tasks/git.rake
|
80
86
|
- tasks/metrics.rake
|
87
|
+
- tasks/profile.rake
|
81
88
|
- tasks/rspec.rake
|
82
89
|
- tasks/yard.rake
|
83
90
|
homepage: https://github.com/sporkmonger/addressable
|
@@ -101,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
108
|
- !ruby/object:Gem::Version
|
102
109
|
version: '0'
|
103
110
|
requirements: []
|
104
|
-
|
105
|
-
rubygems_version: 2.5.1
|
111
|
+
rubygems_version: 3.0.3
|
106
112
|
signing_key:
|
107
113
|
specification_version: 4
|
108
114
|
summary: URI Implementation
|
@@ -1,104 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# Copyright (C) Bob Aman
|
3
|
-
#
|
4
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
-
# you may not use this file except in compliance with the License.
|
6
|
-
# You may obtain a copy of the License at
|
7
|
-
#
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
-
#
|
10
|
-
# Unless required by applicable law or agreed to in writing, software
|
11
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
-
# See the License for the specific language governing permissions and
|
14
|
-
# limitations under the License.
|
15
|
-
|
16
|
-
|
17
|
-
require "spec_helper"
|
18
|
-
|
19
|
-
require "addressable/uri"
|
20
|
-
require "addressable/template"
|
21
|
-
require "rack/mount"
|
22
|
-
|
23
|
-
describe Rack::Mount do
|
24
|
-
let(:app_one) do
|
25
|
-
proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 1'] }
|
26
|
-
end
|
27
|
-
let(:app_two) do
|
28
|
-
proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 2'] }
|
29
|
-
end
|
30
|
-
let(:app_three) do
|
31
|
-
proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 3'] }
|
32
|
-
end
|
33
|
-
let(:routes) do
|
34
|
-
s = Rack::Mount::RouteSet.new do |set|
|
35
|
-
set.add_route(app_one, {
|
36
|
-
:request_method => 'GET',
|
37
|
-
:path_info => Addressable::Template.new('/one/{id}/')
|
38
|
-
}, {:id => 'unidentified'}, :one)
|
39
|
-
set.add_route(app_two, {
|
40
|
-
:request_method => 'GET',
|
41
|
-
:path_info => Addressable::Template.new('/two/')
|
42
|
-
}, {:id => 'unidentified'}, :two)
|
43
|
-
set.add_route(app_three, {
|
44
|
-
:request_method => 'GET',
|
45
|
-
:path_info => Addressable::Template.new('/three/{id}/').to_regexp
|
46
|
-
}, {:id => 'unidentified'}, :three)
|
47
|
-
end
|
48
|
-
s.rehash
|
49
|
-
s
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should generate from routes with Addressable::Template" do
|
53
|
-
path, _ = routes.generate(:path_info, :one, {:id => '123'})
|
54
|
-
expect(path).to eq '/one/123/'
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should generate from routes with Addressable::Template using defaults" do
|
58
|
-
path, _ = routes.generate(:path_info, :one, {})
|
59
|
-
expect(path).to eq '/one/unidentified/'
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should recognize routes with Addressable::Template" do
|
63
|
-
request = Rack::Request.new(
|
64
|
-
'REQUEST_METHOD' => 'GET',
|
65
|
-
'PATH_INFO' => '/one/123/'
|
66
|
-
)
|
67
|
-
route, _, params = routes.recognize(request)
|
68
|
-
expect(route).not_to be_nil
|
69
|
-
expect(route.app).to eq app_one
|
70
|
-
expect(params).to eq({id: '123'})
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should generate from routes with Addressable::Template" do
|
74
|
-
path, _ = routes.generate(:path_info, :two, {:id => '654'})
|
75
|
-
expect(path).to eq '/two/'
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should generate from routes with Addressable::Template using defaults" do
|
79
|
-
path, _ = routes.generate(:path_info, :two, {})
|
80
|
-
expect(path).to eq '/two/'
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should recognize routes with Addressable::Template" do
|
84
|
-
request = Rack::Request.new(
|
85
|
-
'REQUEST_METHOD' => 'GET',
|
86
|
-
'PATH_INFO' => '/two/'
|
87
|
-
)
|
88
|
-
route, _, params = routes.recognize(request)
|
89
|
-
expect(route).not_to be_nil
|
90
|
-
expect(route.app).to eq app_two
|
91
|
-
expect(params).to eq({id: 'unidentified'})
|
92
|
-
end
|
93
|
-
|
94
|
-
it "should recognize routes with derived Regexp" do
|
95
|
-
request = Rack::Request.new(
|
96
|
-
'REQUEST_METHOD' => 'GET',
|
97
|
-
'PATH_INFO' => '/three/789/'
|
98
|
-
)
|
99
|
-
route, _, params = routes.recognize(request)
|
100
|
-
expect(route).not_to be_nil
|
101
|
-
expect(route.app).to eq app_three
|
102
|
-
expect(params).to eq({id: '789'})
|
103
|
-
end
|
104
|
-
end
|