mcalendar 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +12 -11
- data/Gemfile +4 -6
- data/README.md +65 -65
- data/lib/mcalendar/calendar.rb +21 -25
- data/lib/mcalendar/command.rb +26 -10
- data/lib/mcalendar/config.rb +61 -46
- data/lib/mcalendar/holiday.rb +59 -27
- data/lib/mcalendar/options.rb +7 -7
- data/lib/mcalendar/output_pdf.rb +13 -15
- data/lib/mcalendar/version.rb +3 -3
- data/lib/mcalendar.rb +13 -12
- data/mcalendar.gemspec +32 -28
- metadata +48 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a634777135f135d9aeae14ea0bc037a3974ebe8f1574d6d021a11f959d01cc7
|
4
|
+
data.tar.gz: 3afd599f14c4689099906def2f233f489ba990b09b4424422dad20dfd2b4e054
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f54acf7a0748733220713a0fb2395e881c2364e2ee76d95c4ce6f7840bcc5202a8f7f7b1c85eaf0aaa48782af05f063f29761a47cb4313101ca74e0ce0f18ec
|
7
|
+
data.tar.gz: d9f6e5f64f7668e771e7bb183f940f0c5d465e9544819abef54d773d8b3071ffe8f40e4e736cda4b373b26622b5967c32fd06bb4c2d63a1309df2a1339df352b
|
data/.gitignore
CHANGED
@@ -1,11 +1,12 @@
|
|
1
|
-
/.bundle/
|
2
|
-
/.yardoc
|
3
|
-
/_yardoc/
|
4
|
-
/coverage/
|
5
|
-
/doc/
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/tmp/
|
9
|
-
/Gemfile.lock
|
10
|
-
pdf/*.pdf
|
11
|
-
*.pdf
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
/Gemfile.lock
|
10
|
+
pdf/*.pdf
|
11
|
+
*.pdf
|
12
|
+
/.vscode/
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,65 +1,65 @@
|
|
1
|
-
|
2
|
-
# Mcalendar [![Gem Version](https://badge.fury.io/rb/mcalendar.svg)](https://badge.fury.io/rb/mcalendar)
|
3
|
-
|
4
|
-
Ruby monthly calendar, console and pdf.
|
5
|
-
This calendar includes Japanese holidays.
|
6
|
-
|
7
|
-
## Installation
|
8
|
-
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'mcalendar'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle install
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
|
-
$ gem install mcalendar
|
22
|
-
|
23
|
-
|
24
|
-
## Usage
|
25
|
-
|
26
|
-
If you want to create a calendar for this month.
|
27
|
-
|
28
|
-
When you run the command, the calendar appears on the console. The pdf file is created in the current directory.
|
29
|
-
```
|
30
|
-
mcalendar
|
31
|
-
```
|
32
|
-
|
33
|
-
If you want to create a calendar for any month.
|
34
|
-
```
|
35
|
-
mcalendar 2020/02
|
36
|
-
```
|
37
|
-
|
38
|
-
If you want to output only PDF, use the `-p` option.
|
39
|
-
```
|
40
|
-
mcalendar 2020/02 -p
|
41
|
-
```
|
42
|
-
|
43
|
-
Also, If you want to output only console, use the `-c` option.
|
44
|
-
```
|
45
|
-
mcalendar 2020/02 -c
|
46
|
-
```
|
47
|
-
|
48
|
-
The default PDF file name is `calendar.pdf`. You can specify any name using the `-n` option.
|
49
|
-
```
|
50
|
-
mcalendar 2020/02 -n my_calendar.pdf
|
51
|
-
```
|
52
|
-
|
53
|
-
show help
|
54
|
-
```
|
55
|
-
>mcalendar -h
|
56
|
-
Usage: mcalendar [options]
|
57
|
-
-v, --version Show version
|
58
|
-
-p, --pdf output pdf
|
59
|
-
-n, --name=NAME output pdf name
|
60
|
-
-c, --console output console
|
61
|
-
```
|
62
|
-
|
63
|
-
## License
|
64
|
-
|
65
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
1
|
+
|
2
|
+
# Mcalendar [![Gem Version](https://badge.fury.io/rb/mcalendar.svg)](https://badge.fury.io/rb/mcalendar)
|
3
|
+
|
4
|
+
Ruby monthly calendar, console and pdf.
|
5
|
+
This calendar includes Japanese holidays.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'mcalendar'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install mcalendar
|
22
|
+
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
If you want to create a calendar for this month.
|
27
|
+
|
28
|
+
When you run the command, the calendar appears on the console. The pdf file is created in the current directory.
|
29
|
+
```
|
30
|
+
mcalendar
|
31
|
+
```
|
32
|
+
|
33
|
+
If you want to create a calendar for any month.
|
34
|
+
```
|
35
|
+
mcalendar 2020/02
|
36
|
+
```
|
37
|
+
|
38
|
+
If you want to output only PDF, use the `-p` option.
|
39
|
+
```
|
40
|
+
mcalendar 2020/02 -p
|
41
|
+
```
|
42
|
+
|
43
|
+
Also, If you want to output only console, use the `-c` option.
|
44
|
+
```
|
45
|
+
mcalendar 2020/02 -c
|
46
|
+
```
|
47
|
+
|
48
|
+
The default PDF file name is `calendar.pdf`. You can specify any name using the `-n` option.
|
49
|
+
```
|
50
|
+
mcalendar 2020/02 -n my_calendar.pdf
|
51
|
+
```
|
52
|
+
|
53
|
+
show help
|
54
|
+
```
|
55
|
+
>mcalendar -h
|
56
|
+
Usage: mcalendar [options]
|
57
|
+
-v, --version Show version
|
58
|
+
-p, --pdf output pdf
|
59
|
+
-n, --name=NAME output pdf name
|
60
|
+
-c, --console output console
|
61
|
+
```
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/mcalendar/calendar.rb
CHANGED
@@ -2,41 +2,37 @@
|
|
2
2
|
module Mcalendar
|
3
3
|
|
4
4
|
class Calendar
|
5
|
-
attr_reader :pdf_name, :month_title, :days, :first_of_month, :end_of_month
|
6
5
|
|
7
|
-
def initialize(year, month
|
8
|
-
@
|
9
|
-
@
|
10
|
-
@days = (1..end_of_month.day).map {|m| "%2d" % m}
|
11
|
-
first_of_month.wday.times {@days.unshift(" ")}
|
12
|
-
@month_title = first_of_month.strftime("%B %Y")
|
13
|
-
set_pdf_name(pdf_name)
|
6
|
+
def initialize(year, month)
|
7
|
+
@year = year
|
8
|
+
@month = month
|
14
9
|
end
|
15
10
|
|
16
|
-
def
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
def first_of_month
|
12
|
+
Date.new(@year, @month, 1)
|
13
|
+
end
|
14
|
+
|
15
|
+
def end_of_month
|
16
|
+
Date.new(@year, @month, -1)
|
17
|
+
end
|
18
|
+
|
19
|
+
def days
|
20
|
+
days = (1..end_of_month.day).map {|m| "%2d" % m}
|
21
|
+
first_of_month.wday.times {days.unshift(" ")}
|
22
|
+
days
|
23
|
+
end
|
24
|
+
|
25
|
+
def month_title
|
26
|
+
first_of_month.strftime("%B %Y")
|
22
27
|
end
|
23
28
|
|
24
29
|
def to_s
|
25
30
|
week_header = Mcalendar::DAY_OF_WEEK.join(" ")
|
26
|
-
month_header =
|
31
|
+
month_header = month_title.center(week_header.size).rstrip
|
27
32
|
calendar = [[week_header]]
|
28
|
-
|
33
|
+
days.each_slice(7) {|x| calendar << [x.join(" ")]}
|
29
34
|
[month_header, calendar]
|
30
35
|
end
|
31
|
-
|
32
|
-
def display
|
33
|
-
puts to_s
|
34
|
-
end
|
35
|
-
|
36
|
-
def pdf
|
37
|
-
pdf = Mcalendar::OutputPdf.new(self)
|
38
|
-
pdf.render_file @pdf_name
|
39
|
-
end
|
40
36
|
|
41
37
|
end
|
42
38
|
end
|
data/lib/mcalendar/command.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Mcalendar
|
4
4
|
class Command
|
5
|
-
|
6
5
|
def self.run(argv)
|
7
6
|
new(argv).execute
|
8
7
|
end
|
@@ -10,26 +9,43 @@ module Mcalendar
|
|
10
9
|
def initialize(argv)
|
11
10
|
@argv = argv
|
12
11
|
end
|
12
|
+
|
13
|
+
def output_console
|
14
|
+
puts @calendar.to_s
|
15
|
+
end
|
13
16
|
|
14
|
-
def
|
17
|
+
def output_pdf
|
18
|
+
@outputpdf.render_file(pdf_filename)
|
19
|
+
end
|
15
20
|
|
21
|
+
def pdf_filename
|
22
|
+
if @pdf_name.nil? || @pdf_name.empty?
|
23
|
+
Mcalendar::DEFAULT_PDF_NAME
|
24
|
+
else
|
25
|
+
@pdf_name = @pdf_name.downcase.end_with?(".pdf")? @pdf_name : @pdf_name + ".pdf"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def execute
|
16
30
|
options = Mcalendar::Options.parse(@argv)
|
17
31
|
date = options[:date]
|
18
32
|
console = options[:opt][:console]
|
19
33
|
pdf = options[:opt][:pdf]
|
20
|
-
pdf_name = options[:opt][:name]
|
21
|
-
|
34
|
+
@pdf_name = options[:opt][:name]
|
35
|
+
version = options[:opt][:version]
|
36
|
+
@calendar = Mcalendar::Calendar.new(date.year, date.month)
|
37
|
+
@outputpdf = Mcalendar::OutputPdf.new(@calendar)
|
22
38
|
|
23
39
|
# output calendar
|
24
|
-
|
25
|
-
|
40
|
+
output_console if console
|
41
|
+
output_pdf if pdf
|
42
|
+
|
26
43
|
|
27
44
|
# both outputs if no options
|
28
|
-
if console.nil? && pdf.nil?
|
29
|
-
|
30
|
-
|
45
|
+
if console.nil? && pdf.nil? && version.nil?
|
46
|
+
output_console
|
47
|
+
output_pdf
|
31
48
|
end
|
32
|
-
|
33
49
|
end
|
34
50
|
end
|
35
51
|
end
|
data/lib/mcalendar/config.rb
CHANGED
@@ -1,81 +1,96 @@
|
|
1
1
|
module Mcalendar
|
2
2
|
COLOR = {
|
3
|
-
white:
|
4
|
-
silver:
|
5
|
-
gray:
|
6
|
-
black:
|
7
|
-
red:
|
8
|
-
maroon:
|
9
|
-
yellow:
|
10
|
-
olive:
|
11
|
-
lime:
|
12
|
-
green:
|
13
|
-
aqua:
|
14
|
-
teal:
|
15
|
-
blue:
|
16
|
-
navy:
|
17
|
-
fuchsia:
|
18
|
-
purple:
|
19
|
-
orange:
|
20
|
-
}
|
3
|
+
white: "FFFFFF",
|
4
|
+
silver: "C0C0C0",
|
5
|
+
gray: "808080",
|
6
|
+
black: "000000",
|
7
|
+
red: "FF0000",
|
8
|
+
maroon: "800000",
|
9
|
+
yellow: "FFFF00",
|
10
|
+
olive: "808000",
|
11
|
+
lime: "00FF00",
|
12
|
+
green: "008000",
|
13
|
+
aqua: "00FFFF",
|
14
|
+
teal: "008080",
|
15
|
+
blue: "0000FF",
|
16
|
+
navy: "000080",
|
17
|
+
fuchsia: "FF00FF",
|
18
|
+
purple: "800080",
|
19
|
+
orange: "FFA500",
|
20
|
+
}.freeze
|
21
21
|
|
22
|
-
DAY_OF_WEEK = [
|
23
|
-
DEFAULT_PDF_NAME = "calendar.pdf"
|
22
|
+
DAY_OF_WEEK = %w[Sun Mon Tue Wed Thu Fri Sat].freeze
|
23
|
+
DEFAULT_PDF_NAME = "calendar.pdf".freeze
|
24
24
|
|
25
25
|
Config_day = Struct.new(
|
26
|
-
"ConfigDay",
|
27
|
-
:day,
|
28
|
-
:day_color,
|
29
|
-
:holiday_text,
|
30
|
-
:anniversary_text
|
26
|
+
"ConfigDay",
|
27
|
+
:day,
|
28
|
+
:day_color,
|
29
|
+
:holiday_text,
|
30
|
+
:anniversary_text
|
31
31
|
)
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# @end_of_month = obj_calendar.end_of_month
|
33
|
+
class Schedule
|
34
|
+
extend Forwardable
|
35
|
+
def_delegators :@calendar, :first_of_month, :end_of_month
|
37
36
|
|
37
|
+
def initialize(calendar)
|
38
|
+
@calendar = calendar
|
38
39
|
@days_config = Hash.new(nil)
|
40
|
+
|
41
|
+
setup_schedule
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
def setup_schedule
|
46
|
+
holiday_description_language
|
39
47
|
days_basic
|
40
|
-
|
41
|
-
|
48
|
+
holidays_in_the_month
|
49
|
+
anniversaries_in_the_month
|
50
|
+
end
|
51
|
+
|
52
|
+
def holiday_description_language
|
53
|
+
Mcalendar.const_set(:HOLIDAY, Mcalendar::EN::HOLIDAY)
|
54
|
+
Mcalendar.const_set(:ANNIVERSARY, Mcalendar::EN::ANNIVERSARY)
|
42
55
|
end
|
43
56
|
|
44
57
|
def days_basic
|
45
|
-
(
|
58
|
+
(first_of_month..end_of_month).each do |date|
|
46
59
|
d_sym = date.strftime("%Y%m%d").to_sym
|
47
60
|
@days_config[d_sym] = Config_day.new(date.day, :black, nil, nil)
|
48
61
|
end
|
62
|
+
@days_config
|
49
63
|
end
|
50
64
|
|
51
|
-
def
|
52
|
-
y = "%4d"
|
53
|
-
m = "%02d"
|
65
|
+
def holidays_in_the_month
|
66
|
+
y = format("%4d", first_of_month.year)
|
67
|
+
m = format("%02d", first_of_month.month)
|
54
68
|
regex = /#{y}#{m}\d\d/
|
55
|
-
|
69
|
+
|
56
70
|
Mcalendar::HOLIDAY.keys.grep(regex).each do |d|
|
57
71
|
@days_config[d].day = Date.parse(d.to_s).day
|
58
72
|
@days_config[d].day_color = :red
|
59
73
|
@days_config[d].holiday_text = Mcalendar::HOLIDAY[d]
|
60
74
|
end
|
75
|
+
@days_config
|
61
76
|
end
|
62
77
|
|
63
|
-
def
|
64
|
-
y = "%4d"
|
65
|
-
m = "%02d"
|
78
|
+
def anniversaries_in_the_month
|
79
|
+
y = format("%4d", first_of_month.year)
|
80
|
+
m = format("%02d", first_of_month.month)
|
66
81
|
regex = /#{y}#{m}\d\d/
|
67
|
-
|
82
|
+
|
68
83
|
Mcalendar::ANNIVERSARY.keys.grep(regex).each do |d|
|
69
84
|
@days_config[d].day = Date.parse(d.to_s).day
|
70
85
|
@days_config[d].anniversary_text = Mcalendar::ANNIVERSARY[d]
|
71
86
|
end
|
87
|
+
@days_config
|
72
88
|
end
|
73
89
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
77
|
-
|
90
|
+
def daily_schedule
|
91
|
+
daily = @days_config.each_value.map { |val| val }
|
92
|
+
first_of_month.wday.times { daily.unshift(" ") }
|
93
|
+
daily
|
78
94
|
end
|
79
|
-
|
80
95
|
end
|
81
|
-
end
|
96
|
+
end
|
data/lib/mcalendar/holiday.rb
CHANGED
@@ -1,31 +1,63 @@
|
|
1
1
|
module Mcalendar
|
2
|
+
module JA
|
3
|
+
# Japanese holidays in Japanese
|
4
|
+
HOLIDAY = {
|
5
|
+
"20200101": "元日",
|
6
|
+
"20200113": "成人の日",
|
7
|
+
"20200211": "建国記念の日",
|
8
|
+
"20200223": "天皇誕生日",
|
9
|
+
"20200224": "振替休日",
|
10
|
+
"20200320": "春分の日",
|
11
|
+
"20200429": "昭和の日",
|
12
|
+
"20200503": "憲法記念日",
|
13
|
+
"20200504": "みどりの日",
|
14
|
+
"20200505": "子供の日",
|
15
|
+
"20200506": "振替休日",
|
16
|
+
"20200723": "海の日",
|
17
|
+
"20200724": "スポーツの日",
|
18
|
+
"20200810": "山の日",
|
19
|
+
"20200921": "敬老の日",
|
20
|
+
"20200922": "秋分の日",
|
21
|
+
"20201103": "文化の日",
|
22
|
+
"20201123": "勤労感謝の日",
|
23
|
+
}.freeze
|
2
24
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
"20200320": "Vernal Equinox Day",
|
11
|
-
"20200429": "Showa Day",
|
12
|
-
"20200503": "Constitution Memorial Day",
|
13
|
-
"20200504": "Greenery Day",
|
14
|
-
"20200505": "Children's Day",
|
15
|
-
"20200506": "Substitute Holiday",
|
16
|
-
"20200723": "Marine Day",
|
17
|
-
"20200724": "Sports Day",
|
18
|
-
"20200810": "Mountain Day",
|
19
|
-
"20200921": "Respect for the Aged Day",
|
20
|
-
"20200922": "Autumnal Equinox Day",
|
21
|
-
"20201103": "Culture Day",
|
22
|
-
"20201123": "Labour Thanksgiving Day"
|
23
|
-
}
|
25
|
+
ANNIVERSARY = {
|
26
|
+
"20200224": "Rubyの誕生日",
|
27
|
+
"20200903": "RubyKaigi 2020 Nagano",
|
28
|
+
"20200904": "RubyKaigi 2020 Nagano",
|
29
|
+
"20200905": "RubyKaigi 2020 Nagano",
|
30
|
+
}.freeze
|
31
|
+
end
|
24
32
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
module EN
|
34
|
+
# Japanese holidays in English
|
35
|
+
HOLIDAY = {
|
36
|
+
"20200101": "New Year's Day",
|
37
|
+
"20200113": "Coming-of-age Day",
|
38
|
+
"20200211": "National Foundation Day",
|
39
|
+
"20200223": "Emperor's Birthday",
|
40
|
+
"20200224": "Substitute Holiday",
|
41
|
+
"20200320": "Vernal Equinox Day",
|
42
|
+
"20200429": "Showa Day",
|
43
|
+
"20200503": "Constitution Memorial Day",
|
44
|
+
"20200504": "Greenery Day",
|
45
|
+
"20200505": "Children's Day",
|
46
|
+
"20200506": "Substitute Holiday",
|
47
|
+
"20200723": "Marine Day",
|
48
|
+
"20200724": "Sports Day",
|
49
|
+
"20200810": "Mountain Day",
|
50
|
+
"20200921": "Respect for the Aged Day",
|
51
|
+
"20200922": "Autumnal Equinox Day",
|
52
|
+
"20201103": "Culture Day",
|
53
|
+
"20201123": "Labour Thanksgiving Day",
|
54
|
+
}.freeze
|
55
|
+
|
56
|
+
ANNIVERSARY = {
|
57
|
+
"20200224": "Ruby's Birthday",
|
58
|
+
"20200903": "RubyKaigi 2020 Nagano",
|
59
|
+
"20200904": "RubyKaigi 2020 Nagano",
|
60
|
+
"20200905": "RubyKaigi 2020 Nagano",
|
61
|
+
}.freeze
|
62
|
+
end
|
31
63
|
end
|
data/lib/mcalendar/options.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
module Mcalendar
|
2
2
|
module Options
|
3
|
-
|
4
3
|
def self.parse(argv)
|
5
4
|
options = {}
|
6
5
|
|
7
6
|
parser = OptionParser.new do |o|
|
8
|
-
o.on_head(
|
7
|
+
o.on_head("-v", "--version", "Show version") do |v|
|
8
|
+
options[:version] = v
|
9
9
|
o.version = Mcalendar::VERSION
|
10
10
|
puts o.version
|
11
11
|
end
|
12
|
-
o.on(
|
13
|
-
o.on(
|
14
|
-
o.on(
|
12
|
+
o.on("-p", "--pdf", "output pdf") { |v| options[:pdf] = v }
|
13
|
+
o.on("-n NAME", "--name=NAME", String, "output pdf name") { |v| options[:name] = v }
|
14
|
+
o.on("-c", "--console", "output console") { |v| options[:console] = v }
|
15
15
|
end
|
16
16
|
|
17
17
|
begin
|
@@ -24,14 +24,14 @@ module Mcalendar
|
|
24
24
|
options[:name] = Mcalendar::DEFAULT_PDF_NAME
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
begin
|
29
29
|
d = Date.parse(remained.first)
|
30
30
|
rescue
|
31
31
|
d = Date.today
|
32
32
|
end
|
33
33
|
|
34
|
-
{date: d, opt: options}
|
34
|
+
{ date: d, opt: options }
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
data/lib/mcalendar/output_pdf.rb
CHANGED
@@ -1,19 +1,17 @@
|
|
1
1
|
module Mcalendar
|
2
2
|
class OutputPdf < Prawn::Document
|
3
|
-
|
3
|
+
extend Forwardable
|
4
|
+
def_delegator :@calendar, :month_title
|
4
5
|
|
5
|
-
def initialize(
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@month_header = [[obj_calendar.month_title]]
|
6
|
+
def initialize(calendar)
|
7
|
+
@calendar = calendar
|
8
|
+
@month_header = [[month_title]]
|
9
9
|
@day_of_week = [Mcalendar::DAY_OF_WEEK]
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@
|
14
|
-
@
|
15
|
-
@day_height = @calendar.size > 5 ? 20 : 20
|
16
|
-
@text_height = @calendar.size > 5 ? 30 : 40
|
10
|
+
|
11
|
+
schedule = Mcalendar::Schedule.new(calendar)
|
12
|
+
@weekly_schedule = schedule.daily_schedule.each_slice(7).map
|
13
|
+
@day_height = @weekly_schedule.size > 5 ? 20 : 20
|
14
|
+
@text_height = @weekly_schedule.size > 5 ? 30 : 40
|
17
15
|
|
18
16
|
super(page_size: 'A4', margin: 20)
|
19
17
|
calendar_render
|
@@ -36,8 +34,8 @@ module Mcalendar
|
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
|
-
def
|
40
|
-
@
|
37
|
+
def days_schedule
|
38
|
+
@weekly_schedule.each do |c|
|
41
39
|
row_day = c.map {|x| (x.class == Struct::ConfigDay) ? x.day : x}
|
42
40
|
row_color = c.map {|x| (x.class == Struct::ConfigDay) ? x.day_color : :black}
|
43
41
|
row_text = c.map do |x|
|
@@ -80,7 +78,7 @@ module Mcalendar
|
|
80
78
|
stroke_bounds
|
81
79
|
month_header
|
82
80
|
week_header
|
83
|
-
|
81
|
+
days_schedule
|
84
82
|
end
|
85
83
|
end
|
86
84
|
|
data/lib/mcalendar/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module Mcalendar
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
1
|
+
module Mcalendar
|
2
|
+
VERSION = "0.4.0"
|
3
|
+
end
|
data/lib/mcalendar.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
require 'date'
|
2
|
-
require "prawn"
|
3
|
-
require "prawn/table"
|
4
|
-
require "optparse"
|
5
|
-
|
6
|
-
|
7
|
-
require_relative 'mcalendar/
|
8
|
-
require_relative 'mcalendar/
|
9
|
-
require_relative 'mcalendar/
|
10
|
-
require_relative 'mcalendar/
|
11
|
-
require_relative 'mcalendar/
|
12
|
-
require_relative 'mcalendar/
|
1
|
+
require 'date'
|
2
|
+
require "prawn"
|
3
|
+
require "prawn/table"
|
4
|
+
require "optparse"
|
5
|
+
require 'forwardable'
|
6
|
+
|
7
|
+
require_relative 'mcalendar/calendar'
|
8
|
+
require_relative 'mcalendar/command'
|
9
|
+
require_relative 'mcalendar/config'
|
10
|
+
require_relative 'mcalendar/holiday'
|
11
|
+
require_relative 'mcalendar/options'
|
12
|
+
require_relative 'mcalendar/output_pdf'
|
13
|
+
require_relative 'mcalendar/version'
|
data/mcalendar.gemspec
CHANGED
@@ -1,28 +1,32 @@
|
|
1
|
-
require_relative 'lib/mcalendar/version'
|
2
|
-
|
3
|
-
Gem::Specification.new do |spec|
|
4
|
-
spec.name = "mcalendar"
|
5
|
-
spec.version = Mcalendar::VERSION
|
6
|
-
spec.authors = ["icm7216"]
|
7
|
-
spec.email = ["icm7216d@gmail.com"]
|
8
|
-
|
9
|
-
spec.summary = %q{Ruby Monthly calendar}
|
10
|
-
spec.description = %q{Ruby Monthly Calendar, Console and pdf}
|
11
|
-
spec.homepage = "https://github.com/icm7216/mcalendar"
|
12
|
-
spec.license = "MIT"
|
13
|
-
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
-
|
15
|
-
# Specify which files should be added to the gem when it is released.
|
16
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
-
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
-
end
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
|
24
|
-
spec.
|
25
|
-
spec.
|
26
|
-
|
27
|
-
spec.add_development_dependency "
|
28
|
-
|
1
|
+
require_relative 'lib/mcalendar/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "mcalendar"
|
5
|
+
spec.version = Mcalendar::VERSION
|
6
|
+
spec.authors = ["icm7216"]
|
7
|
+
spec.email = ["icm7216d@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Ruby Monthly calendar}
|
10
|
+
spec.description = %q{Ruby Monthly Calendar, Console and pdf}
|
11
|
+
spec.homepage = "https://github.com/icm7216/mcalendar"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_runtime_dependency "prawn"
|
25
|
+
spec.add_runtime_dependency "prawn-table"
|
26
|
+
|
27
|
+
spec.add_development_dependency "test-unit"
|
28
|
+
spec.add_development_dependency "test-unit-rr"
|
29
|
+
spec.add_development_dependency "prawn"
|
30
|
+
spec.add_development_dependency "prawn-table"
|
31
|
+
spec.add_development_dependency "rake"
|
32
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcalendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icm7216
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: prawn
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: prawn-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
13
41
|
- !ruby/object:Gem::Dependency
|
14
42
|
name: test-unit
|
15
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +94,20 @@ dependencies:
|
|
66
94
|
- - ">="
|
67
95
|
- !ruby/object:Gem::Version
|
68
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
69
111
|
description: Ruby Monthly Calendar, Console and pdf
|
70
112
|
email:
|
71
113
|
- icm7216d@gmail.com
|
@@ -96,7 +138,7 @@ homepage: https://github.com/icm7216/mcalendar
|
|
96
138
|
licenses:
|
97
139
|
- MIT
|
98
140
|
metadata: {}
|
99
|
-
post_install_message:
|
141
|
+
post_install_message:
|
100
142
|
rdoc_options: []
|
101
143
|
require_paths:
|
102
144
|
- lib
|
@@ -111,8 +153,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
153
|
- !ruby/object:Gem::Version
|
112
154
|
version: '0'
|
113
155
|
requirements: []
|
114
|
-
rubygems_version: 3.
|
115
|
-
signing_key:
|
156
|
+
rubygems_version: 3.2.17
|
157
|
+
signing_key:
|
116
158
|
specification_version: 4
|
117
159
|
summary: Ruby Monthly calendar
|
118
160
|
test_files: []
|