kamisaku 0.4.1 → 0.4.3

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: 60a3dc3cc7212e2e7f161aaac32c7ff2ed0480a6e9282d38580a4a179df387d5
4
- data.tar.gz: 475477cd26f0190e240133ead67e367f1a64539e2bdd21574c76d8e3284b4821
3
+ metadata.gz: cfdf7ddf6a45f5c5794ad3e1e820b07e38ab7ad24188cca2c9fcf637ccdb0ef1
4
+ data.tar.gz: 1cc9d43c15c69a760d22bb78f77b7d8e3e75f38005686f3e38f48f9adfcb16f2
5
5
  SHA512:
6
- metadata.gz: 9c376919d7dde1c68506dceb3f9aec9e447edbd4dec8211e0e49fbcea00c809f8752f04ec908a517fec2016c50646a85472d26fe1f5d7c49d80d4f8d948d4e65
7
- data.tar.gz: efd056f25b356c0cb2ca24a9f75d0c760db7d2d51f9e0d5cf27749e7d144c81f85c17c7e4814f98813781e30b874facff8402f8fbd8ead50cf235f3e83cbc063
6
+ metadata.gz: 9dae789b198dd96799c93261b6351c5f720d45ca3612f8df2fcb46df161b5ccee25b5d9bdf8a9cbaa341e7a5ffaccca0021eedab62ff7c6571f94da388eded5a
7
+ data.tar.gz: 2600ff04de0ce42018a5a1148c52d3a0ed9ff9af9ba96a810bc20d4eecfec982abbc32c8a67b0427458b7071bf26e23fbbd7a4994f60c65697ecd1742187fcac
data/CHANGELOG.md CHANGED
@@ -5,18 +5,20 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
9
-
10
- ### Added
8
+ ## [0.4.3] - 2026.01.01
11
9
 
12
10
  ### Changed
11
+ - Update YAML parsing error messages
13
12
 
14
- ### Removed
13
+ ## [0.4.2] - 2025.12.31
14
+
15
+ ### Changed
16
+ - Use symbols for template names internally
15
17
 
16
18
  ## [0.4.1] - 2025.06.09
17
19
 
18
20
  ### Changed
19
- - Fix `Kamisaku::BirthdayInvitationContentValidator` template listing
21
+ - Fix `Kamisaku::BirthdayInvitationContentValidator` template listing
20
22
 
21
23
  ## [0.4.0] - 2025.06.09
