http-cookie 1.0.7 → 1.0.8

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: 73ca2100bbc196d47cf762d39b5bf250912d7f90c8643ad6a20fba10a34571ed
4
- data.tar.gz: 0b1fa5d6681c58d4139c3a28ab1a8f820dd6ce152c28f81e11a8bdcb75606fac
3
+ metadata.gz: 143890479b8951250d5f45d4528c390e03741d943269abe0901e091b544f95ca
4
+ data.tar.gz: 7bfef9e1bd7cd6cb01f0de248717fade7a1871fb120cd35227657a96c371d384
5
5
  SHA512:
6
- metadata.gz: dfbbf53e6bfdc11b450e4b050239dfc97ec77012db0a7c0a713fb22833ab1d22fb69b2f75adc0bf2ad0a06e7aba97ec7af9d8469c8f36dcbcf8f563ea61f574d
7
- data.tar.gz: '068c842134bf04dd257dd14b5beb607dea401bd88f72ccef669ca96ceff065b7989b86abda3a8a24699844b7f8e8bbaf4cc711da43dcd0e3755a88aec0b5a6b5'
6
+ metadata.gz: ba03e3c618d888517bc4bb9e95c08cf4c89bbe5a9ec075d31dcaba353d8864b338fe79bf7ad36f45d6e87a114eefabe41ed62a7b62876c3ba55f459e022fb24f
7
+ data.tar.gz: 846fa3243f97982df9b196fbc0645d13cd233105bbaa98e2e42b36f5a95b58c07d7571c213c6b35034b4ea41f1ce415857aabbbfe20042305611608fa3d327df
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.0.8 (2024-12-05)
2
+
3
+ - `Cookie#expires=` accepts `DateTime` objects. (#52) @luke-hill @flavorjones
4
+
5
+
1
6
  ## 1.0.7 (2024-06-06)
2
7
 
3
8
  - Explicitly require "cgi" to avoid `NameError` in some applications. (#50 by @flavorjones)
@@ -1,5 +1,5 @@
1
1
  module HTTP
2
2
  class Cookie
3
- VERSION = "1.0.7"
3
+ VERSION = "1.0.8"
4
4
  end
5
5
  end
data/lib/http/cookie.rb CHANGED
@@ -89,7 +89,7 @@ class HTTP::Cookie
89
89
 
90
90
  # The Expires attribute value as a Time object.
91
91
  #
92
- # The setter method accepts a Time object, a string representation
92
+ # The setter method accepts a Time / DateTime object, a string representation
93
93
  # of date/time that Time.parse can understand, or `nil`.
94
94
  #
95
95
  # Setting this value resets #max_age to nil. When #max_age is
@@ -493,6 +493,8 @@ class HTTP::Cookie
493
493
  def expires= t
494
494
  case t
495
495
  when nil, Time
496
+ when DateTime
497
+ t = t.to_time
496
498
  else
497
499
  t = Time.parse(t)
498
500
  end
@@ -717,8 +717,22 @@ class TestHTTPCookie < Test::Unit::TestCase
717
717
  end
718
718
 
719
719
  def test_expiration
720
- cookie = HTTP::Cookie.new(cookie_values)
720
+ expires = Time.now + 86400
721
+ cookie = HTTP::Cookie.new(cookie_values(expires: expires))
722
+
723
+ assert_equal(expires, cookie.expires)
724
+ assert_equal false, cookie.expired?
725
+ assert_equal true, cookie.expired?(cookie.expires + 1)
726
+ assert_equal false, cookie.expired?(cookie.expires - 1)
727
+ cookie.expire!
728
+ assert_equal true, cookie.expired?
729
+ end
730
+
731
+ def test_expiration_using_datetime
732
+ expires = DateTime.now + 1
733
+ cookie = HTTP::Cookie.new(cookie_values(expires: expires))
721
734
 
735
+ assert_equal(expires.to_time, cookie.expires)
722
736
  assert_equal false, cookie.expired?
723
737
  assert_equal true, cookie.expired?(cookie.expires + 1)
724
738
  assert_equal false, cookie.expired?(cookie.expires - 1)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http-cookie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akinori MUSHA
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2024-08-14 00:00:00.000000000 Z
14
+ date: 2024-12-05 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: domain_name
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0'
175
175
  requirements: []
176
- rubygems_version: 3.5.11
176
+ rubygems_version: 3.5.22
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: A Ruby library to handle HTTP Cookies based on RFC 6265