addressable 2.3.6 → 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
@@ -1,6 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'rspec/its'
5
+
1
6
  begin
2
7
  require 'coveralls'
3
- Coveralls.wear!
8
+ Coveralls.wear! do
9
+ add_filter "spec/"
10
+ add_filter "vendor/"
11
+ end
4
12
  rescue LoadError
5
13
  warn "warning: coveralls gem not found; skipping Coveralls"
14
+ require 'simplecov'
15
+ SimpleCov.start do
16
+ add_filter "spec/"
17
+ add_filter "vendor/"
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
28
+ end
29
+
30
+ RSpec.configure do |config|
31
+ config.warnings = true
32
+ config.filter_run_when_matching :focus
6
33
  end
data/tasks/clobber.rake CHANGED
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+
1
3
  desc "Remove all build products"
2
4
  task "clobber"
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,17 +19,17 @@ namespace :gem do
18
19
  exit(1)
19
20
  end
20
21
 
21
- s.add_development_dependency("rake", ">= 0.7.3")
22
- s.add_development_dependency("rspec", ">= 2.9.0")
23
- s.add_development_dependency("launchy", ">= 0.3.2")
22
+ s.required_ruby_version = ">= 2.0"
23
+
24
+ s.add_runtime_dependency "public_suffix", ">= 2.0.2", "< 5.0"
25
+ s.add_development_dependency "bundler", ">= 1.0", "< 3.0"
24
26
 
25
27
  s.require_path = "lib"
26
28
 
27
29
  s.author = "Bob Aman"
28
30
  s.email = "bob@sporkmonger.com"
29
- s.homepage = RUBY_FORGE_URL
30
- s.rubyforge_project = RUBY_FORGE_PROJECT
31
- s.license = "Apache License 2.0"
31
+ s.homepage = "https://github.com/sporkmonger/addressable"
32
+ s.license = "Apache-2.0"
32
33
  end
33
34
 
34
35
  Gem::PackageTask.new(GEM_SPEC) do |p|
@@ -40,15 +41,8 @@ namespace :gem do
40
41
  desc "Generates .gemspec file"
41
42
  task :gemspec do
42
43
  spec_string = GEM_SPEC.to_ruby
43
-
44
- begin
45
- Thread.new { eval("$SAFE = 3\n#{spec_string}", binding) }.join
46
- rescue
47
- abort "unsafe gemspec: #{$!}"
48
- else
49
- File.open("#{GEM_SPEC.name}.gemspec", 'w') do |file|
50
- file.write spec_string
51
- end
44
+ File.open("#{GEM_SPEC.name}.gemspec", "w") do |file|
45
+ file.write spec_string
52
46
  end
53
47
  end
54
48
 
@@ -76,6 +70,18 @@ namespace :gem do
76
70
 
77
71
  desc "Reinstall the gem"
78
72
  task :reinstall => [:uninstall, :install]
73
+
74
+ desc "Package for release"
75
+ task :release => ["gem:package", "gem:gemspec"] do |t|
76
+ v = ENV["VERSION"] or abort "Must supply VERSION=x.y.z"
77
+ abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
78
+ pkg = "pkg/#{GEM_SPEC.full_name}"
79
+
80
+ changelog = File.open("CHANGELOG.md") { |file| file.read }
81
+
82
+ puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}"
83
+ Rake::Task["git:tag:create"].invoke
84
+ end
79
85
  end
80
86
 
81
87
  desc "Alias to gem:package"
data/tasks/git.rake CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :git do
2
4
  namespace :tag do
3
5
  desc "List tags from the Git repository"
@@ -20,7 +22,7 @@ namespace :git do
20
22
  abort "Versions don't match #{v} vs #{PKG_VERSION}" if v != PKG_VERSION
21
23
 
22
24
  git_status = `git status`
23
- if git_status !~ /nothing to commit \(working directory clean\)/
25
+ if git_status !~ /^nothing to commit/
24
26
  abort "Working directory isn't clean."
25
27
  end
26
28
 
data/tasks/metrics.rake CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  namespace :metrics do
2
4
  task :lines do