22
24
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamisaku (0.4.1)
4
+ kamisaku (0.4.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # 📃 Kamisaku
2
2
 
3
- *Build resume PDF from a yaml text file.*
3
+ *Build resume PDF from a YAML text file.*
4
4
 
5
5
  🚀 See it in action at [https://kamisaku.sinaru.com/](https://kamisaku.sinaru.com/?utm_source=github).
6
6
 
@@ -8,10 +8,18 @@
8
8
 
9
9
  ![Kamisaku](kamisaku.png)
10
10
 
11
- See [examples](/examples) directory for sample generated PDF files based of [templates](/lib/templates).
12
-
13
11
  ## Templates
14
- For a list of templates availble for PDF generation, check the [examples](/examples) directory where each directory name is a template name.
12
+
13
+ For a list of templates available for PDF generation, check the [examples](/examples) directory where each directory
14
+ name is a template name.
15
+
16
+ The templates are simple ERB files. You can find the templates in [`/lib/templates`](/lib/templates).
17
+
18
+ ## Example YAML files
19
+
20
+ Each type of document (e.g., resume) has its own schema based of YAML. There are example YAML files for the schemas for
21
+ each document type in `/lib/schema`. For example, for resume, see [`/lib/schema/resume/example.yml`](/lib/schema/resume/example.yml).
22
+ You can use them to try the PDF generation.
15
23
 
16
24
  ## Installation
17
25
 
@@ -23,7 +31,7 @@ This is a Ruby gem. So you can either install as a gem or clone the repo and use
23
31
  - Chrome must be accessible from the terminal as `google-chrome`.
24
32
  - Kamisaku uses Chrome's [headless mode](https://developer.chrome.com/docs/chromium/headless/) to generate PDF files.
25
33
  - Ensure `exiftool` is installed available in command line.
26
- - exiftool is used to soft remove metadata added by chrome in the PDF file.
34
+ - exiftool is used to soft-remove metadata added by chrome in the PDF file.
27
35
 
28
36
  Add this line to your application's Gemfile:
29
37
 
@@ -42,9 +50,9 @@ $ gem install kamisaku
42
50
 
43
51
  ## Usage
44
52
 
45
- First we need to have a `yaml` file or a string with the correct schema data structure for the type of the PDF you are generating.
53
+ First, we need to have a YAML file or a string with the correct schema data structure for the type of the PDF you are generating.
46
54
 
47
- For the list of schemas, check `lib/schema` folder. E.g. For resume it is `lib/schema/resume/schema.yml`.
55
+ For the list of schemas, check `lib/schema` folder. E.g. For resume, it is `lib/schema/resume/schema.yml`.
48
56
 
49
57
  ## Generating PDF
50
58
 
@@ -53,7 +61,7 @@ For the list of schemas, check `lib/schema` folder. E.g. For resume it is `lib/s
53
61
  Once you have the YAML text file, feed it into the `bin/console` and specify the output location.
54
62
 
55
63
  ```bash
56
- bin/console -c examples/john_doe.yml -o examples/paper/john_doe.pdf -k resume -t paper
64
+ bin/console -c lib/schema/resume/example.yml -o ~/Downloads/test_resume.pdf -k resume -t paper
57
65
  ```
58
66
 
59
67
  #### Bash options
@@ -80,31 +88,40 @@ pdf.write_to('/path/to/generated_file.pdf')
80
88
 
81
89
  ## Development
82
90
 
83
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
91
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
92
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
84
93
 
85
94
  To install this gem onto your local machine, run `bundle exec rake install`.
86
95
 
87
96
  ### Create or Update a template
88
97
 
89
- To a new template, create a folder with template name at `lib/templates`. Additionally add the template name to `Kamisaku::TemplateHelpers::TEMPLATES` list.
98
+ To a new template, create a folder with template name at `lib/templates`. Additionally add the template name
99
+ to `Kamisaku::TemplateHelpers::TEMPLATES` list.
90
100
 
91
101
  Inside this folder, create `template.html.erb`.
92
102
 
93
- The template will be exposed to a Ruby hash variable called `data`. This data represent the data in the YAML file as a hash.
103
+ The template will be exposed to a Ruby hash variable called `data`. This data represents the data in the YAML file as a hash.
94
104
  So you can use the Ruby hash methods to access and render the values.
95
105
 
96
106
  In addition, the template helper methods defined at `lib/kamisaku/template_helpers.rb` will also be available to use directly.
97
107
 
98
- To test and build the template, you can run `scripts/rebuild_examples.rb -t <name of new template>`. This will create the PDF using the `lib/schema/example.yml`
108
+ To test and build the template, you can run `scripts/rebuild_examples.rb -t <name of new template>`. This will
109
+ create the PDF using the `lib/schema/example.yml`
99
110
  and place it in `examples/` folder.
100
111
 
101
112
  ### Releasing a new gem version
102
113
 
103
- 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
114
+ To release a new version;
115
+ 1. update the version number in `version.rb`
116
+ 2. run `bundle update`
117
+ 3. commit the changes
118
+ 2. then run `bundle exec rake release`
119
+ which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
104
120
 
105
121
  ## Contributing
106
122
 
107
- Bug reports and pull requests are welcome on GitHub at https://github.com/sinaru/kamisaku. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/kamisaku/blob/main/CODE_OF_CONDUCT.md).
123
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sinaru/kamisaku. This project is
124
+ intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/kamisaku/blob/main/CODE_OF_CONDUCT.md).
108
125
 
109
126
  ## License
110
127
 
@@ -112,4 +129,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
112
129
 
113
130
  ## Code of Conduct
114
131
 
115
- Everyone interacting in the Kamisaku project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kamisaku/blob/main/CODE_OF_CONDUCT.md).
132
+ Everyone interacting in the Kamisaku project's codebases, issue trackers, chat rooms and mailing
133
+ lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/kamisaku/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ require "rake/testtask"
6
6
  Rake::TestTask.new(:test) do |t|
7
7
  t.libs << "test"
8
8
  t.libs << "lib"
9
- t.test_files = FileList["test/**/test_*.rb"]
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
10
  end
11
11
 
12
12
  require "rubocop/rake_task"
@@ -1,6 +1,6 @@
1
1
  module Kamisaku
2
2
  class BirthdayInvitationContentValidator < BaseContentValidator
3
- TEMPLATES = %w[
3
+ TEMPLATES = %i[
4
4
  dino
5
5
  ].freeze
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Kamisaku
2
2
  class ResumeContentValidator < Kamisaku::BaseContentValidator
3
- TEMPLATES = %w[
3
+ TEMPLATES = %i[
4
4
  paper
5
5
  sleek
6
6
  zenith
@@ -4,8 +4,12 @@ module Kamisaku
4
4
  module Helpers
5
5
  def self.yaml_str_to_content_hash(yaml_str)
6
6
  Psych.safe_load(yaml_str, symbolize_names: true, aliases: false, freeze: true)
7
- rescue Psych::SyntaxError, Psych::DisallowedClass, Psych::AliasesNotEnabled => error
8
- raise Kamisaku::Error.new error.message
7
+ rescue Psych::SyntaxError => error
8
+ raise Kamisaku::Error, "Syntax error at line #{error.line}"
9
+ rescue Psych::AliasesNotEnabled => _error
10
+ raise Kamisaku::Error, "Aliases are not enabled in yaml text"
11
+ rescue Psych::DisallowedClass
12
+ raise Kamisaku::Error, error.message
9
13
  end
10
14
 
11
15
  def self.remove_metadata_from_pdf_file(file_path)
data/lib/kamisaku/pdf.rb CHANGED
@@ -11,13 +11,14 @@ module Kamisaku
11
11
 
12
12
  def initialize(content_hash:, category:, template:)
13
13
  @content_hash = content_hash
14
- @category = category
15
- @template = template
14
+ @category = category.to_sym
15
+ @template = template.to_sym
16
+
16
17
  raise Error, "Invalid template name '#{template}'" unless template.is_a?(String)
17
- validator_klass = CONTENT_VALIDATOR_MAP[category.to_sym]
18
- raise Error, "Invalid template name '#{category}'" unless validator_klass
18
+ validator_klass = CONTENT_VALIDATOR_MAP[@category]
19
+ raise Error, "Invalid template name '#{@category}'" unless validator_klass
19
20
  validator_klass.new(content_hash:).validate!
20
- raise Error, "Invalid template name '#{template}'" unless validator_klass::TEMPLATES.include?(template)
21
+ raise Error, "Invalid template name '#{@template}'" unless validator_klass::TEMPLATES.include?(@template)
21
22
  end
22
23
 
23
24
  def write_to(pdf_location)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamisaku
4
- VERSION = "0.4.1"
4
+ VERSION = "0.4.3"
5
5
  end
@@ -27,11 +27,11 @@ end.parse!
27
27
 
28
28
  categories = options[:category] ? [options[:category]] : Kamisaku::PDF::CONTENT_VALIDATOR_MAP.keys
29
29
 
30
- Kamisaku::PDF::CONTENT_VALIDATOR_MAP.select {|key, value| categories.include? key }.each do | category, klass |
30
+ Kamisaku::PDF::CONTENT_VALIDATOR_MAP.slice(*categories).each do |category, klass|
31
31
  templates = klass::TEMPLATES
32
32
 
33
33
  # Use specified template or all templates
34
- templates = options[:template] ? templates.select {|t| t == options[:template] } : templates
34
+ templates = options[:template] ? templates.select { |t| t == options[:template] } : templates
35
35
 
36
36
  templates.each do |template|
37
37
  template_dir = File.expand_path("../examples/#{category}/#{template}", __dir__)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kamisaku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sinaru Gunawardena