verified_holidays 0.3.1 → 0.3.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: c9c851b992fdefecb26db75afbe6c4c04d289ad871e355e481d224fb6218f938
4
- data.tar.gz: bcb850940dc6a86e5b72d877765377e1614f26b92b6848588f45a015d3bbaeec
3
+ metadata.gz: 6daf6bd2f68005f635e997644c83097605f8a3716ea49decc9f756fb020be27a
4
+ data.tar.gz: 3c7d1e1cdf6a4e7514951e8f6f21dd6a229c17ad2ff201c18793e7af911f1f94
5
5
  SHA512:
6
- metadata.gz: 341026a59a66206f49f91ac8028abc5f9f780541a3283f17449dee6f630020354e6a208f7f9eec8aed9e1181d658645ef657f013754d28ab967e7483595d62ab
7
- data.tar.gz: 8f67f420814c7bfbbc089604522b331656dc5b27432a9c6899b5267abb9a0eb3eabdb1cc1320c120f46167c34752aa737bf9e3fd10d971eb2aca46ec6c22b6e6
6
+ metadata.gz: 924ed9a8aa2469bac79d3ae9912eb9f042309a8c32b7111d6f3f8a72671bfdd1d10f1d12f7141590e7a1162bbbf6920e430660d42f31e5361a198d085d1beb16
7
+ data.tar.gz: f9459d943472843c129ba579a8e49ec33c2865415cdc0e24725310a3e45cbfca4415bc25119067ab3b04271464e330a6e485e1d092366e2c0df62dc8397a9828
data/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.3.3](https://github.com/verified-holidays/verified_holidays/compare/verified_holidays/v0.3.2...verified_holidays/v0.3.3) (2026-08-22)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * add English names for holidays present in the dataset ([#32](https://github.com/verified-holidays/verified_holidays/issues/32)) ([1f92812](https://github.com/verified-holidays/verified_holidays/commit/1f92812aea09b9f27d6034556f0576997bdac1db))
9
+ * raise FetchError on a non-success Cabinet Office response ([#28](https://github.com/verified-holidays/verified_holidays/issues/28)) ([6d55172](https://github.com/verified-holidays/verified_holidays/commit/6d55172f5eac707e54f5039cf2fbed3ea224af08))
10
+ * reject a Cabinet Office response that holds no holidays ([#30](https://github.com/verified-holidays/verified_holidays/issues/30)) ([9040ff5](https://github.com/verified-holidays/verified_holidays/commit/9040ff5f089dcecfdad827f480cac5950663fc99))
11
+ * use YAML.dump when writing holidays.yml ([#31](https://github.com/verified-holidays/verified_holidays/issues/31)) ([be2879b](https://github.com/verified-holidays/verified_holidays/commit/be2879b143408af0764057c1e83343f6e9235a9c))
12
+
13
+
14
+ ### Miscellaneous
15
+
16
+ * label docs/ branches from the branch prefix ([#33](https://github.com/verified-holidays/verified_holidays/issues/33)) ([b6867f6](https://github.com/verified-holidays/verified_holidays/commit/b6867f6febe29cfc06d423a4b94a948287437c2e))
17
+ * point the tests label at test/ instead of spec/ ([#35](https://github.com/verified-holidays/verified_holidays/issues/35)) ([f86d05b](https://github.com/verified-holidays/verified_holidays/commit/f86d05b29643c5bdb191aef8b17c72a1874b6f39))
18
+
19
+ ## [0.3.2](https://github.com/verified-holidays/verified_holidays/compare/verified_holidays/v0.3.1...verified_holidays/v0.3.2) (2026-08-22)
20
+
21
+
22
+ ### Miscellaneous
23
+
24
+ * write source comments in English ([#26](https://github.com/verified-holidays/verified_holidays/issues/26)) ([aa1879f](https://github.com/verified-holidays/verified_holidays/commit/aa1879f993affaf651f4b8d56277964c617b1f35))
25
+
3
26
  ## [0.3.1](https://github.com/verified-holidays/verified_holidays/compare/verified_holidays/v0.3.0...verified_holidays/v0.3.1) (2026-04-28)
4
27
 
5
28
 
data/README.md CHANGED
@@ -54,11 +54,11 @@ VerifiedHolidays.year(2026)
54
54
 
55
55
  ```ruby
56
56
  holiday = VerifiedHolidays.between(Date.new(2026, 1, 1), Date.new(2026, 1, 1)).first
57
- holiday.date # => #<Date: 2026-01-01>
58
- holiday.name # => "元日"
59
- holiday.name_en # => "New Year's Day"
60
- holiday.wday_name # => "Thursday"
61
- holiday.week # => "Thursday" (alias for wday_name)
57
+ holiday.date # => #<Date: 2026-01-01>
58
+ holiday.name # => "元日"
59
+ holiday.name_en # => "New Year's Day"
60
+ holiday.wday_name # => ""
61
+ holiday.week # => "" (alias for wday_name)
62
62
  ```
63
63
 
64
64
  ## Compatibility with holiday_jp
@@ -85,6 +85,11 @@ result.extra # => entries in Cabinet Office CSV but not in local data
85
85
  result.mismatched # => entries with different names
86
86
  ```
87
87
 
88
+ If the Cabinet Office responds with anything other than success — an outage, a
89
+ moved file, a redirect — or answers with something that holds no holidays at
90
+ all, `verify!` raises `VerifiedHolidays::CabinetOffice::FetchError` rather than
91
+ reporting the data as mismatched.
92
+
88
93
  Or via Rake:
89
94
 
90
95
  ```sh
@@ -9,19 +9,30 @@ module VerifiedHolidays
9
9
  class CabinetOffice
10
10
  CSV_URL = 'https://www8.cao.go.jp/chosei/shukujitsu/syukujitsu.csv'
11
11
 
12
+ # Raised when the Cabinet Office CSV cannot be retrieved.
13
+ class FetchError < StandardError; end
14
+
12
15
  def self.fetch
13
- uri = URI.parse(CSV_URL)
14
- response = Net::HTTP.get(uri)
16
+ holidays = parse(download_csv)
17
+ raise FetchError, "#{CSV_URL} returned no holidays" if holidays.empty?
18
+
19
+ holidays
20
+ end
21
+
22
+ def self.download_csv
23
+ response = Net::HTTP.get_response(URI.parse(CSV_URL))
24
+ unless response.is_a?(Net::HTTPSuccess)
25
+ raise FetchError, "Failed to fetch #{CSV_URL}: HTTP #{response.code} #{response.message}"
26
+ end
15
27
 
16
28
  # Remove UTF-8 BOM bytes if present (before encoding conversion)
17
- raw = response.b
29
+ raw = response.body.b
18
30
  raw = raw.byteslice(3..) if raw.byteslice(0, 3) == "\xEF\xBB\xBF".b
19
31
 
20
32
  # Convert from CP932 (Shift_JIS) to UTF-8
21
- utf8 = raw.force_encoding('CP932').encode('UTF-8')
22
-
23
- parse(utf8)
33
+ raw.force_encoding('CP932').encode('UTF-8')
24
34
  end
35
+ private_class_method :download_csv
25
36
 
26
37
  def self.presence(str)
27
38
  str&.strip&.then { |s| s unless s.empty? }
@@ -41,7 +41,7 @@ module VerifiedHolidays
41
41
  private
42
42
 
43
43
  def to_date(value)
44
- # DateTime Date のサブクラスだが、明示的に .to_date Date に変換
44
+ # DateTime is a subclass of Date, so convert it explicitly with .to_date.
45
45
  return value.to_date if value.is_a?(DateTime) || value.is_a?(Time)
46
46
  return value if value.is_a?(Date)
47
47
 
@@ -23,12 +23,17 @@ module VerifiedHolidays
23
23
  '勤労感謝の日' => 'Labor Thanksgiving Day',
24
24
  '振替休日' => 'Substitute Holiday',
25
25
  '休日' => "Citizens' Holiday",
26
+ '休日(祝日扱い)' => 'Public Holiday',
26
27
  '体育の日' => 'Health and Sports Day',
28
+ '体育の日(スポーツの日)' => 'Health and Sports Day (Sports Day)',
27
29
  '国民の休日' => "Citizens' Holiday",
30
+ '即位礼正殿の儀' => 'Enthronement Ceremony',
28
31
  '即位礼正殿の儀の行われる日' => 'Enthronement Ceremony',
29
32
  '即位の日' => 'Enthronement Day',
30
33
  '天皇の即位の日及び即位礼正殿の儀の行われる日を休日とする法律' => 'Holiday by Law',
31
34
  'みどりの日(国民の休日)' => "Greenery Day (Citizens' Holiday)",
35
+ '結婚の儀' => 'Imperial Wedding Ceremony',
36
+ '大喪の礼' => 'Imperial Funeral Ceremony',
32
37
  }.freeze
33
38
 
34
39
  attr_reader :date, :name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VerifiedHolidays
4
- VERSION = '0.3.1'
4
+ VERSION = '0.3.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: verified_holidays
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenta Ishizaki