diff --git a/Gemfile.lock b/Gemfile.lock index 2da61f9..331bb70 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,6 +7,7 @@ PATH GEM remote: https://rubygems.org/ specs: + byebug (11.1.3) diff-lcs (1.5.0) pdf-core (0.9.0) prawn (2.4.0) @@ -26,7 +27,6 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) rspec-support (3.10.3) - thor (1.2.1) ttfunk (1.7.0) PLATFORMS @@ -35,10 +35,10 @@ PLATFORMS DEPENDENCIES agenda_pdf! bundler (~> 2.2.22) + byebug (~> 11.1) prawn (~> 2.4) rake (~> 10.0) rspec (~> 3.0) - thor (~> 1.2) RUBY VERSION ruby 3.0.2p107 diff --git a/agenda_pdf.gemspec b/agenda_pdf.gemspec index e5ca4e4..42c45a0 100644 --- a/agenda_pdf.gemspec +++ b/agenda_pdf.gemspec @@ -33,12 +33,13 @@ Gem::Specification.new do |spec| `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } end spec.bindir = "bin" - spec.executables = ['agenda_pdf'] + spec.executables = ['agenda_pdf'] spec.require_paths = ["lib"] spec.add_development_dependency "bundler", "~> 2.2.22" spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rspec", "~> 3.0" + spec.add_development_dependency "byebug", "~> 11.1" spec.add_dependency "prawn", "~> 2.4" end diff --git a/lib/agenda_pdf/options_parser.rb b/lib/agenda_pdf/options_parser.rb index 8e5e7e1..0292187 100644 --- a/lib/agenda_pdf/options_parser.rb +++ b/lib/agenda_pdf/options_parser.rb @@ -34,7 +34,7 @@ class OptionsParser @options[:month] = DateTime.parse(v) rescue DateTime.now end - opts.on("-o", "--path", "The output file path") do |v| + opts.on("-oPATH", "--path=PATH", "The output file path") do |v| @options[:path] = Pathname.new(v) end diff --git a/lib/agenda_pdf/pdf_generator.rb b/lib/agenda_pdf/pdf_generator.rb index cb5b3b9..d8cedc8 100644 --- a/lib/agenda_pdf/pdf_generator.rb +++ b/lib/agenda_pdf/pdf_generator.rb @@ -1,11 +1,11 @@ require 'prawn' +require 'byebug' class PdfGenerator < Prawn::Document def initialize(path, &block) - super() initialize_document - instance_eval(&block) + super() finalize_document(path) end @@ -17,13 +17,13 @@ class PdfGenerator < Prawn::Document start_date = DateTime.new(year, month) end_date = start_date.next_month - + new(path) do - (start_date..end_date).each do |day| + (start_date...end_date).to_a.each do |day| text day.year.to_s text day.strftime('%b') text day.strftime('%a %d') - start_new_page unless day == end_date + start_new_page end end end diff --git a/lib/agenda_pdf/version.rb b/lib/agenda_pdf/version.rb index a13d1c7..6675b6f 100644 --- a/lib/agenda_pdf/version.rb +++ b/lib/agenda_pdf/version.rb @@ -1,3 +1,3 @@ module AgendaPdf - VERSION = "0.1.0" + VERSION = "0.1.1" end