kamisaku 0.3.1 → 0.3.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: '08311183150f22bf9897f33d7ecb93616573e99b90a49455efd27747316b3a5b'
4
- data.tar.gz: b198531b11fdf5b409c1b9c39be5ca04c64a1b9174a867f38e93f7d928f534e9
3
+ metadata.gz: 3c2b9b3a11f581cc1ee84330c7813cfc6e2875616de64d41fde78ad710891916
4
+ data.tar.gz: a54225bf6e5851ead275215047393339cbca5bd8834d9a2030fb4a121b0aded2
5
5
  SHA512:
6
- metadata.gz: 621551dfa5fa5bf482ccccf5e8fb72a7a12b2736ed397f8a813f85274f8f33db09e1ffed4d1846dbd3dbb75f2ffc7abb53dd719229c1d00946945050949517d8
7
- data.tar.gz: 6434717f692966c901becca7a7573ee69ed69b63516bdf356ea826c7d27302255dad520e72ac86519b87213ade8319d3a064de0f9991c5cf69f3242a3918aa20
6
+ metadata.gz: ba93279fffb6b6f6af37123a580d6084bd3d570870167c7eb912ce3950b18d8affa157eb1adbc253f463bf293803270ef17c4b66eec26b444b4f3c7754005eda
7
+ data.tar.gz: b097d987aa90f78b613738e096e8ffb4218dba1de43e5ff796d3092e21a6a07ed47d803b126baab0f3bc8aebc01326254adac3a1dfafab4f8d6c830bca1396c4
data/CHANGELOG.md CHANGED
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
 
14
14
  ### Removed
15
15
 
16
+ ## [0.3.2] - 2025.06.01
17
+
18
+ ### Added
19
+ - Template name validation to `Kamisaku::PDF` interface
20
+
16
21
  ## [0.3.1] - 2025-06-01
17
22
 
18
23
  ### Changed
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kamisaku (0.3.1)
4
+ kamisaku (0.3.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -2,15 +2,47 @@
2
2
 
3
3
  *Build a CV PDF from a yaml text file.*
4
4
 
5
+ 🚀 See it in action at [https://kamisaku.sinaru.com/](https://kamisaku.sinaru.com/).
6
+
5
7
  [![Gem Version](https://badge.fury.io/rb/kamisaku.svg)](https://badge.fury.io/rb/kamisaku)
6
8
 
7
9
  ![Kamisaku](kamisaku.png)
8
10
 
9
11
  See [examples](/examples) directory for sample generated PDF files based of [templates](/lib/templates).
10
12
 
13
+ ## Templates
14
+ For a list of templates availble for CV generation, check the [examples](/examples) directory where each directory name is a template name.
15
+
16
+ ## Installation
17
+
18
+ This is a Ruby gem. So you can either install as a gem or clone the repo and use `bin/console` file run from terminal.
19
+
20
+ ### Dependency Requirement
21
+ - Ruby 3.4.3
22
+ - Ensure that [Google Chrome](https://www.google.com/chrome/) is installed.
23
+ - Chrome must be accessible from the terminal as `google-chrome`.
24
+ - Kamisaku uses Chrome's [headless mode](https://developer.chrome.com/docs/chromium/headless/) to generate PDF files.
25
+ - Ensure `exiftool` is installed available in command line.
26
+ - exiftool is used to soft remove metadata added by chrome in the PDF file.
27
+
28
+ Add this line to your application's Gemfile:
29
+
30
+ ```ruby
31
+ gem 'kamisaku'
32
+ ```
33
+
34
+ And then execute:
35
+ ```bash
36
+ $ bundle install
37
+ ```
38
+ Or install it yourself as:
39
+ ```bash
40
+ $ gem install kamisaku
41
+ ```
42
+
11
43
  ## Usage
12
44
 
13
- First we need to have a `yaml` file with the CV data. The yaml file supports following sections.
45
+ First we need to have a `yaml` file or a string with the CV data. The gem supports the following sections.
14
46
 
15
47
  ```yaml
16
48
  version: 1
@@ -69,36 +101,6 @@ education:
69
101
  - # Things you have achieved or did
70
102
  ```
71
103
 
72
- ## Template
73
- For a list of templates availble for CV generation, check the [examples](/examples) directory where each directory name is a template name.
74
-
75
- ## Installation
76
-
77
- This is a Ruby gem. So you can either install as a gem or clone the repo and use `bin/console` file run from terminal.
78
-
79
- ### Dependency Requirement
80
- - Ruby 3.4.3
81
- - Ensure that [Google Chrome](https://www.google.com/chrome/) is installed.
82
- - Chrome must be accessible from the terminal as `google-chrome`.
83
- - Kamisaku uses Chrome's [headless mode](https://developer.chrome.com/docs/chromium/headless/) to generate PDF files.
84
- - Ensure `exiftool` is installed available in command line.
85
- - exiftool is used to soft remove metadata added by chrome in the PDF file.
86
-
87
- Add this line to your application's Gemfile:
88
-
89
- ```ruby
90
- gem 'kamisaku'
91
- ```
92
-
93
- And then execute:
94
- ```bash
95
- $ bundle install
96
- ```
97
- Or install it yourself as:
98
- ```bash
99
- $ gem install kamisaku
100
- ```
101
-
102
104
  ## Generating PDF
103
105
 
104
106
  ### Using terminal
@@ -115,6 +117,21 @@ bin/console -c examples/paper/john_doe.yml -o examples/paper/john_doe.pdf -t pa
115
117
  - `-o` output location for the PDF file including the name
116
118
  - `-t` template to use
117
119
 
120
+ ### Using `PDF` class
121
+
122
+ ```ruby
123
+ # Have a YAML string
124
+ yaml_str = "..."
125
+ # Create a hash
126
+ content_hash = Kamisaku::Helpers.yaml_str_to_content_hash(yaml_str)
127
+ # Validate the hash is correct. If there is any issue, it will raise a ` Kamisaku::Error ` exception.
128
+ Kamisaku::ContentValidator.new(content_hash:).validate!
129
+ # create a pdf instance
130
+ pdf = Kamisaku::PDF.new(content_hash:, template: "paper")
131
+ # create the PDF at given path
132
+ pdf.write_to('/path/to/generated_file.pdf')
133
+ ```
134
+
118
135
  ## Development
119
136
 
120
137
  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.
data/lib/kamisaku/pdf.rb CHANGED
@@ -6,6 +6,8 @@ module Kamisaku
6
6
  @content_hash = content_hash
7
7
  @template = template || "sleek"
8
8
  ContentValidator.new(content_hash:).validate!
9
+ raise Error, "Invalid template name '#{template}'" unless template.is_a?(String)
10
+ raise Error, "Invalid template name '#{template}'" unless TemplateHelpers::TEMPLATES.include? @template
9
11
  end
10
12
 
11
13
  def write_to(pdf_location)
@@ -2,6 +2,8 @@ require "date"
2
2
 
3
3
  module Kamisaku
4
4
  module TemplateHelpers
5
+ TEMPLATES = %w[paper sleek].freeze
6
+
5
7
  def month_name(month_int)
6
8
  return "" if month_int.nil?
7
9
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kamisaku
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
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.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sinaru Gunawardena