holiday_jp 0.7.1 → 0.8.0

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: 6ebd9b74ed9f7e61e341e217748bdae919741cc6f1c05b898be7f27373a9ad45
4
- data.tar.gz: 45c09c56ceb0ce8b3c81a8b4ab234fcfdba58994f4d028cc6ba307bec23ad79e
3
+ metadata.gz: 32d70e14a9053f50182b13a99e481431fd9180fb28b02fcd0ba042959fbb1819
4
+ data.tar.gz: 60d36bf1854b72e50e32fb1c61f71c5d23925f96bfbc81184c5c86b363190a2c
5
5
  SHA512:
6
- metadata.gz: 837c9b891e69a4c48b3a792522219dbf90b4fbb773e201dd284498aa6afa702a3dc05b4ade12d0c13ab3d6a02b51ff7b3cf3881b2b4f4c542a54b1c42a9c611e
7
- data.tar.gz: e53e61326ef8be41f2a6b0368fc38addc3072dc8da47bb822c0fcfdafb61f1264f91ea05a2f8fbec39313770f4869b3346f57cc834736fd469802d0119381dce
6
+ metadata.gz: 032dbec25f732d8b880406cfb52c343ced173c0205e57c69d179c5be9e1b8af68b68c30b48ddab86b4585070b035047d63dcd446e3fe4ae492dcc414d5a9b879
7
+ data.tar.gz: 792dcf1441024706b7c41b879d1679d7e9b7bb2f7665ec477e44287da5698ed6af5adc1664b97085906a7687a55c90f2bb54fb2db14cd06932da2b670a236cbd
@@ -0,0 +1,31 @@
1
+ ---
2
+ name: test
3
+
4
+ on:
5
+ push:
6
+ schedule:
7
+ - cron: '0 1 * * *'
8
+
9
+ jobs:
10
+ job-test:
11
+ name: Test
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: [ '2.4', '2.5', '2.6', '2.7' ]
16
+ steps:
17
+ - uses: actions/setup-ruby@v1
18
+ with:
19
+ ruby-version: ${{ matrix.ruby-version }}
20
+
21
+ - name: Check out source code
22
+ uses: actions/checkout@v2
23
+
24
+ - name: Setup
25
+ run: |
26
+ git submodule update --init
27
+ gem install bundler -v '~> 1.6'
28
+ bundle install
29
+
30
+ - name: Run test
31
+ run: bundle exec rake test
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # holiday_jp [![Build Status](https://travis-ci.org/holiday-jp/holiday_jp-ruby.svg?branch=master)](https://travis-ci.org/holiday-jp/holiday_jp-ruby)
1
+ # holiday_jp [![test](https://github.com/holiday-jp/holiday_jp-ruby/workflows/test/badge.svg)](https://github.com/holiday-jp/holiday_jp-ruby/actions)
2
2
 
3
3
  Get holidays in Japan.
4
4
 
@@ -13,8 +13,28 @@ HolidayJp.holiday?(Date.new(2016, 8 ,11)) # true
13
13
  ## Supported Ruby Version
14
14
  Ruby 1.9.3+
15
15
 
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ ```ruby
21
+ gem 'holiday_jp'
22
+ ```
23
+
24
+ And then execute:
25
+
26
+ ```sh
27
+ $ bundle
28
+ ```
29
+
30
+ Or install it yourself as:
31
+
32
+ ```sh
33
+ $ gem install holiday_jp
34
+ ```
35
+
16
36
  ## Note on Patches/Pull Requests
17
-
37
+
18
38
  * Fork the project.
19
39
  * Make your feature addition or bug fix.
20
40
  * Add tests for it. This is important so I don't break it in a
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
19
19
  s.require_paths = ['lib']
20
20
 
21
- s.add_development_dependency 'bundler', '~> 1.6'
21
+ s.add_development_dependency 'bundler', '< 3.0'
22
22
  s.add_development_dependency 'rake'
23
23
  s.add_development_dependency 'test-unit', '3.0.9'
24
24
  end
