mcalendar 0.5.2 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mcalendar/calendar.rb +21 -1
- data/lib/mcalendar/options.rb +3 -2
- 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: ac015db20949925d06ccf0e5f37e6cda175d161c73761e716aad6038c7280511
|
4
|
+
data.tar.gz: 28d599a9eb429270732f2e7d216eb0969212325a1f42efad84da7fc94a92ddfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5d978d7361405ac362dde8e36f1a435a9e4391673a92350b9bbe1b3659a569374e764a92dab89686aab3e20ee01d9650d04d973063210540278f8bc67f8d13f
|
7
|
+
data.tar.gz: 9750e02a0e79139e039dccc4fb6bfa46e0090b4193f7006378717bf81940b9aca214057ce1605dd51a68258ff8f450cf2757b0a0bf9c4773b001b13565c645fe
|
data/lib/mcalendar/calendar.rb
CHANGED
@@ -26,11 +26,31 @@ module Mcalendar
|
|
26
26
|
first_of_month.strftime("%B %Y")
|
27
27
|
end
|
28
28
|
|
29
|
+
def this_month_calendar?
|
30
|
+
(Date.today.year == @year) && (Date.today.month == @month)
|
31
|
+
end
|
32
|
+
|
33
|
+
def reverse_color(day_str)
|
34
|
+
"\e[7m" + day_str.to_s + "\e[0m"
|
35
|
+
end
|
36
|
+
|
37
|
+
def reverse_todays_date
|
38
|
+
today_str = format("%2s", Date.today.day.to_s)
|
39
|
+
|
40
|
+
if this_month_calendar?
|
41
|
+
month_days = days.map {|x| x.sub(today_str, reverse_color(today_str))}
|
42
|
+
else
|
43
|
+
month_days = days
|
44
|
+
end
|
45
|
+
|
46
|
+
month_days
|
47
|
+
end
|
48
|
+
|
29
49
|
def to_s
|
30
50
|
week_header = Mcalendar::DAY_OF_WEEK.join(" ")
|
31
51
|
month_header = month_title.center(week_header.size).rstrip
|
32
52
|
calendar = [[week_header]]
|
33
|
-
|
53
|
+
reverse_todays_date.each_slice(7) {|x| calendar << [x.join(" ")]}
|
34
54
|
[month_header, calendar]
|
35
55
|
end
|
36
56
|
|
data/lib/mcalendar/options.rb
CHANGED
@@ -61,13 +61,14 @@ module Mcalendar
|
|
61
61
|
|
62
62
|
begin
|
63
63
|
remained = parser.parse!(argv)
|
64
|
-
rescue OptionParser::InvalidArgument => e
|
65
|
-
abort e.message
|
66
64
|
rescue OptionParser::MissingArgument => e
|
67
65
|
case e.args
|
68
66
|
when ["-n"], ["--name"]
|
69
67
|
@options[:name] = Mcalendar::DEFAULT_PDF_NAME
|
70
68
|
end
|
69
|
+
rescue OptionParser::ParseError => e
|
70
|
+
puts parser
|
71
|
+
abort e.message
|
71
72
|
end
|
72
73
|
|
73
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.5
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|