addressable 2.7.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
 
@@ -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.7.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-08-31 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
@@ -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.2.3
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