holidays_in_month 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -31
- data/lib/holidays_in_month/version.rb +1 -1
- data/lib/holidays_in_month.rb +27 -31
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4dfaf63b472e085d5685d9d3b9da017ca71183ab
|
4
|
+
data.tar.gz: f2d4350613a77c4d87f044f1355caacf499dc44d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f291c7258eb610b897a305b24694e7aeb6e833155eafbc477e14408fb41d65601434152f3be758ce3c836ef7910631c1df31ee13934933ab52c4614133c86b4d
|
7
|
+
data.tar.gz: c11c108761809b35b87693219721173562150abfb5ebeb1e03b2a849b86d715f7da0e08349ed1849d153f9cb74c60ffa3a2a121b0d12401f2b4b50e6e16ac68a
|
data/README.md
CHANGED
@@ -2,46 +2,30 @@
|
|
2
2
|
|
3
3
|
This gem is return holidays(Saturday, Sunday, National) of month in Japan.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
Holiday.new.in_month(2016, 1)
|
9
|
+
=> ["2016-1-2", "2016-1-3", "2016-1-9", "2016-1-10", "2016-1-16", "2016-1-17",
|
8
10
|
"2016-1-23", "2016-1-24", "2016-1-30", "2016-1-31", {"2016-01-01"=>"元日", "2016-01-11"=>"成人の日"}]
|
9
|
-
```
|
11
|
+
```
|
10
12
|
|
11
13
|
## Installation
|
12
14
|
|
13
|
-
Add this line to your application's Gemfile:
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
gem 'holidays_in_month'
|
17
|
-
```
|
15
|
+
Add this line to your application's Gemfile:
|
18
16
|
|
19
|
-
|
17
|
+
```ruby
|
18
|
+
gem 'holidays_in_month'
|
19
|
+
```
|
20
20
|
|
21
|
-
|
21
|
+
And then execute:
|
22
22
|
|
23
|
-
|
23
|
+
$ bundle install
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
## Usage
|
25
|
+
Or install it yourself as:
|
28
26
|
|
29
|
-
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
holidays = JP::Holidays.new
|
33
|
-
holidays.get_in_month(year, month)
|
34
|
-
```
|
35
|
-
|
36
|
-
example:
|
37
|
-
|
38
|
-
```ruby
|
39
|
-
@holidays = JP::Holidays.new
|
40
|
-
@holidays.get_in_month(2016, 1)
|
41
|
-
@holidays => ["2016-1-2", "2016-1-3", "2016-1-9", "2016-1-10", "2016-1-16", "2016-1-17",
|
42
|
-
"2016-1-23", "2016-1-24", "2016-1-30", "2016-1-31", {"2016-01-01"=>"元日", "2016-01-11"=>"成人の日"}]
|
43
|
-
```
|
27
|
+
$ gem install holidays_in_month
|
44
28
|
|
45
29
|
## License
|
46
30
|
|
47
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
31
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/lib/holidays_in_month.rb
CHANGED
@@ -1,40 +1,36 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
class Holiday
|
2
|
+
def initialize
|
3
|
+
@nationaldays = {}
|
4
|
+
@holidays = []
|
5
|
+
end
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
init
|
11
|
-
#休日に祝日を追加
|
12
|
-
holidays(year, month) << nationaldays.select { |n| n.match(/#{year}-#{"%02d" % month}-*/) }
|
13
|
-
end
|
7
|
+
def in_month(year, month)
|
8
|
+
holidays(year, month) << nationaldays.select { |n| n.match(/#{year}-#{"%02d" % month}-*/) }
|
9
|
+
end
|
14
10
|
|
15
|
-
|
11
|
+
private
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
def nationaldays
|
23
|
-
yaml = YAML.load_file(File.expand_path('./../../holidays.yml', __FILE__))
|
24
|
-
yaml.each do |date, name|
|
25
|
-
@nationaldays.store(date.strftime("%Y-%m-%d"), name)
|
26
|
-
end
|
27
|
-
@nationaldays
|
13
|
+
def nationaldays
|
14
|
+
yaml = YAML.load_file(File.expand_path('./../../holidays.yml', __FILE__))
|
15
|
+
yaml.each do |date, name|
|
16
|
+
@nationaldays.store(date.strftime("%Y-%m-%d"), name)
|
28
17
|
end
|
18
|
+
@nationaldays
|
19
|
+
end
|
29
20
|
|
30
|
-
|
31
|
-
|
21
|
+
def holidays(year, month)
|
22
|
+
num_days_of_month = Date.new(year, month).end_of_month.day
|
32
23
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
@holidays
|
24
|
+
1.upto(num_days_of_month) do |day|
|
25
|
+
wday = Date.new(year, month, day).wday
|
26
|
+
@holidays << "%04d-%02d-%02d" % [year, month, day] if wday == 6 || wday == 0
|
38
27
|
end
|
28
|
+
@holidays
|
39
29
|
end
|
40
30
|
end
|
31
|
+
|
32
|
+
require 'holidays_in_month/version'
|
33
|
+
require 'active_support'
|
34
|
+
require 'active_support/time'
|
35
|
+
require 'time'
|
36
|
+
require 'yaml'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: holidays_in_month
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuta Hasada
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|