@@ -1,3 +1,4 @@
1
+ ---
1
2
  1970-01-01: 元日
2
3
  1970-01-15: 成人の日
3
4
  1970-02-11: 建国記念の日
@@ -257,7 +258,7 @@
257
258
  1989-01-15: 成人の日
258
259
  1989-01-16: 振替休日
259
260
  1989-02-11: 建国記念の日
260
- 1989-02-24: 昭和天皇の大喪の礼
261
+ 1989-02-24: 大喪の礼
261
262
  1989-03-21: 春分の日
262
263
  1989-04-29: みどりの日
263
264
  1989-05-03: 憲法記念日
@@ -327,7 +328,7 @@
327
328
  1993-05-03: 憲法記念日
328
329
  1993-05-04: 国民の休日
329
330
  1993-05-05: こどもの日
330
- 1993-06-09: 皇太子徳仁親王の結婚の儀
331
+ 1993-06-09: 結婚の儀
331
332
  1993-09-15: 敬老の日
332
333
  1993-09-23: 秋分の日
333
334
  1993-10-10: 体育の日
@@ -758,9 +759,9 @@
758
759
  2019-02-11: 建国記念の日
759
760
  2019-03-21: 春分の日
760
761
  2019-04-29: 昭和の日
761
- 2019-04-30: 休日
762
+ 2019-04-30: 国民の休日
762
763
  2019-05-01: 休日(祝日扱い)
763
- 2019-05-02: 休日
764
+ 2019-05-02: 国民の休日
764
765
  2019-05-03: 憲法記念日
765
766
  2019-05-04: みどりの日
766
767
  2019-05-05: こどもの日
@@ -770,7 +771,7 @@
770
771
  2019-08-12: 振替休日
771
772
  2019-09-16: 敬老の日
772
773
  2019-09-23: 秋分の日
773
- 2019-10-14: 体育の日
774
+ 2019-10-14: 体育の日(スポーツの日)
774
775
  2019-10-22: 休日(祝日扱い)
775
776
  2019-11-03: 文化の日
776
777
  2019-11-04: 振替休日
@@ -802,11 +803,12 @@
802
803
  2021-05-03: 憲法記念日
803
804
  2021-05-04: みどりの日
804
805
  2021-05-05: こどもの日
805
- 2021-07-19: 海の日
806
- 2021-08-11: 山の日
806
+ 2021-07-22: 海の日
807
+ 2021-07-23: スポーツの日
808
+ 2021-08-08: 山の日
809
+ 2021-08-09: 振替休日
807
810
  2021-09-20: 敬老の日
808
811
  2021-09-23: 秋分の日
809
- 2021-10-11: スポーツの日
810
812
  2021-11-03: 文化の日
811
813
  2021-11-23: 勤労感謝の日
812
814
  2022-01-01: 元日
@@ -14,12 +14,12 @@ module HolidayJp
14
14
 
15
15
  def between(start, last)
16
16
  holidays.find_all do |date, _holiday|
17
- start <= date && date <= last
17
+ start.to_date <= date && date <= last.to_date
18
18
  end.map(&:last)
19
19
  end
20
20
 
21
21
  def holiday?(date)
22
- holidays[date]
22
+ holidays.has_key?(date.to_date)
23
23
  end
24
24
  end
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module HolidayJp
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -19,22 +19,46 @@ class TestHolidayJp < Test::Unit::TestCase
19
19
  assert_equal holidays[2].date, Date.new(2009, 1, 12)
20
20
  end
21
21
 
22
+ def test_between_accepts_datetime
23
+ holidays = HolidayJp.between(DateTime.new(2008, 12, 23), DateTime.new(2009, 1, 12))
24
+ assert_equal holidays[0].date, Date.new(2008, 12, 23)
25
+ assert_equal holidays[1].date, Date.new(2009, 1, 1)
26
+ assert_equal holidays[2].date, Date.new(2009, 1, 12)
27
+ end
28
+
29
+ def test_between_accepts_time
30
+ holidays = HolidayJp.between(Time.new(2008, 12, 23), Time.new(2009, 1, 12))
31
+ assert_equal holidays[0].date, Date.new(2008, 12, 23)
32
+ assert_equal holidays[1].date, Date.new(2009, 1, 1)
33
+ assert_equal holidays[2].date, Date.new(2009, 1, 12)
34
+ end
35
+
22
36
  def test_holiday?
