mcalendar 0.3.1 → 0.3.2
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 +4 -4
- data/lib/mcalendar/config.rb +17 -0
- data/lib/mcalendar/holiday.rb +9 -0
- data/lib/mcalendar/output_pdf.rb +7 -7
- data/lib/mcalendar/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f26751cd7124cc591143e0a0fe1cfe6062e0a9a5e3b05d6b6159d7bf5add079
|
4
|
+
data.tar.gz: 10c26d535fab1b442877f877eb55251f6a5e728c150d088810221561cac0945e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3165f35909445ceb798da668ba224721520e05af8b55823eb92f1074b49cbfba13f33a9296b9814d42d1ffb37b8cce1f1a76eea410267dbe57b10b5ba4407ac9
|
7
|
+
data.tar.gz: '0738ea2950b47e1533bd775c3246bd1a377c21ed1875b453b4c3c142838775ef5c209e20370270ae1e41bfd5d8807e6432bafc928fb040963f4733055ce71069'
|
data/lib/mcalendar/config.rb
CHANGED
@@ -32,6 +32,7 @@ module Mcalendar
|
|
32
32
|
@days_config = Hash.new(nil)
|
33
33
|
days_basic
|
34
34
|
holiday
|
35
|
+
anniversary
|
35
36
|
end
|
36
37
|
|
37
38
|
def self.days_basic
|
@@ -53,6 +54,22 @@ module Mcalendar
|
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
def self.anniversary
|
58
|
+
y = "%4d" % @first_of_month.year
|
59
|
+
m = "%02d" % @first_of_month.month
|
60
|
+
regex = /#{y}#{m}\d\d/
|
61
|
+
|
62
|
+
Mcalendar::ANNIVERSARY.keys.grep(regex).each do |d|
|
63
|
+
@days_config[d].day = Date.parse(d.to_s).day
|
64
|
+
if @days_config[d].text.size > 1
|
65
|
+
@days_config[d].text += (", " + Mcalendar::ANNIVERSARY[d])
|
66
|
+
else
|
67
|
+
@days_config[d].text += Mcalendar::ANNIVERSARY[d]
|
68
|
+
end
|
69
|
+
@days_config[d].color = :black if @days_config[d].color != :red
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
56
73
|
def self.days
|
57
74
|
pdf_days = @days_config.each_value.map {|val| val}
|
58
75
|
@first_of_month.wday.times {pdf_days.unshift(" ")}
|
data/lib/mcalendar/holiday.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
module Mcalendar
|
2
|
+
|
3
|
+
# Japanese holidays
|
2
4
|
HOLIDAY = {
|
3
5
|
"20200101": "New Year's Day",
|
4
6
|
"20200113": "Coming-of-age Day",
|
@@ -19,4 +21,11 @@ module Mcalendar
|
|
19
21
|
"20201103": "Culture Day",
|
20
22
|
"20201123": "Labour Thanksgiving Day"
|
21
23
|
}
|
24
|
+
|
25
|
+
ANNIVERSARY = {
|
26
|
+
"20200224": "Ruby's Birthday",
|
27
|
+
"20200809": "RubyKaigi 2020 Nagano",
|
28
|
+
"20200810": "RubyKaigi 2020 Nagano",
|
29
|
+
"20200811": "RubyKaigi 2020 Nagano"
|
30
|
+
}
|
22
31
|
end
|
data/lib/mcalendar/output_pdf.rb
CHANGED
@@ -9,7 +9,8 @@ module Mcalendar
|
|
9
9
|
Mcalendar::Config::days_information(obj_calendar)
|
10
10
|
@pdf_days = Mcalendar::Config::days
|
11
11
|
@calendar = @pdf_days.each_slice(7).map
|
12
|
-
@
|
12
|
+
@day_height = @calendar.size > 5 ? 20 : 20
|
13
|
+
@text_height = @calendar.size > 5 ? 30 : 40
|
13
14
|
|
14
15
|
super(page_size: 'A4', margin: 20)
|
15
16
|
calendar_render
|
@@ -38,10 +39,10 @@ module Mcalendar
|
|
38
39
|
row_color = c.map {|x| (x.class == Struct::ConfigDay) ? x.color : :black}
|
39
40
|
row_text = c.map {|x| (x.class == Struct::ConfigDay) ? x.text : x}
|
40
41
|
|
41
|
-
table([row_day], cell_style: {height: @
|
42
|
+
table([row_day], cell_style: {height: @day_height}) do
|
42
43
|
cells.style(width: 79, align: :center, size: 19)
|
43
44
|
row(0).borders = [:top, :left, :right]
|
44
|
-
row(0).padding_top =
|
45
|
+
row(0).padding_top = 2
|
45
46
|
row(0).padding_bottom = 0
|
46
47
|
row_color.each_with_index do |color, index|
|
47
48
|
rows(0).columns(index).text_color = Mcalendar::Config::COLOR[color]
|
@@ -49,11 +50,10 @@ module Mcalendar
|
|
49
50
|
column(0).map {|col| col.text_color = Mcalendar::Config::COLOR[:red]}
|
50
51
|
end
|
51
52
|
|
52
|
-
table([row_text], cell_style: {height: @
|
53
|
-
cells.style(width: 79, align: :center, size:
|
54
|
-
row(0).style = {overflow: :shrink_to_fit}
|
53
|
+
table([row_text], cell_style: {height: @text_height}) do
|
54
|
+
cells.style(width: 79, align: :center, size: 8, overflow: :shrink_to_fit)
|
55
55
|
row(0).borders = [:bottom, :left, :right]
|
56
|
-
row(0).padding_top =
|
56
|
+
row(0).padding_top = 0
|
57
57
|
row(0).padding_bottom = 0
|
58
58
|
row(0).padding_left = 0
|
59
59
|
row(0).padding_right = 0
|
data/lib/mcalendar/version.rb
CHANGED