addressable 2.6.0 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/spec_helper.rb CHANGED
@@ -16,6 +16,15 @@ rescue LoadError
16
16
  add_filter "spec/"
17
17
  add_filter "vendor/"
18
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
19
28
  end
20
29
 
21
30
  RSpec.configure do |config|
data/tasks/gem.rake CHANGED
@@ -11,7 +11,6 @@ namespace :gem do
11
11
 
12
12
  s.files = PKG_FILES.to_a
13
13
 
14
- s.has_rdoc = true
15
14
  s.extra_rdoc_files = %w( README.md )
16
15
  s.rdoc_options.concat ["--main", "README.md"]
17
16
 
@@ -20,10 +19,10 @@ namespace :gem do
20
19
  exit(1)
21
20
  end
22
21
 
23
- s.required_ruby_version = '>= 2.0'
22
+ s.required_ruby_version = ">= 2.0"
24
23
 
25
- s.add_runtime_dependency 'public_suffix', '>= 2.0.2', '< 4.0'
26
- s.add_development_dependency 'bundler', '>= 1.0', '< 3.0'
24
+ s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 5.0"
25
+ s.add_development_dependency "bundler", ">= 1.0", "< 3.0"
27
26
 
28
27
  s.require_path = "lib"
29
28
 
@@ -42,7 +41,7 @@ namespace :gem do
42
41
  desc "Generates .gemspec file"
43
42
  task :gemspec do
44
43
  spec_string = GEM_SPEC.to_ruby
45
- File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
44
+ File.open("#{GEM_SPEC.name}.gemspec", "w") do |file|
46
45
  file.write spec_string
47
46
  end
48
47
  end
@@ -72,9 +71,9 @@ namespace :gem do
72
71
  desc "Reinstall the gem"
73
72
  task :reinstall => [:uninstall, :install]
74
73
 
75
- desc 'Package for release'
74
+ desc "Package for release"
76
75
  task :release => ["gem:package", "gem:gemspec"] do |t|
77
- v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
76
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
78
77
  abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
79
78
  pkg = "pkg/#{GEM_SPEC.full_name}"
80
79
 
@@ -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&params=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
@@ -5,7 +5,7 @@ require "rspec/core/rake_task"
5
5
  namespace :spec do
6
6
  RSpec::Core::RakeTask.new(:simplecov) do |t|
7
7
  t.pattern = FileList['spec/**/*_spec.rb']
8
- t.rspec_opts = ['--color', '--format', 'documentation']
8
+ t.rspec_opts = %w[--color --format documentation] unless ENV["CI"]
9
9
  end
10
10
 
11
11
  namespace :simplecov do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
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: 2019-01-18 00:00:00.000000000 Z
11
+ date: 2021-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: public_suffix
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 2.0.2
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.0'
22
+ version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 2.0.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.0'
32
+ version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -51,9 +51,9 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3.0'
53
53
  description: |
54
- Addressable is a replacement for the URI implementation that is part of
55
- Ruby's standard library. It more closely conforms to the relevant RFCs and
56
- adds support for IRIs and URI templates.
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.
57
57
  email: bob@sporkmonger.com
58
58
  executables: []
59
59
  extensions: []
@@ -65,6 +65,7 @@ files:
65
65
  - LICENSE.txt
66
66
  - README.md
67
67
  - Rakefile
68
+ - addressable.gemspec
68
69
  - data/unicode.data
69
70
  - lib/addressable.rb
70
71
  - lib/addressable/idna.rb
@@ -75,7 +76,6 @@ files:
75
76
  - lib/addressable/version.rb
76
77
  - spec/addressable/idna_spec.rb
77
78
  - spec/addressable/net_http_compat_spec.rb
78
- - spec/addressable/rack_mount_compat_spec.rb
79
79
  - spec/addressable/security_spec.rb
80
80
  - spec/addressable/template_spec.rb
81
81
  - spec/addressable/uri_spec.rb