23
- assert HolidayJp.holiday?(Date.new(2011, 9, 19))
24
- assert !HolidayJp.holiday?(Date.new(2011, 9, 18))
37
+ assert_true HolidayJp.holiday?(Date.new(2011, 9, 19))
38
+ assert_false HolidayJp.holiday?(Date.new(2011, 9, 18))
39
+ end
40
+
41
+ def test_holiday_p_accepts_datetime
42
+ assert_true HolidayJp.holiday?(DateTime.new(2011, 9, 19))
43
+ assert_false HolidayJp.holiday?(DateTime.new(2011, 9, 18))
44
+ end
45
+
46
+ def test_holiday_p_accepts_time
47
+ assert_true HolidayJp.holiday?(Time.new(2011, 9, 19))
48
+ assert_false HolidayJp.holiday?(Time.new(2011, 9, 18))
25
49
  end
26
50
 
27
51
  def test_mountain_day_from_2016
28
- assert !HolidayJp.holiday?(Date.new(2015, 8, 11))
52
+ assert_false HolidayJp.holiday?(Date.new(2015, 8, 11))
29
53
  (2016..2050).each do |year|
30
- next if year == 2020 # Tokyo Olympic year
31
- assert HolidayJp.holiday?(Date.new(year, 8, 11))
54
+ next if year == 2020 || year == 2021 # Tokyo Olympic year
55
+ assert_true HolidayJp.holiday?(Date.new(year, 8, 11))
32
56
  end
33
57
  end
34
58
 
35
59
  def test_emperors_birthday
36
60
  1970.upto(1988) do |year|
37
- assert HolidayJp.holiday?(Date.new(year, 4, 29))
61
+ assert_true HolidayJp.holiday?(Date.new(year, 4, 29))
38
62
  end
39
63
 
40
64
  1989.upto(2018) do |year|
@@ -1,11 +1,15 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require 'test/unit'
3
+ require 'net/http'
3
4
  require 'yaml'
4
5
 
5
6
  class TestHolidayJpYaml < Test::Unit::TestCase
6
7
  def test_yaml
7
8
  yaml = YAML.load_file(File.expand_path('../../holidays.yml', __FILE__))
8
- holiday_jp_yaml = YAML.load_file(File.expand_path('../holiday_jp/holidays.yml', __FILE__))
9
+ uri = URI.parse('https://raw.githubusercontent.com/holiday-jp/holiday_jp/v0.x/holidays.yml')
10
+ http = Net::HTTP.new(uri.host, uri.port)
11
+ http.use_ssl = true
12
+ holiday_jp_yaml = YAML.load(http.get(uri.request_uri).body)
9
13
  yaml.map do |date, name|
10
14
  assert_equal holiday_jp_yaml[date], name
11
15
  end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: holiday_jp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Komagata
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2020-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - "<"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '3.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '3.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,9 +61,9 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - ".document"
63
63
  - ".gemtest"
64
+ - ".github/workflows/ci.yml"
64
65
  - ".gitignore"
65
66
  - ".gitmodules"
66
- - ".travis.yml"
67
67
  - CHANGELOG.md
68
68
  - Gemfile
69
69
  - LICENSE
@@ -96,8 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubyforge_project: holiday_jp
100
- rubygems_version: 2.7.6
99
+ rubygems_version: 3.0.3
101
100
  signing_key:
102
101
  specification_version: 4
103
102
  summary: Japanese Holidays.
@@ -1,13 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 2.1.5
5
- - 2.2.2
6
- - 2.2.3
7
- - 2.2.5
8
- - 2.3.1
9
- - 2.4.1
10
- before_install:
11
- - git submodule update --init
12
- - sudo apt-get update
13
- - gem install bundler -v '~> 1.6'