petit-felix 0.1.0 → 0.1.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/lib/felix/config.rb +4 -1
- data/lib/felix/error.rb +9 -0
- data/lib/felix/generator.rb +20 -2
- data/lib/felix/metadata.rb +11 -0
- data/lib/felix/task/basic_pdf_task.rb +0 -1
- data/lib/version.rb +1 -1
- data/lib/worker/basic_pdf_writer.rb +2 -2
- metadata +4 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a5819e6778a8ae5227fcc22048592b939e2d4fc649043cca1dd8659d97bc2c4
|
4
|
+
data.tar.gz: e7e3abd0742011659a1269c33c5997cc58115e3929cf524dfcf4bf42d3ca33a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f446b700730a5f70b4c7812624c4cd2637b8d150bf15b052e354c19b45bdb7e5efb6d356ae4c6f1722bf474e7c5bc7e7942010b49dae0241f0ddb87009568b3
|
7
|
+
data.tar.gz: 0d2beb8311d36d55b0bca706aa2ab4c9db9a6e4638025ec51cecbdf1c012bdc052efbacd40541fdbba511f2be04b58ec7e264d8668ab65f2ebed8ee9ff503d03
|
data/lib/felix/config.rb
CHANGED
@@ -24,7 +24,9 @@ module PetitFelix
|
|
24
24
|
"font_normal" => "./assets/font/Unageo-Regular.ttf",
|
25
25
|
"font_italic"=> "./assets/font/Unageo-Regular-Italic.ttf",
|
26
26
|
"font_bold"=> "./assets/font/Unageo-ExtraBold.ttf",
|
27
|
-
"font_bold_italic" => "./assets/font/Unageo-ExtraBold-Italic.ttf"
|
27
|
+
"font_bold_italic" => "./assets/font/Unageo-ExtraBold-Italic.ttf",
|
28
|
+
"image_dir" => "./assets/images",
|
29
|
+
"worker" => "basic_pdf",
|
28
30
|
}
|
29
31
|
|
30
32
|
## Hash for custom command line argument calls
|
@@ -44,6 +46,7 @@ module PetitFelix
|
|
44
46
|
"font_bold_italic" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
|
45
47
|
"page_layout" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
|
46
48
|
"input_files" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
|
49
|
+
"image_dir" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
|
47
50
|
}
|
48
51
|
|
49
52
|
### Command Line Arguments
|
data/lib/felix/error.rb
ADDED
data/lib/felix/generator.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
1
|
require "felix/task/basic_pdf_task"
|
2
|
+
require "felix/error"
|
2
3
|
|
3
4
|
module PetitFelix
|
4
5
|
|
5
6
|
class Generator
|
6
7
|
|
8
|
+
WORKERS = {
|
9
|
+
# Basic PDF
|
10
|
+
"basic_pdf" => PetitFelix::Task::BasicPDFTask.new,
|
11
|
+
}
|
12
|
+
|
7
13
|
## Renders all the files in the given directory.
|
8
14
|
|
9
15
|
def render_files(options)
|
@@ -16,9 +22,21 @@ module PetitFelix
|
|
16
22
|
options["input_files"] = input_path
|
17
23
|
end
|
18
24
|
|
19
|
-
options
|
25
|
+
if !options.key?("output_dir")
|
26
|
+
options["output_dir"] = output_path
|
27
|
+
end
|
28
|
+
|
29
|
+
if WORKERS.key?(options["worker"].downcase)
|
30
|
+
WORKERS[options["worker"].downcase].render_files options
|
31
|
+
else
|
32
|
+
text = "worker " + options["worker"].downcase + " not found. Make sure the variable \"worker\" is set correctly in your configuration settings. Available workers: "
|
20
33
|
|
21
|
-
|
34
|
+
WORKERS.keys.each do |key|
|
35
|
+
text += "\n " + key
|
36
|
+
end
|
37
|
+
|
38
|
+
PetitFelix::Error.new.print_err text
|
39
|
+
end
|
22
40
|
end
|
23
41
|
|
24
42
|
end
|
data/lib/felix/metadata.rb
CHANGED
@@ -4,6 +4,17 @@ module PetitFelix
|
|
4
4
|
|
5
5
|
class Metadata
|
6
6
|
|
7
|
+
## Gets image from path and location
|
8
|
+
def get_image_location img_dir, filename
|
9
|
+
file = img_dir + "/" + filename
|
10
|
+
|
11
|
+
if !File.file?(file)
|
12
|
+
file = "." + img_dir + "/" + filename
|
13
|
+
end
|
14
|
+
|
15
|
+
file
|
16
|
+
end
|
17
|
+
|
7
18
|
## Gets metadata from string into paired hashes
|
8
19
|
def get_metadata(input)
|
9
20
|
array = input.lines
|
data/lib/version.rb
CHANGED
@@ -40,7 +40,7 @@ module PetitFelix
|
|
40
40
|
height: box_width) do
|
41
41
|
|
42
42
|
if metadata.key?("back_cover_image")
|
43
|
-
var = "
|
43
|
+
var = PetitFelix::Metadata.new.get_image_location(metadata["image_dir"], metadata["back_cover_image"])
|
44
44
|
|
45
45
|
if File.file?(var)
|
46
46
|
pdf.image(var,
|
@@ -89,7 +89,7 @@ module PetitFelix
|
|
89
89
|
height: box_width) do
|
90
90
|
|
91
91
|
if metadata.key?("front_cover_image")
|
92
|
-
var = "
|
92
|
+
var = PetitFelix::Metadata.new.get_image_location(metadata["image_dir"], metadata["front_cover_image"])
|
93
93
|
|
94
94
|
if File.file?(var)
|
95
95
|
pdf.image(var,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: petit-felix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PunishedFelix
|
@@ -35,20 +35,14 @@ dependencies:
|
|
35
35
|
requirements:
|
36
36
|
- - "~>"
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.1.
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: 0.1.9
|
38
|
+
version: 0.1.10
|
42
39
|
type: :runtime
|
43
40
|
prerelease: false
|
44
41
|
version_requirements: !ruby/object:Gem::Requirement
|
45
42
|
requirements:
|
46
43
|
- - "~>"
|
47
44
|
- !ruby/object:Gem::Version
|
48
|
-
version: 0.1.
|
49
|
-
- - ">="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
version: 0.1.9
|
45
|
+
version: 0.1.10
|
52
46
|
description: Converts markdown files into PDF documents using options passed in a
|
53
47
|
hash.
|
54
48
|
email:
|
@@ -58,6 +52,7 @@ extensions: []
|
|
58
52
|
extra_rdoc_files: []
|
59
53
|
files:
|
60
54
|
- lib/felix/config.rb
|
55
|
+
- lib/felix/error.rb
|
61
56
|
- lib/felix/generator.rb
|
62
57
|
- lib/felix/metadata.rb
|
63
58
|
- lib/felix/task/basic_pdf_task.rb
|