http-cookie 1.0.8 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 143890479b8951250d5f45d4528c390e03741d943269abe0901e091b544f95ca
4
- data.tar.gz: 7bfef9e1bd7cd6cb01f0de248717fade7a1871fb120cd35227657a96c371d384
3
+ metadata.gz: 72ef3493437238f93258320d1e8bdfea5d155e731ed6e88d55b284bff3c7a3a0
4
+ data.tar.gz: ecf432149b7b13a7437ad6c8a8433b85fbe4cf223ba07016831c2da3a8598de2
5
5
  SHA512:
6
- metadata.gz: ba03e3c618d888517bc4bb9e95c08cf4c89bbe5a9ec075d31dcaba353d8864b338fe79bf7ad36f45d6e87a114eefabe41ed62a7b62876c3ba55f459e022fb24f
7
- data.tar.gz: 846fa3243f97982df9b196fbc0645d13cd233105bbaa98e2e42b36f5a95b58c07d7571c213c6b35034b4ea41f1ce415857aabbbfe20042305611608fa3d327df
6
+ metadata.gz: 110ace005f635800820a73c4c4955cdd0d80fdfddf781949957f2738e0bd7d78068c5d03537f9defa7eba25b7f8156e823897460cd3bf84db8fd7dff55550cd2
7
+ data.tar.gz: c20f7c2409b86773bcf93367d135058dea7bf52f7fe3ef240161be0b137d2dce9ced8fc4e8398353b876c469edaebcdecc2e7cba77f92795972e6472a8f13959
data/CHANGELOG.md CHANGED
@@ -1,3 +1,42 @@
1
+ ## 1.1.6 (2026-04-20)
2
+
3
+ - Use `autoload` to avoid "circular require" warnings between `http/cookie` and `http/cookie_jar`. (#65)
4
+
5
+
6
+ ## 1.1.5 (2026-04-19)
7
+
8
+ - Fix `NameError: uninitialized constant HTTP::Cookie::MAX_COOKIES_TOTAL` when `http/cookie_jar` is required without `http/cookie`, as done by the `http` gem. (#62)
9
+
10
+
11
+ ## 1.1.4 (2026-04-07)
12
+
13
+ - Fix `require "http/cookie_jar"` raising `NameError: uninitialized constant HTTP`. (#61)
14
+
15
+
16
+ ## 1.1.3 (2026-04-06)
17
+
18
+ - Restore compatibility with Ruby 2.6.
19
+
20
+
21
+ ## 1.1.2 (2026-04-06)
22
+
23
+ - Stop requiring sqlite3 at load time by changing `MozillaStore::Database` from inheritance to composition.
24
+
25
+
26
+ ## 1.1.1 (2026-04-06)
27
+
28
+ - Fix thread-unsafe runtime requires. (#43 by @brasic, #57)
29
+ - Replace `require 'cgi'` with `require 'cgi/escape'` to suppress Ruby 4.0 warning. (#56 by @dominion525)
30
+ - Do not define `MozillaStore` on JRuby; leave the constant undefined instead.
31
+ - Relax sqlite3 development dependency to `>= 1.3`.
32
+
33
+
34
+ ## 1.1.0 (2025-09-26)
35
+
36
+ - Implement `Cookie#to_h`. (#55) @luke-hill @flavorjones
37
+ - Reduce gem size by excluding test files (#54) @yuri-zubov
38
+
39
+
1
40
  ## 1.0.8 (2024-12-05)
2
41
 
3
42
  - `Cookie#expires=` accepts `DateTime` objects. (#52) @luke-hill @flavorjones
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 Akinori MUSHA
1
+ Copyright (c) 2013-2026 Akinori MUSHA
2
2
  Copyright (c) 2011-2012 Akinori MUSHA, Eric Hodel
3
3
  Copyright (c) 2006-2011 Aaron Patterson, Mike Dalessio
4
4
 
@@ -1,5 +1,5 @@
1
1
  module HTTP
2
2
  class Cookie
3
- VERSION = "1.0.8"
3
+ VERSION = "1.1.6"
4
4
  end
5
5
  end
data/lib/http/cookie.rb CHANGED
@@ -6,7 +6,7 @@ require 'time'
6
6
  require 'uri'
7
7
  require 'domain_name'
8
8
  require 'http/cookie/ruby_compat'
9
- require 'cgi'
9
+ require 'cgi/escape'
10
10
 
11
11
  module HTTP
12
12
  autoload :CookieJar, 'http/cookie_jar'
@@ -655,6 +655,11 @@ class HTTP::Cookie
655
655
  end
656
656
  include Comparable
657
657
 
658
+ # Hash serialization helper for use back into other libraries (Like Selenium)
659
+ def to_h
660
+ PERSISTENT_PROPERTIES.each_with_object({}) { |property, hash| hash[property.to_sym] = instance_variable_get("@#{property}") }
661
+ end
662
+
658
663
  # YAML serialization helper for Syck.
659
664
  def to_yaml_properties
660
665
  PERSISTENT_PROPERTIES.map { |name| "@#{name}" }
@@ -2,29 +2,15 @@
2
2
 
3
3
  # An abstract superclass for all saver classes.
4
4
  class HTTP::CookieJar::AbstractSaver
5
- class << self
6
- @@class_map = {}
7
5
 
8
- # Gets an implementation class by the name, optionally trying to
9
- # load "http/cookie_jar/*_saver" if not found. If loading fails,
10
- # IndexError is raised.
11
- def implementation(symbol)
12
- @@class_map.fetch(symbol)
13
- rescue IndexError
14
- begin
15
- require 'http/cookie_jar/%s_saver' % symbol
16
- @@class_map.fetch(symbol)
17
- rescue LoadError, IndexError
18
- raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
19
- end
20
- end
21
-
22
- def inherited(subclass) # :nodoc:
23
- @@class_map[class_to_symbol(subclass)] = subclass
24
- end
25
-
26
- def class_to_symbol(klass) # :nodoc:
27
- klass.name[/[^:]+?(?=Saver$|$)/].downcase.to_sym
6
+ def self.implementation(symbol)
7
+ case symbol
8
+ when :yaml
9
+ HTTP::CookieJar::YAMLSaver
10
+ when :cookiestxt
11
+ HTTP::CookieJar::CookiestxtSaver
12
+ else
13
+ raise IndexError, 'cookie saver unavailable: %s' % symbol.inspect
28
14
  end
29
15
  end
30
16
 
@@ -63,3 +49,6 @@ class HTTP::CookieJar::AbstractSaver
63
49
  # self
64
50
  end
65
51
  end
52
+
53
+ require "http/cookie_jar/yaml_saver"
54
+ require "http/cookie_jar/cookiestxt_saver"
@@ -6,29 +6,18 @@ class HTTP::CookieJar::AbstractStore
6
6
  include MonitorMixin
7
7
 
8
8
  class << self
9
- @@class_map = {}
10
9
 
11
- # Gets an implementation class by the name, optionally trying to
12
- # load "http/cookie_jar/*_store" if not found. If loading fails,
13
- # IndexError is raised.
10
+ # Gets an implementation class by the name.
14
11
  def implementation(symbol)
15
- @@class_map.fetch(symbol)
16
- rescue IndexError
17
- begin
18
- require 'http/cookie_jar/%s_store' % symbol
19
- @@class_map.fetch(symbol)
20
- rescue LoadError, IndexError => e
21
- raise IndexError, 'cookie store unavailable: %s, error: %s' % [symbol.inspect, e.message]
12
+ case symbol
13
+ when :hash
14
+ HTTP::CookieJar::HashStore
15
+ when :mozilla
16
+ HTTP::CookieJar::MozillaStore
17
+ else
18
+ raise IndexError, 'cookie store unavailable: %s' % symbol.inspect
22
19
  end
23
20
  end
24
-
25
- def inherited(subclass) # :nodoc:
26
- @@class_map[class_to_symbol(subclass)] = subclass
27
- end
28
-
29
- def class_to_symbol(klass) # :nodoc:
30
- klass.name[/[^:]+?(?=Store$|$)/].downcase.to_sym
31
- end
32
21
  end
33
22
 
34
23
  # Defines options and their default values.
@@ -122,3 +111,9 @@ class HTTP::CookieJar::AbstractStore
122
111
  # self
123
112
  end
124
113
  end
114
+
115
+ require 'http/cookie_jar/hash_store'
116
+
117
+ unless defined?(JRUBY_VERSION)
118
+ require 'http/cookie_jar/mozilla_store'
119
+ end
@@ -1,5 +1,4 @@
1
1
  # :markup: markdown
2
- require 'http/cookie_jar'
3
2
 
4
3
  # CookiestxtSaver saves and loads cookies in the cookies.txt format.
5
4
  class HTTP::CookieJar::CookiestxtSaver < HTTP::CookieJar::AbstractSaver
@@ -1,5 +1,4 @@
1
1
  # :markup: markdown
2
- require 'http/cookie_jar'
3
2
 
4
3
  class HTTP::CookieJar
5
4
  # A store class that uses a hash-based cookie store.
@@ -1,6 +1,5 @@
1
1
  # :markup: markdown
2
- require 'http/cookie_jar'
3
- require 'sqlite3'
2
+ autoload :SQLite3, 'sqlite3'
4
3
 
5
4
  class HTTP::CookieJar
6
5
  # A store class that uses Mozilla compatible SQLite3 database as
@@ -38,20 +37,15 @@ class HTTP::CookieJar
38
37
  }
39
38
  }
40
39
 
41
- class Database < SQLite3::Database
42
- def initialize(file, options = {})
40
+ class Database
41
+ def initialize(file)
42
+ @db = SQLite3::Database.new(file, results_as_hash: true)
43
43
  @stmts = []
44
- options = {
45
- :results_as_hash => true,
46
- }.update(options)
47
- super
48
44
  end
49
45
 
50
46
  def prepare(sql)
51
- case st = super
52
- when SQLite3::Statement
53
- @stmts << st
54
- end
47
+ st = @db.prepare(sql)
48
+ @stmts << st if st.is_a?(SQLite3::Statement)
55
49
  st
56
50
  end
57
51
 
@@ -60,7 +54,19 @@ class HTTP::CookieJar
60
54
  @stmts.reject! { |st|
61
55
  st.closed? || st.close
62
56
  }
63
- super
57
+ @db.close
58
+ end
59
+
60
+ def closed?
61
+ @db.closed?
62
+ end
63
+
64
+ def execute(*args, &block)
65
+ @db.execute(*args, &block)
66
+ end
67
+
68
+ def create_function(*args, &block)
69
+ @db.create_function(*args, &block)
64
70
  end
65
71
  end
66
72
  # :startdoc:
@@ -1,7 +1,5 @@
1
1
  # :markup: markdown
2
- require 'http/cookie_jar'
3
- require 'psych' if !defined?(YAML) && RUBY_VERSION == "1.9.2"
4
- require 'yaml'
2
+ autoload :YAML, 'yaml'
5
3
 
6
4
  # YAMLSaver saves and loads cookies in the YAML format. It can load a
7
5
  # YAML file saved by Mechanize, but the saving format is not
@@ -74,13 +72,9 @@ class HTTP::CookieJar::YAMLSaver < HTTP::CookieJar::AbstractSaver
74
72
  {}
75
73
  end
76
74
 
77
- if YAML.name == 'Psych' && Psych::VERSION >= '3.1'
78
- def load_yaml(yaml)
79
- YAML.safe_load(yaml, :permitted_classes => %w[Time HTTP::Cookie Mechanize::Cookie DomainName], :aliases => true)
80
- end
81
- else
82
- def load_yaml(yaml)
83
- YAML.load(yaml)
84
- end
75
+ def load_yaml(yaml)
76
+ YAML.safe_load(yaml, :permitted_classes => %w[Time HTTP::Cookie Mechanize::Cookie DomainName], :aliases => true)
77
+ rescue NoMethodError # ruby < 2.0, no safe_load
78
+ YAML.load(yaml)
85
79
  end
86
80
  end
@@ -1,31 +1,14 @@
1
1
  # :markup: markdown
2
- require 'http/cookie'
2
+
3
+ module HTTP
4
+ autoload :Cookie, "http/cookie"
5
+ end
3
6
 
4
7
  ##
5
8
  # This class is used to manage the Cookies that have been returned from
6
9
  # any particular website.
7
10
 
8
11
  class HTTP::CookieJar
9
- class << self
10
- def const_missing(name)
11
- case name.to_s
12
- when /\A([A-Za-z]+)Store\z/
13
- file = 'http/cookie_jar/%s_store' % $1.downcase
14
- when /\A([A-Za-z]+)Saver\z/
15
- file = 'http/cookie_jar/%s_saver' % $1.downcase
16
- end
17
- begin
18
- require file
19
- rescue LoadError
20
- raise NameError, 'can\'t resolve constant %s; failed to load %s' % [name, file]
21
- end
22
- if const_defined?(name)
23
- const_get(name)
24
- else
25
- raise NameError, 'can\'t resolve constant %s after loading %s' % [name, file]
26
- end
27
- end
28
- end
29
12
 
30
13
  attr_reader :store
31
14
 
@@ -342,3 +325,6 @@ class HTTP::CookieJar
342
325
  self
343
326
  end
344
327
  end
328
+
329
+ require 'http/cookie_jar/abstract_store'
330
+ require 'http/cookie_jar/abstract_saver'
data/lib/http-cookie.rb CHANGED
@@ -1 +1,4 @@
1
- require 'http/cookie'
1
+ module HTTP
2
+ autoload :Cookie, 'http/cookie'
3
+ autoload :CookieJar, 'http/cookie_jar'
4
+ end
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-cookie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori MUSHA
8
8
  - Aaron Patterson
9
9
  - Eric Hodel
10
10
  - Mike Dalessio
11
- autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2024-12-05 00:00:00.000000000 Z
13
+ date: 1980-01-02 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: domain_name
@@ -31,14 +30,14 @@ dependencies:
31
30
  name: sqlite3
32
31
  requirement: !ruby/object:Gem::Requirement
33
32
  requirements:
34
- - - "~>"
33
+ - - ">="
35
34
  - !ruby/object:Gem::Version
36
35
  version: '1.3'
37
36
  type: :development
38
37
  prerelease: false
39
38
  version_requirements: !ruby/object:Gem::Requirement
40
39
  requirements:
41
- - - "~>"
40
+ - - ">="
42
41
  - !ruby/object:Gem::Version
43
42
  version: '1.3'
44
43
  - !ruby/object:Gem::Dependency
@@ -124,18 +123,12 @@ email:
124
123
  executables: []
125
124
  extensions: []
126
125
  extra_rdoc_files:
127
- - README.md
128
126
  - LICENSE.txt
127
+ - README.md
129
128
  files:
130
- - ".github/CODEOWNERS"
131
- - ".github/workflows/ci.yml"
132
- - ".gitignore"
133
129
  - CHANGELOG.md
134
- - Gemfile
135
130
  - LICENSE.txt
136
131
  - README.md
137
- - Rakefile
138
- - http-cookie.gemspec
139
132
  - lib/http-cookie.rb
140
133
  - lib/http/cookie.rb
141
134
  - lib/http/cookie/ruby_compat.rb
@@ -149,16 +142,10 @@ files:
149
142
  - lib/http/cookie_jar/hash_store.rb
150
143
  - lib/http/cookie_jar/mozilla_store.rb
151
144
  - lib/http/cookie_jar/yaml_saver.rb
152
- - test/helper.rb
153
- - test/mechanize.yml
154
- - test/simplecov_start.rb
155
- - test/test_http_cookie.rb
156
- - test/test_http_cookie_jar.rb
157
145
  homepage: https://github.com/sparklemotion/http-cookie
158
146
  licenses:
159
147
  - MIT
160
148
  metadata: {}
161
- post_install_message:
162
149
  rdoc_options: []
163
150
  require_paths:
164
151
  - lib
@@ -173,13 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
160
  - !ruby/object:Gem::Version
174
161
  version: '0'
175
162
  requirements: []
176
- rubygems_version: 3.5.22
177
- signing_key:
163
+ rubygems_version: 4.0.6
178
164
  specification_version: 4
179
165
  summary: A Ruby library to handle HTTP Cookies based on RFC 6265
180
- test_files:
181
- - test/helper.rb
182
- - test/mechanize.yml
183
- - test/simplecov_start.rb
184
- - test/test_http_cookie.rb
185
- - test/test_http_cookie_jar.rb
166
+ test_files: []
data/.github/CODEOWNERS DELETED
@@ -1 +0,0 @@
1
- * @knu
@@ -1,37 +0,0 @@
1
- name: CI
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request:
8
- branches:
9
- - "*"
10
-
11
- jobs:
12
- test:
13
- strategy:
14
- fail-fast: false
15
- matrix:
16
- os: [ubuntu]
17
- # We still kind of support Ruby 1.8.7
18
- ruby: ["2.7", "3.0", "3.1", "3.2", "3.3", "head", "jruby"]
19
-
20
- name: >-
21
- ${{matrix.os}}:ruby-${{matrix.ruby}}
22
- runs-on: ${{matrix.os}}-latest
23
- continue-on-error: ${{matrix.ruby == 'head' || matrix.ruby == 'jruby'}}
24
-
25
- steps:
26
- - name: Check out
27
- uses: actions/checkout@v4
28
-
29
- - name: Set up ruby and bundle
30
- uses: ruby/setup-ruby@v1
31
- with:
32
- ruby-version: ${{matrix.ruby}}
33
- bundler-cache: true
34
-
35
- - name: Run rake
36
- run: |
37
- bundle exec rake
data/.gitignore DELETED
@@ -1,17 +0,0 @@
1
- *.gem
2
- *.rbc
3
- .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in http-cookie.gemspec
4
- gemspec
data/Rakefile DELETED
@@ -1,20 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:test) do |test|
5
- test.ruby_opts << '-r./test/simplecov_start.rb' if RUBY_VERSION >= '1.9'
6
- test.pattern = 'test/**/test_*.rb'
7
- test.verbose = true
8
- end
9
-
10
- task :default => :test
11
-
12
- require 'rdoc/task'
13
- Rake::RDocTask.new do |rdoc|
14
- version = HTTP::Cookie::VERSION
15
-
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = "http-cookie #{version}"
18
- rdoc.rdoc_files.include('lib/**/*.rb')
19
- rdoc.rdoc_files.include(Bundler::GemHelper.gemspec.extra_rdoc_files)
20
- end
data/http-cookie.gemspec DELETED
@@ -1,35 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'http/cookie/version'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.name = "http-cookie"
8
- gem.version = HTTP::Cookie::VERSION
9
- gem.authors, gem.email = {
10
- 'Akinori MUSHA' => 'knu@idaemons.org',
11
- 'Aaron Patterson' => 'aaronp@rubyforge.org',
12
- 'Eric Hodel' => 'drbrain@segment7.net',
13
- 'Mike Dalessio' => 'mike.dalessio@gmail.com',
14
- }.instance_eval { [keys, values] }
15
-
16
- gem.description = %q{HTTP::Cookie is a Ruby library to handle HTTP Cookies based on RFC 6265. It has with security, standards compliance and compatibility in mind, to behave just the same as today's major web browsers. It has builtin support for the legacy cookies.txt and the latest cookies.sqlite formats of Mozilla Firefox, and its modular API makes it easy to add support for a new backend store.}
17
- gem.summary = %q{A Ruby library to handle HTTP Cookies based on RFC 6265}
18
- gem.homepage = "https://github.com/sparklemotion/http-cookie"
19
- gem.license = "MIT"
20
-
21
- gem.files = `git ls-files`.split($/)
22
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
23
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
24
- gem.require_paths = ["lib"]
25
- gem.extra_rdoc_files = ['README.md', 'LICENSE.txt']
26
-
27
- gem.add_runtime_dependency("domain_name", ["~> 0.5"])
28
- gem.add_development_dependency("sqlite3", ["~> 1.3"]) unless defined?(JRUBY_VERSION)
29
- gem.add_development_dependency("bundler", [">= 1.2.0"])
30
- gem.add_development_dependency("test-unit", [">= 2.4.3", *("< 3" if RUBY_VERSION < "1.9")])
31
- gem.add_development_dependency("rake", [">= 0.9.2.2", *("< 11" if RUBY_VERSION < "1.9")])
32
- gem.add_development_dependency("rdoc", RUBY_VERSION > "1.9" ? "> 2.4.2" : "~> 2.4.2")
33
- gem.add_development_dependency("simplecov", [">= 0"])
34
- gem.add_development_dependency("json", ["< 2"]) if RUBY_VERSION < "2.0"
35
- end
data/test/helper.rb DELETED
@@ -1,55 +0,0 @@
1
- require 'rubygems'
2
- require 'test-unit'
3
- require 'uri'
4
- require 'http/cookie'
5
-
6
- module Test
7
- module Unit
8
- module Assertions
9
- def assert_warn(pattern, message = nil, &block)
10
- class << (output = +"")
11
- alias write <<
12
- end
13
- stderr, $stderr = $stderr, output
14
- yield
15
- assert_match(pattern, output, message)
16
- ensure
17
- $stderr = stderr
18
- end
19
-
20
- def assert_warning(pattern, message = nil, &block)
21
- verbose, $VERBOSE = $VERBOSE, true
22
- assert_warn(pattern, message, &block)
23
- ensure
24
- $VERBOSE = verbose
25
- end
26
- end
27
- end
28
- end
29
-
30
- module Enumerable
31
- def combine
32
- masks = inject([[], 1]){|(ar, m), e| [ar << m, m << 1 ] }[0]
33
- all = masks.inject(0){ |al, m| al|m }
34
-
35
- result = []
36
- for i in 1..all do
37
- tmp = []
38
- each_with_index do |e, idx|
39
- tmp << e unless (masks[idx] & i) == 0
40
- end
41
- result << tmp
42
- end
43
- result
44
- end
45
- end
46
-
47
- def test_file(filename)
48
- File.expand_path(filename, File.dirname(__FILE__))
49
- end
50
-
51
- def sleep_until(time)
52
- if (s = time - Time.now) > 0
53
- sleep s + 0.01
54
- end
55
- end