Compare commits

...

No commits in common. 'master' and 'main' have entirely different histories.
master ... main

  1. 4
      Gemfile.lock
  2. 42
      README.md
  3. 3
      agenda_pdf.gemspec
  4. 5
      lib/agenda_pdf.rb
  5. 8
      lib/agenda_pdf/options_parser.rb
  6. 23
      lib/agenda_pdf/pdf_generator.rb
  7. 2
      lib/agenda_pdf/version.rb

@ -7,6 +7,7 @@ PATH
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
byebug (11.1.3)
diff-lcs (1.5.0) diff-lcs (1.5.0)
pdf-core (0.9.0) pdf-core (0.9.0)
prawn (2.4.0) prawn (2.4.0)
@ -26,7 +27,6 @@ GEM
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.10.0) rspec-support (~> 3.10.0)
rspec-support (3.10.3) rspec-support (3.10.3)
thor (1.2.1)
ttfunk (1.7.0) ttfunk (1.7.0)
PLATFORMS PLATFORMS
@ -35,10 +35,10 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
agenda_pdf! agenda_pdf!
bundler (~> 2.2.22) bundler (~> 2.2.22)
byebug (~> 11.1)
prawn (~> 2.4) prawn (~> 2.4)
rake (~> 10.0) rake (~> 10.0)
rspec (~> 3.0) rspec (~> 3.0)
thor (~> 1.2)
RUBY VERSION RUBY VERSION
ruby 3.0.2p107 ruby 3.0.2p107

@ -1,39 +1,17 @@
# AgendaPdf # Agenda PDF
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/agenda_pdf`. To experiment with that code, run `bin/console` for an interactive prompt. ## Purpose
On the [Remarkable](https://remarkable.com/) you can use a PDF as a template. This will fill the blank page with the content of the PDF and you can write over it.
TODO: Delete this and the text above, and describe your gem My wife loves to do her agenda on the Remarkable; so I created this gem so she can have a tool to do it alone whenever she wants.
## Installation ## Setup
- Install ruby 3.0.2
Add this line to your application's Gemfile: - `bundle install`
```ruby
gem 'agenda_pdf'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install agenda_pdf
## Usage ## Usage
`bundle exec agenda_pdf -m <yyyy-mm-dd> -o <output_file>.pdf`
TODO: Write usage instructions here Example:
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/agenda_pdf.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). `bundle exec agenda_pdf -m 2023-08-21 -o test.pdf`

@ -33,12 +33,13 @@ Gem::Specification.new do |spec|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end end
spec.bindir = "bin" spec.bindir = "bin"
spec.executables = ['agenda_pdf'] spec.executables = ['agenda_pdf']
spec.require_paths = ["lib"] spec.require_paths = ["lib"]
spec.add_development_dependency "bundler", "~> 2.2.22" spec.add_development_dependency "bundler", "~> 2.2.22"
spec.add_development_dependency "rake", "~> 10.0" spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "rspec", "~> 3.0" spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "byebug", "~> 11.1"
spec.add_dependency "prawn", "~> 2.4" spec.add_dependency "prawn", "~> 2.4"
end end

@ -10,9 +10,6 @@ module AgendaPdf
def self.execute(argv) def self.execute(argv)
options = OptionsParser.new options = OptionsParser.new
PdfGenerator.new(options.path) do PdfGenerator.generate_month(options.month, path: options.path)
text 'hello world'
text argv.to_s
end
end end
end end

@ -17,7 +17,7 @@ class OptionsParser
end end
def month def month
@options[:month] || DateTime.now.month @options[:month] || DateTime.now
end end
def verbose def verbose
@ -30,11 +30,11 @@ class OptionsParser
OptionParser.new do |opts| OptionParser.new do |opts|
opts.banner = "Usage: agenda_pdf [options]" opts.banner = "Usage: agenda_pdf [options]"
opts.on("-m", "--month", "Generates a pdf for current month") do |v| opts.on("-mMONTH", "--month=MONTH", "Generates a pdf for given month (ex: 2021-02-01)") do |v|
@options[:month] = DateTime.parse(v) rescue DateTime.now.month @options[:month] = DateTime.parse(v) rescue DateTime.now
end 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) @options[:path] = Pathname.new(v)
end end

@ -1,15 +1,34 @@
require 'prawn' require 'prawn'
require 'byebug'
class PdfGenerator < Prawn::Document class PdfGenerator < Prawn::Document
def initialize(path, &block) def initialize(path, &block)
super()
initialize_document initialize_document
instance_eval &block super()
finalize_document(path) finalize_document(path)
end end
class << self
def generate_month(datetime, path:)
month = datetime.month
year = datetime.year
start_date = DateTime.new(year, month)
end_date = start_date.next_month
new(path) do
(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
end
end
end
end
protected protected
def initialize_document; end def initialize_document; end

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

Loading…
Cancel
Save