3
5
  lines, codelines, total_lines, total_codelines = 0, 0, 0, 0
@@ -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
@@ -1,58 +1,23 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rspec/core/rake_task"
2
4
 
3
5
  namespace :spec do
4
- RSpec::Core::RakeTask.new(:rcov) do |t|
5
- t.pattern = FileList['spec/**/*_spec.rb']
6
- t.rspec_opts = ['--color', '--format', 'documentation']
7
-
8
- t.rcov = RCOV_ENABLED
9
- t.rcov_opts = [
10
- '--exclude', 'lib\\/compat',
11
- '--exclude', 'spec',
12
- '--exclude', '\\.rvm\\/gems',
13
- '--exclude', '1\\.8\\/gems',
14
- '--exclude', '1\\.9\\/gems',
15
- '--exclude', '\\.rvm',
16
- '--exclude', '\\/Library\\/Ruby',
17
- '--exclude', 'addressable\\/idna' # environment dependant
18
- ]
19
- end
20
-
21
- RSpec::Core::RakeTask.new(:normal) do |t|
22
- t.pattern = FileList['spec/**/*_spec.rb'].exclude(/compat/)
23
- t.rspec_opts = ['--color', '--format', 'documentation']
24
- t.rcov = false
25
- end
26
-
27
- RSpec::Core::RakeTask.new(:all) do |t|
28
- t.pattern = FileList['spec/**/*_spec.rb']
29
- t.rspec_opts = ['--color', '--format', 'documentation']
30
- t.rcov = false
31
- end
32
-
33
- desc "Generate HTML Specdocs for all specs"
34
- RSpec::Core::RakeTask.new(:specdoc) do |t|
35
- specdoc_path = File.expand_path(
36
- File.join(File.dirname(__FILE__), '..', 'documentation')
37
- )
38
- Dir.mkdir(specdoc_path) if !File.exist?(specdoc_path)
39
-
40
- output_file = File.join(specdoc_path, 'index.html')
6
+ RSpec::Core::RakeTask.new(:simplecov) do |t|
41
7
  t.pattern = FileList['spec/**/*_spec.rb']
42
- t.rspec_opts = ["--format", "\"html:#{output_file}\"", "--diff"]
43
- t.fail_on_error = false
8
+ t.rspec_opts = %w[--color --format documentation] unless ENV["CI"]
44
9
  end
45
10
 
46
- namespace :rcov do
11
+ namespace :simplecov do
47
12
  desc "Browse the code coverage report."
48
- task :browse => "spec:rcov" do
13
+ task :browse => "spec:simplecov" do
49
14
  require "launchy"
50
- Launchy::Browser.run("coverage/index.html")
15
+ Launchy.open("coverage/index.html")
51
16
  end
52
17
  end
53
18
  end
54
19
 
55
- desc "Alias to spec:normal"
56
- task "spec" => "spec:normal"
20
+ desc "Alias to spec:simplecov"
21
+ task "spec" => "spec:simplecov"
57
22
 
58
- task "clobber" => ["spec:clobber_rcov"]
23
+ task "clobber" => ["spec:clobber_simplecov"]
data/tasks/yard.rake CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "rake"
2
4
 
3
5
  begin
metadata CHANGED
@@ -1,67 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: addressable
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.6
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: 2014-03-24 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
- name: rake
14
+ name: public_suffix
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.7.3
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
19
+ version: 2.0.2
20
+ - - "<"
25
21
  - !ruby/object:Gem::Version
26
- version: 0.7.3
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: 2.9.0
34
- type: :development
22
+ version: '5.0'
23
+ type: :runtime
35
24
  prerelease: false
36
25
  version_requirements: !ruby/object:Gem::Requirement
37
26
  requirements:
38
- - - '>='
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.2
30
+ - - "<"
39
31
  - !ruby/object:Gem::Version
40
- version: 2.9.0
32
+ version: '5.0'
41
33
  - !ruby/object:Gem::Dependency
42
- name: launchy
34
+ name: bundler
43
35
  requirement: !ruby/object:Gem::Requirement
44
36
  requirements:
45
- - - '>='
37
+ - - ">="
46
38
  - !ruby/object:Gem::Version
