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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac015db20949925d06ccf0e5f37e6cda175d161c73761e716aad6038c7280511
4
- data.tar.gz: 28d599a9eb429270732f2e7d216eb0969212325a1f42efad84da7fc94a92ddfe
3
+ metadata.gz: 133f621aecebd01516320415aa7463d70691d31647a0de2b98b4cb5bc370d806
4
+ data.tar.gz: 2d783d1a2c276304e2113734ed5b351ee86a564e446aaa5039ada4f4fa76f45e
5
5
  SHA512:
6
- metadata.gz: f5d978d7361405ac362dde8e36f1a435a9e4391673a92350b9bbe1b3659a569374e764a92dab89686aab3e20ee01d9650d04d973063210540278f8bc67f8d13f
7
- data.tar.gz: 9750e02a0e79139e039dccc4fb6bfa46e0090b4193f7006378717bf81940b9aca214057ce1605dd51a68258ff8f450cf2757b0a0bf9c4773b001b13565c645fe
6
+ metadata.gz: 189e94a8ef9278e512939794b496435b02c0c87601a3c1c6ac01de384b5899acd59dbdd790db1fc4b99cc22336bf3a4bcdf494aab2fed6fc4873e1a08c0d3320
7
+ data.tar.gz: 19b83125e2404cb5e4debbebd1bfbce4da0e40cc87211fe1ab55682d793ecd1f9564d7113d81c18ba384c80f545e6aaa71171f8dc1157ccb6d3c09f676fe745c
@@ -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
- @outputpdf.render_file(pdf_filename)
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
@@ -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
@@ -1,3 +1,3 @@
1
1
  module Mcalendar
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
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.5
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-04-29 00:00:00.000000000 Z
11
+ date: 2022-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawn