mcalendar 0.5.1 → 0.5.4

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: 106df652910d9257dddfa3814af1ab493c2ead746ed454c94ce4aa9950014f16
4
- data.tar.gz: 6889c7be1874699ac9c86bd96ee7e48f1d61a566c90a78dfb2f398163e86dcda
3
+ metadata.gz: c413c998aafb8d17962a9610bad85958075a2779d7fc1cbf0859037ffe5c8e95
4
+ data.tar.gz: 931462951e2ee6ae342405aad95e7a09d93d6e1a315d4c593b9f2e2c368894cf
5
5
  SHA512:
6
- metadata.gz: 953e8b02928a44b6129fc716858aceaf0d29288bd473b3f2e9e2e6dd2a3f7a8276fc1948e403840acb7640b83a68e4f733100c93d2fdc114843c33412823e629
7
- data.tar.gz: 027ba073a3567099bf0f18378726925754097826ea8066c1c99b1776e87e90b816f9f6fc9af1cf03b41b1656ade0dc61c1bc2cfbe5e54fb4ffca8680d40d7801
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
 
@@ -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
@@ -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
- load_config(Mcalendar::DEFAULT_CONFIG_FILE)
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
- config_file = File.expand_path("../../mcalendar.yml",__dir__)
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
@@ -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.map{|k,v| "#{k}: #{v}"}
34
+ holidays_in_the_year(@holidays)
27
35
  end
28
36
 
29
37
  def show_anniversaries
30
- @anniversaries.map{|k,v| "#{k}: #{v}"}
38
+ holidays_in_the_year(@anniversaries)
31
39
  end
32
40
 
33
41
  def setup_schedule
@@ -1,3 +1,3 @@
1
1
  module Mcalendar
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.4"
3
3
  end
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.1
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: 2021-09-18 00:00:00.000000000 Z
11
+ date: 2022-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn