mcalendar 0.5.5 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -1
- data/lib/mcalendar/command.rb +47 -18
- data/lib/mcalendar/options.rb +2 -0
- data/lib/mcalendar/version.rb +1 -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: 1b8b4ca4a9ab65f33b16609833ba52b47565da3dd42bba249112ebe0134fe0e7
|
4
|
+
data.tar.gz: 9b4be615e52a0285d55cc686ecef029ec51bd2f8d810a59df9485eeae0b18447
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bab1cee9cde84161543d3ad5dfe912a948929a5473b94e12a7db977dc64df9262cf80573fd57ba8db21ed953576a525ad166139189f3e7454e7323f535a05ba4
|
7
|
+
data.tar.gz: f8ad3f54399e6dd85facaac66e0c8eb73432fd203e2061cf5414f41e5c19f47fe9cbada09a5e2688401aac23279733e63af2d9c4120562c6b6511f9495703e67
|
data/README.md
CHANGED
@@ -142,8 +142,24 @@ You can also use the command option `-f` or `--config=` to load your own `your_s
|
|
142
142
|
>mcalendar -f your_schedule.yml
|
143
143
|
```
|
144
144
|
|
145
|
+
How many Sundays are there this month?
|
146
|
+
Use the command option `-w`, You can easily know this answer.
|
147
|
+
```
|
148
|
+
>mcalendar -w
|
149
|
+
|
150
|
+
Number of days for each day of the week in August 2022
|
151
|
+
-----------------------------------------------------------------------
|
152
|
+
Sun. 4 days. => 7,14,21,28
|
153
|
+
Mon. 5 days. => 1, 8,15,22,29
|
154
|
+
Tue. 5 days. => 2, 9,16,23,30
|
155
|
+
Wed. 5 days. => 3,10,17,24,31
|
156
|
+
Thu. 4 days. => 4,11,18,25
|
157
|
+
Fri. 4 days. => 5,12,19,26
|
158
|
+
Sat. 4 days. => 6,13,20,27
|
159
|
+
```
|
160
|
+
|
145
161
|
|
146
|
-
|
162
|
+
Show help
|
147
163
|
```
|
148
164
|
>mcalendar --help
|
149
165
|
Usage: mcalendar [options]
|
@@ -153,6 +169,7 @@ Usage: mcalendar [options]
|
|
153
169
|
-c, --console output console
|
154
170
|
-f, --config=FILE Use YAML format file.
|
155
171
|
-y, --holidays Display holidays and anniversaries in YAML file
|
172
|
+
-w, --wday Number of days for each day of the week in this month
|
156
173
|
```
|
157
174
|
|
158
175
|
## License
|
data/lib/mcalendar/command.rb
CHANGED
@@ -7,15 +7,53 @@ module Mcalendar
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def initialize(argv)
|
10
|
-
@argv = argv
|
10
|
+
# @argv = argv
|
11
|
+
options = Mcalendar::Options.new.parse(argv)
|
12
|
+
@date = options[:date]
|
13
|
+
|
14
|
+
@console = options[:console]
|
15
|
+
@pdf = options[:pdf]
|
16
|
+
@pdf_name = options[:name]
|
17
|
+
@version = options[:version]
|
18
|
+
@holidays = options[:holidays]
|
19
|
+
@calendar = Mcalendar::Calendar.new(@date.year, @date.month)
|
20
|
+
@schedule = Mcalendar::Schedule.new(@calendar, options)
|
21
|
+
@wday = options[:wday]
|
11
22
|
end
|
12
23
|
|
13
24
|
def output_console
|
14
25
|
puts @calendar.to_s
|
15
26
|
end
|
16
27
|
|
28
|
+
# Number of days for each day of the week in this month.
|
29
|
+
def how_many_days
|
30
|
+
wdays = Mcalendar::DAY_OF_WEEK.map {|w| w.capitalize + "."}
|
31
|
+
wvalues = day_of_weeks.values
|
32
|
+
|
33
|
+
puts "\nNumber of days for each day of the week in #{@date.strftime("%B %Y")}"
|
34
|
+
puts "------------------------------------------------------------"
|
35
|
+
wdays.each_with_index do |wday, idx|
|
36
|
+
puts "#{wday} #{wvalues[idx].size} days. => #{wvalues[idx].join(",")}"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def day_of_weeks
|
42
|
+
wks = @calendar.days.each_slice(7).map(&:to_a)
|
43
|
+
keys = Mcalendar::DAY_OF_WEEK.map(&:downcase).map(&:to_sym)
|
44
|
+
|
45
|
+
vals = (0..6).map do |wd|
|
46
|
+
w = wks.map {|wk| wk[wd]}
|
47
|
+
w.delete(" ")
|
48
|
+
w.compact
|
49
|
+
end
|
50
|
+
|
51
|
+
Hash[keys.zip(vals)]
|
52
|
+
end
|
53
|
+
|
17
54
|
def output_pdf
|
18
|
-
|
55
|
+
outputpdf = Mcalendar::OutputPdf.new(@calendar, @schedule)
|
56
|
+
outputpdf.render_file(pdf_filename)
|
19
57
|
end
|
20
58
|
|
21
59
|
def output_holidays
|
@@ -34,28 +72,19 @@ module Mcalendar
|
|
34
72
|
end
|
35
73
|
|
36
74
|
def execute
|
37
|
-
options = Mcalendar::Options.new.parse(@argv)
|
38
|
-
date = options[:date]
|
39
|
-
console = options[:console]
|
40
|
-
pdf = options[:pdf]
|
41
|
-
@pdf_name = options[:name]
|
42
|
-
version = options[:version]
|
43
|
-
holidays = options[:holidays]
|
44
|
-
|
45
|
-
@calendar = Mcalendar::Calendar.new(date.year, date.month)
|
46
|
-
@schedule = Mcalendar::Schedule.new(@calendar, options)
|
47
|
-
@outputpdf = Mcalendar::OutputPdf.new(@calendar, @schedule)
|
48
|
-
|
49
75
|
# output calendar
|
50
|
-
output_console if console
|
51
|
-
output_pdf if pdf
|
52
|
-
output_holidays if holidays
|
76
|
+
output_console if @console
|
77
|
+
output_pdf if @pdf
|
78
|
+
output_holidays if @holidays
|
53
79
|
|
54
80
|
# both outputs if no options
|
55
|
-
if console.nil? && pdf.nil? && version.nil? && holidays.nil?
|
81
|
+
if @console.nil? && @pdf.nil? && @version.nil? && @holidays.nil? && @wday.nil?
|
56
82
|
output_console
|
57
83
|
output_pdf
|
58
84
|
end
|
85
|
+
|
86
|
+
# Number of days for each day of the week in this month.
|
87
|
+
how_many_days if @wday
|
59
88
|
|
60
89
|
end
|
61
90
|
end
|
data/lib/mcalendar/options.rb
CHANGED
@@ -57,6 +57,8 @@ module Mcalendar
|
|
57
57
|
end
|
58
58
|
|
59
59
|
o.on("-y", "--holidays", "Display holidays and anniversaries in YAML file") { |v| @options[:holidays] = v }
|
60
|
+
|
61
|
+
o.on("-w", "--wday", "Number of days for each day of the week in this month") { |v| @options[:wday] = v }
|
60
62
|
end
|
61
63
|
|
62
64
|
begin
|
data/lib/mcalendar/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icm7216
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|