🐛 Fixes double generation of content for the pdf_generatorx

main
Ervan Silvert 4 years ago
parent d356da89aa
commit b0a97adc96
  1. 4
      Gemfile.lock
  2. 1
      agenda_pdf.gemspec
  3. 2
      lib/agenda_pdf/options_parser.rb
  4. 8
      lib/agenda_pdf/pdf_generator.rb
  5. 2
      lib/agenda_pdf/version.rb

@ -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

@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
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

@ -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

@ -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
@ -19,11 +19,11 @@ class PdfGenerator < Prawn::Document
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

@ -1,3 +1,3 @@
module AgendaPdf
VERSION = "0.1.0"
VERSION = "0.1.1"
end

Loading…
Cancel
Save