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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/README.md +48 -31
- data/lib/kamisaku/pdf.rb +2 -0
- data/lib/kamisaku/template_helpers.rb +2 -0
- data/lib/kamisaku/version.rb +1 -1
- 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: 3c2b9b3a11f581cc1ee84330c7813cfc6e2875616de64d41fde78ad710891916
|
|
4
|
+
data.tar.gz: a54225bf6e5851ead275215047393339cbca5bd8834d9a2030fb4a121b0aded2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba93279fffb6b6f6af37123a580d6084bd3d570870167c7eb912ce3950b18d8affa157eb1adbc253f463bf293803270ef17c4b66eec26b444b4f3c7754005eda
|
|
7
|
+
data.tar.gz: b097d987aa90f78b613738e096e8ffb4218dba1de43e5ff796d3092e21a6a07ed47d803b126baab0f3bc8aebc01326254adac3a1dfafab4f8d6c830bca1396c4
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
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
|
[](https://badge.fury.io/rb/kamisaku)
|
|
6
8
|
|
|
7
9
|

|
|
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
|
|
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)
|
data/lib/kamisaku/version.rb
CHANGED