47
- version: 0.3.2
39
+ version: '1.0'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '3.0'
48
43
  type: :development
49
44
  prerelease: false
50
45
  version_requirements: !ruby/object:Gem::Requirement
51
46
  requirements:
52
- - - '>='
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '1.0'
50
+ - - "<"
53
51
  - !ruby/object:Gem::Version
54
- version: 0.3.2
52
+ version: '3.0'
55
53
  description: |
56
- Addressable is a replacement for the URI implementation that is part of
57
- Ruby's standard library. It more closely conforms to the relevant RFCs and
58
- 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.
59
57
  email: bob@sporkmonger.com
60
58
  executables: []
61
59
  extensions: []
62
60
  extra_rdoc_files:
63
61
  - README.md
64
62
  files:
63
+ - CHANGELOG.md
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - addressable.gemspec
69
+ - data/unicode.data
70
+ - lib/addressable.rb
65
71
  - lib/addressable/idna.rb
66
72
  - lib/addressable/idna/native.rb
67
73
  - lib/addressable/idna/pure.rb
@@ -70,46 +76,39 @@ files:
70
76
  - lib/addressable/version.rb
71
77
  - spec/addressable/idna_spec.rb
72
78
  - spec/addressable/net_http_compat_spec.rb
79
+ - spec/addressable/security_spec.rb
73
80
  - spec/addressable/template_spec.rb
74
81
  - spec/addressable/uri_spec.rb
75
82
  - spec/spec_helper.rb
76
- - data/unicode.data
77
83
  - tasks/clobber.rake
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
- - tasks/rubyforge.rake
83
89
  - tasks/yard.rake
84
- - website/index.html
85
- - CHANGELOG.md
86
- - Gemfile
87
- - LICENSE.txt
88
- - README.md
89
- - Rakefile
90
- homepage: http://addressable.rubyforge.org/
90
+ homepage: https://github.com/sporkmonger/addressable
91
91
  licenses:
92
- - Apache License 2.0
92
+ - Apache-2.0
93
93
  metadata: {}
94
94
  post_install_message:
95
95
  rdoc_options:
96
- - --main
96
+ - "--main"
97
97
  - README.md
98
98
  require_paths:
99
99
  - lib
100
100
  required_ruby_version: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: '0'
104
+ version: '2.0'
105
105
  required_rubygems_version: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - '>='
107
+ - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  requirements: []
111
- rubyforge_project: addressable
112
- rubygems_version: 2.0.3
111
+ rubygems_version: 3.0.3
113
112
  signing_key:
114
113
  specification_version: 4
115
114
  summary: URI Implementation
