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 +4 -4
- data/CHANGELOG.md +6 -1
- data/Gemfile.lock +1 -1
- data/README.md +29 -15
- data/Rakefile +1 -1
- data/lib/kamisaku/content_validators/birthday_invitation_content_validator.rb +1 -1
- data/lib/kamisaku/content_validators/resume_content_validator.rb +1 -1
- data/lib/kamisaku/pdf.rb +6 -5
- data/lib/kamisaku/version.rb +1 -1
- data/scripts/rebuild_examples.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4292c2079171e643c3b2cbc54a57710c23e5b2abcc8689b03dcb25ecef691af2
|
|
4
|
+
data.tar.gz: f101f3fae445b34b437612c29bb64e067c27d4f46e036d0c3e4d2d1d32019ddc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
24
|
+
- Fix `Kamisaku::BirthdayInvitationContentValidator` template listing
|
|
20
25
|
|
|
21
26
|
## [0.4.0] - 2025.06.09
|
|
22
27
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 📃 Kamisaku
|
|
2
2
|
|
|
3
|
-
*Build resume PDF from a
|
|
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
|

|
|
10
10
|
|
|
11
|
-
See [examples](/examples) directory for sample generated PDF files based of [templates](/lib/templates).
|
|
12
|
-
|
|
13
11
|
## Templates
|
|
14
|
-
|
|
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
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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`,
|
|
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
|
|
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
|
|
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
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
|
|
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)
|
data/lib/kamisaku/version.rb
CHANGED
data/scripts/rebuild_examples.rb
CHANGED
|
@@ -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.
|
|
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__)
|