mcalendar 0.5.5 → 0.6.0
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/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: 133f621aecebd01516320415aa7463d70691d31647a0de2b98b4cb5bc370d806
|
4
|
+
data.tar.gz: 2d783d1a2c276304e2113734ed5b351ee86a564e446aaa5039ada4f4fa76f45e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189e94a8ef9278e512939794b496435b02c0c87601a3c1c6ac01de384b5899acd59dbdd790db1fc4b99cc22336bf3a4bcdf494aab2fed6fc4873e1a08c0d3320
|
7
|
+
data.tar.gz: 19b83125e2404cb5e4debbebd1bfbce4da0e40cc87211fe1ab55682d793ecd1f9564d7113d81c18ba384c80f545e6aaa71171f8dc1157ccb6d3c09f676fe745c
|
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.0
|
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-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|