date_values 0.1.2 → 0.1.3

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: 76e212d3b12d520ef70a3072bb307cfec021b1f4a09fae4a03b75df64e8c2dcd
4
- data.tar.gz: 7e230882c9b6cd8ea7147195143a0802a6f15c9cfcea6e04578edcd3235494ba
3
+ metadata.gz: 18c625b8766c99ee4e063b2d2b756f68702d7468301cf0e14cb61c29647bc97e
4
+ data.tar.gz: cc21e80e920a5590109a62894d362b541f5f7362835f7d5113980b20bc28842f
5
5
  SHA512:
6
- metadata.gz: 9bdf4015dd33168d98fb6bdd3885e42ccb7a880862b67f400ca2c5fc394afad08a42b20f7af820548ecb482f178e128e0f6ee81893de90ce39ed9b2d1b9f9f64
7
- data.tar.gz: 49b14bf137cd2139ade667faf3ffb6d2b3890830aa63f8f66138ca55ad5ed792570a0186dbcbcfa2f57876c3402bb29875b97087645610753af0f3f5621bfa4d
6
+ metadata.gz: 3ea359a67138a64040d1fc62a9288c3862665f636db9e1651697ec6527390e1e53cb002f87745df2189b8eba8944f104e127b620af032be0e92d5a5d707f77a2
7
+ data.tar.gz: f5a8b524c53566ee986a3eea6bf28d08e889a428d15b7ae48f04443d46108ee7b882391adc82bc597af10338ef071ec9ecb83dc6812718d67ef332c5065432eb
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2026-03-20
4
+
5
+ - Fix ActiveRecord type registration — use `ActiveSupport.on_load(:active_record)` to register types regardless of load order
6
+ - Values now work directly in ActiveRecord queries (`Shop.where(billing_month: YearMonth.new(2026, 3))`)
7
+
3
8
  ## [0.1.2] - 2026-03-19
4
9
 
5
10
  - Add `#strftime` to `YearMonth`, `MonthDay`, and `TimeOfDay`
data/README.md CHANGED
@@ -43,8 +43,12 @@ md = MonthDay.new(3, 19)
43
43
  md.to_s # => "--03-19"
44
44
  md.to_date(2026) # => #<Date: 2026-03-19>
45
45
 
46
- MonthDay.from(Date.today) # => MonthDay[--03-19]
46
+ MonthDay.from(Date.today) # => MonthDay[--03-20]
47
47
  MonthDay.parse('--03-19') # => MonthDay[--03-19]
48
+
49
+ # Range membership
50
+ summer = MonthDay.new(6, 1)..MonthDay.new(8, 31)
51
+ summer.cover?(MonthDay.new(7, 15)) # => true
48
52
  ```
49
53
 
50
54
  ### TimeOfDay
@@ -57,6 +61,10 @@ TimeOfDay.new(14, 30, 45).to_s # => "14:30:45"
57
61
 
58
62
  TimeOfDay.from(Time.now) # => TimeOfDay[14:30]
59
63
  TimeOfDay.parse('14:30') # => TimeOfDay[14:30]
64
+
65
+ # Range membership
66
+ business_hours = TimeOfDay.new(9, 0)..TimeOfDay.new(17, 0)
67
+ business_hours.cover?(TimeOfDay.new(12, 30)) # => true
60
68
  ```
61
69
 
62
70
  ### Pattern Matching
@@ -94,6 +102,13 @@ class Shop < ApplicationRecord
94
102
  end
95
103
  ```
96
104
 
105
+ Values are automatically serialized in queries:
106
+
107
+ ```ruby
108
+ Shop.where(billing_month: YearMonth.new(2026, 3))
109
+ # SELECT * FROM shops WHERE billing_month = '2026-03'
110
+ ```
111
+
97
112
  ### I18n / `l` Helper
98
113
 
99
114
  All classes implement `#strftime`, and the Rails integration extends `I18n.l` to support them. Define formats in your locale files:
@@ -12,4 +12,10 @@ ActiveModel::Type.register(:year_month, DateValues::Rails::YearMonthType)
12
12
  ActiveModel::Type.register(:month_day, DateValues::Rails::MonthDayType)
13
13
  ActiveModel::Type.register(:time_of_day, DateValues::Rails::TimeOfDayType)
14
14
 
15
+ ActiveSupport.on_load(:active_record) do
16
+ ActiveRecord::Type.register(:year_month, DateValues::Rails::YearMonthType)
17
+ ActiveRecord::Type.register(:month_day, DateValues::Rails::MonthDayType)
18
+ ActiveRecord::Type.register(:time_of_day, DateValues::Rails::TimeOfDayType)
19
+ end
20
+
15
21
  I18n::Backend::Base.prepend(DateValues::Rails::I18nBackend)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DateValues
4
- VERSION = '0.1.2'
4
+ VERSION = '0.1.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: date_values
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keita Urashima