data/tasks/rubyforge.rake DELETED
@@ -1,73 +0,0 @@
1
- namespace :gem do
2
- desc 'Package and upload to RubyForge'
3
- task :release => ["gem:package", "gem:gemspec"] do |t|
4
- require 'rubyforge'
5
-
6
- v = ENV['VERSION'] or abort 'Must supply VERSION=x.y.z'
7
- abort "Versions don't match #{v} vs #{PROJ.version}" if v != PKG_VERSION
8
- pkg = "pkg/#{GEM_SPEC.full_name}"
9
-
10
- rf = RubyForge.new
11
- rf.configure
12
- puts 'Logging in...'
13
- rf.login
14
-
15
- c = rf.userconfig
16
- changelog = File.open("CHANGELOG.md") { |file| file.read }
17
- c['release_changes'] = changelog
18
- c['preformatted'] = true
19
-
20
- files = ["#{pkg}.tgz", "#{pkg}.zip", "#{pkg}.gem"]
21
-
22
- puts "Releasing #{PKG_NAME} v. #{PKG_VERSION}"
23
- rf.add_release RUBY_FORGE_PROJECT, PKG_NAME, PKG_VERSION, *files
24
- end
25
- end
26
-
27
- namespace :spec do
28
- desc "Publish specdoc to RubyForge"
29
- task :release => ["spec:specdoc"] do
30
- require "rake/contrib/sshpublisher"
31
- require "yaml"
32
-
33
- config = YAML.load(
34
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
35
- )
36
- host = "#{config['username']}@rubyforge.org"
37
- remote_dir = RUBY_FORGE_PATH + "/specdoc"
38
- local_dir = "specdoc"
39
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
40
- end
41
-
42
- namespace :rcov do
43
- desc "Publish coverage report to RubyForge"
44
- task :release => ["spec:rcov"] do
45
- require "rake/contrib/sshpublisher"
46
- require "yaml"
47
-
48
- config = YAML.load(
49
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
50
- )
51
- host = "#{config['username']}@rubyforge.org"
52
- remote_dir = RUBY_FORGE_PATH + "/coverage"
53
- local_dir = "coverage"
54
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
55
- end
56
- end
57
- end
58
-
59
- namespace :website do
60
- desc "Publish website to RubyForge"
61
- task :release => ["doc:release", "spec:release", "spec:rcov:release"] do
62
- require "rake/contrib/sshpublisher"
63
- require "yaml"
64
-
65
- config = YAML.load(
66
- File.read(File.expand_path('~/.rubyforge/user-config.yml'))
67
- )
68
- host = "#{config['username']}@rubyforge.org"
69
- remote_dir = RUBY_FORGE_PATH
70
- local_dir = "website"
71
- Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
72
- end
73
- end
data/website/index.html DELETED
@@ -1,110 +0,0 @@
1
- <!DOCTYPE html>
2
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3
- <head>
4
- <meta charset="utf-8"/>
5
- <title>Addressable</title>
6
- <style type="text/css">
7
- * {
8
- font-size: 100%;
9
- margin: 0;
10
- padding: 0;
11
- }
12
-
13
- body {
14
- font-family: lucida grande, verdana, sans-serif;
15
- margin: 1em;
16
- }
17
-
18
- a {
19
- color: #880000;
20
- }
21
-
22
- a:visited {
23
- color: #333333;
24
- }
25
-
26
- h1 {
27
- font-size: 2em;
28
- margin: 0 0 0.8em 0;
29
- text-align: center;
30
- }
31
-
32
- h2 {
33
- font-size: 1em;
34
- margin: 0.8em 0;
35
- }
36
-
37
- p {
38
- margin: 0.8em 0;
39
- }
40
-
41
- ul {
42
- font-size: 0.9em;
43
- margin: 0 0 0 1.5em;
44
- }
45
-
46
- div {
47
- width: 50%;
48
- margin: 0 auto;
49
- padding: 0.8em;
50
- background-color: #AA5852;
51
- border: 2px solid #C2645D;
52
- }
53
-
54
- @media print {
55
- body {
56
- font-size: 0.9em;
57
- }
58
-
59
- a {
60
- text-decoration: none;
61
- color: #000;
62
- }
63
- }
64
- </style>
65
- </head>
66
- <body>
67
- <h1>Addressable</h1>
68
- <div>
69
- <p>
70
- Addressable is a replacement for the URI implementation that is part
71
- of Ruby's standard library. It more closely conforms to the relevant
72
- RFCs and adds support for IRIs and URI templates.
73
- </p>
74
- <ul>
75
- <li>
76
- <a href="http://rubyforge.org/projects/addressable/">
77
- Project Page
78
- </a>
79
- </li>
80
- <li>
81
- <a href="http://github.com/sporkmonger/addressable">
82
- GitHub Page
83
- </a>
84
- </li>
85
- <li><a href="http://rubydoc.info/gems/addressable">API</a></li>
86
- <li><a href="/specdoc/">Specifications</a></li>
87
- <li><a href="/coverage/">Code Coverage</a></li>
88
- </ul>
89
- <p>
90
- You know what to do:
91
- </p>
92
- <p>
93
- <code>sudo gem install addressable</code>
94
- </p>
95
- <p>
96
- Alternatively, you can:
97
- </p>
98
- <p>
99
- <code>
100
- git submodule add
101
- git://github.com/sporkmonger/addressable.git
102
- vendor/gems/addressable
103
- </code>
104
- </p>
105
- <p>
106
- Addressable works in Ruby 1.8.x, 1.9.x, and JRuby.
107
- </p>
108
- </div>
109
- </body>
110
- </html>