@@ -84,6 +84,7 @@ files:
84
84
  - tasks/gem.rake
85
85
  - tasks/git.rake
86
86
  - tasks/metrics.rake
87
+ - tasks/profile.rake
87
88
  - tasks/rspec.rake
88
89
  - tasks/yard.rake
89
90
  homepage: https://github.com/sporkmonger/addressable
@@ -107,8 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
110
  requirements: []
110
- rubyforge_project:
111
- rubygems_version: 2.5.1
111
+ rubygems_version: 3.0.3
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: URI Implementation
@@ -1,106 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # coding: utf-8
4
- # Copyright (C) Bob Aman
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
-
19
- require "spec_helper"
20
-
21
- require "addressable/uri"
22
- require "addressable/template"
23
- require "rack/mount"
24
-
25
- describe Rack::Mount do
26
- let(:app_one) do
27
- proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 1'] }
28
- end
29
- let(:app_two) do
30
- proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 2'] }
31
- end
32
- let(:app_three) do
33
- proc { |env| [200, {'Content-Type' => 'text/plain'}, 'Route 3'] }
34
- end
35
- let(:routes) do
36
- s = Rack::Mount::RouteSet.new do |set|
37
- set.add_route(app_one, {
38
- :request_method => 'GET',
39
- :path_info => Addressable::Template.new('/one/{id}/')
40
- }, {:id => 'unidentified'}, :one)
41
- set.add_route(app_two, {
42
- :request_method => 'GET',
43
- :path_info => Addressable::Template.new('/two/')
44
- }, {:id => 'unidentified'}, :two)
45
- set.add_route(app_three, {
46
- :request_method => 'GET',
47
- :path_info => Addressable::Template.new('/three/{id}/').to_regexp
48
- }, {:id => 'unidentified'}, :three)
49
- end
50
- s.rehash
51
- s
52
- end
53
-
54
- it "should generate from routes with Addressable::Template" do
55
- path, _ = routes.generate(:path_info, :one, {:id => '123'})
56
- expect(path).to eq '/one/123/'
57
- end
58
-
59
- it "should generate from routes with Addressable::Template using defaults" do
60
- path, _ = routes.generate(:path_info, :one, {})
61
- expect(path).to eq '/one/unidentified/'
62
- end
63
-
64
- it "should recognize routes with Addressable::Template" do
65
- request = Rack::Request.new(
66
- 'REQUEST_METHOD' => 'GET',
67
- 'PATH_INFO' => '/one/123/'
68
- )
69
- route, _, params = routes.recognize(request)
70
- expect(route).not_to be_nil
71
- expect(route.app).to eq app_one
72
- expect(params).to eq({id: '123'})
73
- end
74
-
75
- it "should generate from routes with Addressable::Template" do
76
- path, _ = routes.generate(:path_info, :two, {:id => '654'})
77
- expect(path).to eq '/two/'
78
- end
79
-
80
- it "should generate from routes with Addressable::Template using defaults" do
81
- path, _ = routes.generate(:path_info, :two, {})
82
- expect(path).to eq '/two/'
83
- end
84
-
85
- it "should recognize routes with Addressable::Template" do
86
- request = Rack::Request.new(
87
- 'REQUEST_METHOD' => 'GET',
88
- 'PATH_INFO' => '/two/'
89
- )
90
- route, _, params = routes.recognize(request)
91
- expect(route).not_to be_nil
92
- expect(route.app).to eq app_two
93
- expect(params).to eq({id: 'unidentified'})
94
- end
95
-
96
- it "should recognize routes with derived Regexp" do
97
- request = Rack::Request.new(
98
- 'REQUEST_METHOD' => 'GET',
99
- 'PATH_INFO' => '/three/789/'
100
- )
101
- route, _, params = routes.recognize(request)
102
- expect(route).not_to be_nil
103
- expect(route.app).to eq app_three
104
- expect(params).to eq({id: '789'})
105
- end
106
- end