Compare commits

...

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

  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,7 +7,6 @@ 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)
@ -27,6 +26,7 @@ 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

@ -1,17 +1,39 @@
# Agenda PDF
# AgendaPdf
## 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.
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.
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.
TODO: Delete this and the text above, and describe your gem
## Setup
- Install ruby 3.0.2
- `bundle install`
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'agenda_pdf'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install agenda_pdf
## Usage
`bundle exec agenda_pdf -m <yyyy-mm-dd> -o <output_file>.pdf`
Example:
TODO: Write usage instructions here
## 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
`bundle exec agenda_pdf -m 2023-08-21 -o test.pdf`
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

@ -33,13 +33,12 @@ 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

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

@ -17,7 +17,7 @@ class OptionsParser
end
def month
@options[:month] || DateTime.now
@options[:month] || DateTime.now.month
end
def verbose
@ -30,11 +30,11 @@ class OptionsParser
OptionParser.new do |opts|
opts.banner = "Usage: agenda_pdf [options]"
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
opts.on("-m", "--month", "Generates a pdf for current month") do |v|
@options[:month] = DateTime.parse(v) rescue DateTime.now.month
end
opts.on("-oPATH", "--path=PATH", "The output file path") do |v|
opts.on("-o", "--path", "The output file path") do |v|
@options[:path] = Pathname.new(v)
end

@ -1,34 +1,15 @@
require 'prawn'
require 'byebug'
class PdfGenerator < Prawn::Document
def initialize(path, &block)
super()
initialize_document
super()
instance_eval &block
finalize_document(path)
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
def initialize_document; end

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

Loading…
Cancel
Save