mcalendar 0.5.1 → 0.5.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 +1 -1
- data/lib/mcalendar/config.rb +2 -1
- data/lib/mcalendar/options.rb +10 -6
- data/lib/mcalendar/schedule.rb +10 -2
- data/lib/mcalendar/version.rb +1 -1
- data/mcalendar.yml +28 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c413c998aafb8d17962a9610bad85958075a2779d7fc1cbf0859037ffe5c8e95
|
4
|
+
data.tar.gz: 931462951e2ee6ae342405aad95e7a09d93d6e1a315d4c593b9f2e2c368894cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 833c63b6fa24b4f5b18b505ede13cd069b9fccff1cdbf83ba2c1b1bd482c8b23a8c6eb1967090d5b68af0e288ecc3330b1f4225c19b272512b2c5e1d4c57da64
|
7
|
+
data.tar.gz: 0d83b7e80cd2b54a005919a95da5e5f34cda5604a1512f6f53e3c283b147843195edbc920c7fe86d80a8720dbd2b6d427b5fda6a2d0224098d7d7734d4b0441a
|
data/README.md
CHANGED
@@ -74,7 +74,7 @@ mcalendar 2021/02 -n my_calendar.pdf
|
|
74
74
|
|
75
75
|
### Configure mcalendar schedule
|
76
76
|
|
77
|
-
mcalendar reads mcalendar.yml in the current working directory as mcalendar's schedule file. It can contain the following settings:
|
77
|
+
mcalendar reads `~/.mcalendar.yml` or `mcalendar.yml` in the current working directory as mcalendar's schedule file. It can contain the following settings:
|
78
78
|
* holiday
|
79
79
|
* anniversary
|
80
80
|
|
data/lib/mcalendar/config.rb
CHANGED
@@ -23,5 +23,6 @@ module Mcalendar
|
|
23
23
|
DEFAULT_PDF_NAME = "calendar.pdf".freeze
|
24
24
|
|
25
25
|
DEFAULT_CONFIG_FILE = "mcalendar.yml".freeze
|
26
|
-
|
26
|
+
GLOBAL_CONFIG_FILE = File.expand_path("~/.mcalendar.yml").freeze
|
27
|
+
BUILT_IN_CONFIG_FILE = File.expand_path("../../mcalendar.yml", __dir__).freeze
|
27
28
|
end
|
data/lib/mcalendar/options.rb
CHANGED
@@ -7,14 +7,17 @@ module Mcalendar
|
|
7
7
|
:anniversary => {}
|
8
8
|
}
|
9
9
|
|
10
|
-
# If mcalendar.yml is not found, load the built-in mcalendar.yml.
|
10
|
+
# If mcalendar.yml or ~/.mcalendar.yml is not found, load the built-in mcalendar.yml.
|
11
11
|
if File.exist?(Mcalendar::DEFAULT_CONFIG_FILE)
|
12
|
-
|
12
|
+
config_yaml = Mcalendar::DEFAULT_CONFIG_FILE
|
13
|
+
elsif File.exist?(Mcalendar::GLOBAL_CONFIG_FILE)
|
14
|
+
config_yaml = Mcalendar::GLOBAL_CONFIG_FILE
|
13
15
|
else
|
14
|
-
|
15
|
-
load_config(config_file)
|
16
|
+
config_yaml = Mcalendar::BUILT_IN_CONFIG_FILE
|
16
17
|
end
|
17
18
|
|
19
|
+
load_config(config_yaml)
|
20
|
+
|
18
21
|
end
|
19
22
|
|
20
23
|
def hash_key_to_sym(h)
|
@@ -58,13 +61,14 @@ module Mcalendar
|
|
58
61
|
|
59
62
|
begin
|
60
63
|
remained = parser.parse!(argv)
|
61
|
-
rescue OptionParser::InvalidArgument => e
|
62
|
-
abort e.message
|
63
64
|
rescue OptionParser::MissingArgument => e
|
64
65
|
case e.args
|
65
66
|
when ["-n"], ["--name"]
|
66
67
|
@options[:name] = Mcalendar::DEFAULT_PDF_NAME
|
67
68
|
end
|
69
|
+
rescue OptionParser::ParseError => e
|
70
|
+
puts parser
|
71
|
+
abort e.message
|
68
72
|
end
|
69
73
|
|
70
74
|
begin
|
data/lib/mcalendar/schedule.rb
CHANGED
@@ -18,16 +18,24 @@ module Mcalendar
|
|
18
18
|
@days_config = Hash.new(nil)
|
19
19
|
@holidays = @config_schedule[:holiday]
|
20
20
|
@anniversaries = @config_schedule[:anniversary]
|
21
|
+
@date = @config_schedule[:date]
|
21
22
|
|
22
23
|
setup_schedule
|
23
24
|
end
|
24
25
|
|
26
|
+
def holidays_in_the_year(holidays)
|
27
|
+
holidays.map do |k,v|
|
28
|
+
year_of_key = Date.parse(k.to_s).year
|
29
|
+
"#{k}: #{v}" if year_of_key == Date.parse(@date.to_s).year
|
30
|
+
end.compact
|
31
|
+
end
|
32
|
+
|
25
33
|
def show_holidays
|
26
|
-
@holidays
|
34
|
+
holidays_in_the_year(@holidays)
|
27
35
|
end
|
28
36
|
|
29
37
|
def show_anniversaries
|
30
|
-
@anniversaries
|
38
|
+
holidays_in_the_year(@anniversaries)
|
31
39
|
end
|
32
40
|
|
33
41
|
def setup_schedule
|
data/lib/mcalendar/version.rb
CHANGED
data/mcalendar.yml
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
+
# Japanese holidays in English
|
2
|
+
# https://www8.cao.go.jp/chosei/shukujitsu/gaiyou.html
|
3
|
+
# 2021 -> 2022
|
4
|
+
|
1
5
|
holiday:
|
6
|
+
# 2021
|
2
7
|
20210101: New Year's Day
|
3
8
|
20210111: Coming-of-age Day
|
4
9
|
20210211: National Foundation Day
|
@@ -16,10 +21,32 @@ holiday:
|
|
16
21
|
20210923: Autumnal Equinox Day
|
17
22
|
20211103: Culture Day
|
18
23
|
20211123: Labour Thanksgiving Day
|
24
|
+
# 2022
|
25
|
+
20220101: New Year's Day
|
26
|
+
20220110: Coming-of-age Day
|
27
|
+
20220211: National Foundation Day
|
28
|
+
20220223: Emperor's Birthday
|
29
|
+
20220321: Vernal Equinox Day
|
30
|
+
20220429: Showa Day
|
31
|
+
20220503: Constitution Memorial Day
|
32
|
+
20220504: Greenery Day
|
33
|
+
20220505: Children's Day
|
34
|
+
20220718: Marine Day
|
35
|
+
20220811: Mountain Day
|
36
|
+
20220919: Respect for the Aged Day
|
37
|
+
20220923: Autumnal Equinox Day
|
38
|
+
20221010: Sports Day
|
39
|
+
20221103: Culture Day
|
40
|
+
20221123: Labour Thanksgiving Day
|
19
41
|
|
20
42
|
anniversary:
|
43
|
+
# 2021
|
21
44
|
20210224: Ruby's Birthday
|
22
45
|
20210909: RubyKaigi Takeout 2021
|
23
46
|
20210910: RubyKaigi Takeout 2021
|
24
47
|
20210911: RubyKaigi Takeout 2021
|
25
|
-
|
48
|
+
# 2022
|
49
|
+
20220224: Ruby's Birthday
|
50
|
+
20220908: RubyKaigi 2022
|
51
|
+
20220909: RubyKaigi 2022
|
52
|
+
20220910: RubyKaigi 2022
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icm7216
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|