kamisaku 0.2.0 → 0.3.0
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 +0 -3
- data/Gemfile.lock +1 -13
- data/kamisaku.gemspec +38 -0
- data/lib/kamisaku/cv_generator.rb +0 -1
- data/lib/kamisaku/pdf.rb +63 -0
- data/lib/kamisaku/version.rb +1 -1
- data/lib/kamisaku.rb +1 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3ec65c8d7b635ea047a547d4fdf3a90ef1e4ddaa2b271b2178e8b2bdf9bca0f
|
|
4
|
+
data.tar.gz: c6fada80efb1876043306bc9c38842e627f5ee32a7ca18f1a3c97a1f1490a954
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea270d4a7e392a32ffb83fbe87a9f31ba483b1827f99f52547278875f92f87989b629dd901e4047d31f288cafeac8f722a6534ac1d88858cd6e9b3f6e06c055a
|
|
7
|
+
data.tar.gz: '0877a0d602fe76e39cd955bd71557355d273b4d6f45b6bafd519757b1478d635da1c3c78e67488e1aa3cd23898d7eb3297f55870c328c811f506675847ca2c63'
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,27 +1,19 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
kamisaku (0.
|
|
4
|
+
kamisaku (0.3.0)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
8
8
|
specs:
|
|
9
9
|
ast (2.4.3)
|
|
10
|
-
bigdecimal (3.1.9)
|
|
11
10
|
json (2.12.0)
|
|
12
11
|
language_server-protocol (3.17.0.5)
|
|
13
|
-
matrix (0.4.2)
|
|
14
12
|
minitest (5.25.5)
|
|
15
13
|
parallel (1.27.0)
|
|
16
14
|
parser (3.3.8.0)
|
|
17
15
|
ast (~> 2.4.1)
|
|
18
16
|
racc
|
|
19
|
-
pdf-core (0.10.0)
|
|
20
|
-
pdfkit (0.8.7.3)
|
|
21
|
-
prawn (2.5.0)
|
|
22
|
-
matrix (~> 0.4)
|
|
23
|
-
pdf-core (~> 0.10.0)
|
|
24
|
-
ttfunk (~> 1.8)
|
|
25
17
|
prism (1.4.0)
|
|
26
18
|
racc (1.8.1)
|
|
27
19
|
rainbow (3.1.1)
|
|
@@ -47,8 +39,6 @@ GEM
|
|
|
47
39
|
rubocop-rake (0.6.0)
|
|
48
40
|
rubocop (~> 1.0)
|
|
49
41
|
ruby-progressbar (1.13.0)
|
|
50
|
-
ttfunk (1.8.0)
|
|
51
|
-
bigdecimal (~> 3.1)
|
|
52
42
|
unicode-display_width (2.6.0)
|
|
53
43
|
|
|
54
44
|
PLATFORMS
|
|
@@ -58,8 +48,6 @@ PLATFORMS
|
|
|
58
48
|
DEPENDENCIES
|
|
59
49
|
kamisaku!
|
|
60
50
|
minitest (~> 5.0)
|
|
61
|
-
pdfkit
|
|
62
|
-
prawn
|
|
63
51
|
rake (~> 13.0)
|
|
64
52
|
rubocop (= 1.57.2)
|
|
65
53
|
rubocop-minitest (~> 0.33.0)
|
data/kamisaku.gemspec
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "lib/kamisaku/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "kamisaku"
|
|
7
|
+
spec.version = Kamisaku::VERSION
|
|
8
|
+
spec.authors = ["Sinaru Gunawardena"]
|
|
9
|
+
spec.email = ["sinaru@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = "Build a CV PDF from a yaml text file."
|
|
12
|
+
spec.description = "Build a CV PDF from a yaml text file."
|
|
13
|
+
spec.homepage = "https://github.com/sinaru/kamisaku"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
spec.required_ruby_version = ">= 3.4.3"
|
|
16
|
+
|
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/sinaru/kamisaku"
|
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/sinaru/kamisaku/blob/main/CHANGELOG.md"
|
|
20
|
+
spec.metadata["bug_tracker_uri"] = "https://github.com/sinaru/kamisaku/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug"
|
|
21
|
+
|
|
22
|
+
# Specify which files should be added to the gem when it is released.
|
|
23
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
24
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
25
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
|
26
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
spec.bindir = "bin"
|
|
30
|
+
spec.executables = spec.files.grep(%r{\Abin/}) { |f| File.basename(f) }
|
|
31
|
+
spec.require_paths = ["lib"]
|
|
32
|
+
|
|
33
|
+
# Uncomment to register a new dependency of your gem
|
|
34
|
+
# spec.add_dependency "example-gem", "~> 1.0"
|
|
35
|
+
|
|
36
|
+
# For more information and examples about making a new gem, check out our
|
|
37
|
+
# guide at: https://bundler.io/guides/crea ting_gem.html
|
|
38
|
+
end
|
data/lib/kamisaku/pdf.rb
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
module Kamisaku
|
|
2
|
+
class PDF
|
|
3
|
+
attr_reader :yaml_content, :pdf_location, :html_location, :cv_data, :template
|
|
4
|
+
|
|
5
|
+
def initialize(yaml_content:, pdf_location:, html_location: nil, template: nil)
|
|
6
|
+
@yaml_content = yaml_content
|
|
7
|
+
@cv_data = CvData.new(YAML.load(yaml_content))
|
|
8
|
+
@pdf_location = pdf_location
|
|
9
|
+
@html_location = html_location
|
|
10
|
+
@template = template || "sleek"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def create
|
|
14
|
+
generated_html_file do |file_path|
|
|
15
|
+
FileUtils.cp(file_path, html_location) if html_location
|
|
16
|
+
html_file_to_pdf_file(file_path, pdf_location)
|
|
17
|
+
soft_remove_metadata_from_pdf_file(pdf_location)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
def html_file_to_pdf_file(html_file_path, pdf_file_path)
|
|
24
|
+
# Convert the HTML file to a PDF using Google Chrome in headless mode
|
|
25
|
+
pdf_conversion_command = <<~CMD
|
|
26
|
+
google-chrome --headless --disable-gpu --run-all-compositor-stages-before-draw \
|
|
27
|
+
--print-to-pdf=#{pdf_file_path} --no-pdf-header-footer \
|
|
28
|
+
#{html_file_path}
|
|
29
|
+
CMD
|
|
30
|
+
|
|
31
|
+
system(pdf_conversion_command)
|
|
32
|
+
raise "PDF generation failed" unless File.exist?(pdf_file_path)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def soft_remove_metadata_from_pdf_file(file_path)
|
|
36
|
+
command = <<~CMD
|
|
37
|
+
exiftool -all= #{file_path} -overwrite_original
|
|
38
|
+
CMD
|
|
39
|
+
system(command)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def generated_html_file
|
|
43
|
+
temp_html_file = Tempfile.new(%w[kamisaku .html])
|
|
44
|
+
temp_html_file.write(cv_html)
|
|
45
|
+
temp_html_file.close
|
|
46
|
+
begin
|
|
47
|
+
yield temp_html_file.path
|
|
48
|
+
ensure
|
|
49
|
+
temp_html_file.unlink
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def cv_html
|
|
54
|
+
rhtml = ERB.new(template_html)
|
|
55
|
+
rhtml.result(@cv_data.get_bindings)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def template_html
|
|
59
|
+
path = File.join(File.dirname(__FILE__), "/../templates/#{template}/template.html.erb")
|
|
60
|
+
File.read(path)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|
data/lib/kamisaku/version.rb
CHANGED
data/lib/kamisaku.rb
CHANGED
|
@@ -11,6 +11,7 @@ require_relative "kamisaku/cv_data"
|
|
|
11
11
|
require_relative "kamisaku/meta_file_parser"
|
|
12
12
|
require_relative "kamisaku/cv_generator"
|
|
13
13
|
require_relative "kamisaku/arg_parser"
|
|
14
|
+
require_relative "kamisaku/pdf"
|
|
14
15
|
|
|
15
16
|
module Kamisaku
|
|
16
17
|
class Error < StandardError; 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.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Sinaru Gunawardena
|
|
@@ -29,6 +29,7 @@ files:
|
|
|
29
29
|
- examples/paper/john_doe.yml
|
|
30
30
|
- examples/sleek/john_doe.pdf
|
|
31
31
|
- examples/sleek/john_doe.yml
|
|
32
|
+
- kamisaku.gemspec
|
|
32
33
|
- kamisaku.png
|
|
33
34
|
- lib/kamisaku.rb
|
|
34
35
|
- lib/kamisaku/arg_parser.rb
|
|
@@ -41,6 +42,7 @@ files:
|
|
|
41
42
|
- lib/kamisaku/cv_data_sections/skill.rb
|
|
42
43
|
- lib/kamisaku/cv_generator.rb
|
|
43
44
|
- lib/kamisaku/meta_file_parser.rb
|
|
45
|
+
- lib/kamisaku/pdf.rb
|
|
44
46
|
- lib/kamisaku/version.rb
|
|
45
47
|
- lib/templates/paper/template.html.erb
|
|
46
48
|
- lib/templates/sleek/template.html.erb
|