kamisaku 0.4.1 → 0.4.2

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: 4292c2079171e643c3b2cbc54a57710c23e5b2abcc8689b03dcb25ecef691af2
4
+ data.tar.gz: f101f3fae445b34b437612c29bb64e067c27d4f46e036d0c3e4d2d1d32019ddc
5
5
  SHA512:
6
- metadata.gz: 9c376919d7dde1c68506dceb3f9aec9e447edbd4dec8211e0e49fbcea00c809f8752f04ec908a517fec2016c50646a85472d26fe1f5d7c49d80d4f8d948d4e65
7
- data.tar.gz: efd056f25b356c0cb2ca24a9f75d0c760db7d2d51f9e0d5cf27749e7d144c81f85c17c7e4814f98813781e30b874facff8402f8fbd8ead50cf235f3e83cbc063
6
+ metadata.gz: 281c18ed0c9ab2d7131c11cda21ba48be132fb5e09ac0aac738bb6e4f53644b767778dc2cd08c622f4e9a597aeaa2c7a28b15f6752beb8e778711bd331e805c7
7
+ data.tar.gz: 8f07ab76298f53cd2d75790797d4a5823850ad5108f23dfcb9cdcf8e393b18417d8e525bbde89aa837831480b2a7392074826bddbc53bda285b0d618df6f7db3
data/CHANGELOG.md CHANGED
@@ -13,10 +13,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
+ ## [0.4.2] - 2025.12.31
17
+
18
+ ### Changed
19
+ - Use symbols for template names internally
20
+
16
21
  ## [0.4.1] - 2025.06.09
17
22
 
18
23
  ### Changed
19
- - Fix `Kamisaku::BirthdayInvitationContentValidator` template listing
24
+ - Fix `Kamisaku::BirthdayInvitationContentValidator` template listing
20
25
 
21
26
  ## [0.4.0] - 2025.06.09
22
27
 
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.2)
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,36 @@ 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, update the version number in `version.rb`, and then run `bundle exec rake release`,
115
+ 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
116
 
105
117
  ## Contributing
106
118
 
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).
119
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sinaru/kamisaku. This project is
120
+ 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
121
 
109
122
  ## License
110
123
 
@@ -112,4 +125,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
112
125
 
113
126
  ## Code of Conduct
114
127
 
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).
128
+ Everyone interacting in the Kamisaku project's codebases, issue trackers, chat rooms and mailing
129
+ 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
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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sinaru Gunawardena