petit-felix 0.1.6 → 0.1.7
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 +7 -5
- data/lib/felix/file.rb +28 -0
- data/lib/felix/metadata.rb +2 -10
- data/lib/felix/task_manager.rb +5 -3
- data/lib/task/pdf_single_task.rb +1 -1
- data/lib/task/template_pdf_task.rb +2 -2
- data/lib/version.rb +1 -1
- data/lib/worker/basic_pdf_writer_classic.rb +10 -2
- data/lib/worker/pdf_writer.rb +9 -2
- data/lib/worker/templater/font.rb +5 -0
- data/lib/worker/templater/methods.rb +2 -2
- data/lib/worker/templater/validation.rb +18 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43e66d8321092975cf428beebfb0710634396b23b357d349cbb64ea00b86106a
|
4
|
+
data.tar.gz: 3b5c0abbd975e5c3acfe58410034dbbcbf835e0e8e8069fffe924a8376b56c6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 044dc388971b643baf04f35ebd6887b1b244e9837d1552b84381bf7418ca83e0c6286569937501906bc6c273be3145855cf2d028f5fad83b080bdab9718dd109
|
7
|
+
data.tar.gz: 386d6f9d6a400e06a0400195710b995f42fbc660d498a368af7fe08a8370b58508b0f7429d8cf800dec208a88e9ca3acbddc3100231571fe185f99d15bdb7fc6
|
data/lib/felix/config.rb
CHANGED
@@ -13,9 +13,9 @@ module PetitFelix
|
|
13
13
|
|
14
14
|
# Global defaults
|
15
15
|
DEFAULT_OPTIONS = {
|
16
|
-
"image_dir" => "
|
17
|
-
"input_files" => "
|
18
|
-
"output_dir" => "
|
16
|
+
"image_dir" => (File.join("assets","images")),
|
17
|
+
"input_files" => (File.join("md","*")),
|
18
|
+
"output_dir" => (File.join("output")),
|
19
19
|
"task" => "pdf-single",
|
20
20
|
}
|
21
21
|
|
@@ -69,9 +69,11 @@ module PetitFelix
|
|
69
69
|
|
70
70
|
default_config = {}
|
71
71
|
|
72
|
-
|
72
|
+
default_file = File.join("default.cfg")
|
73
|
+
|
74
|
+
if File.file? default_file
|
73
75
|
|
74
|
-
default_config = metadata.get_metadata(File.read
|
76
|
+
default_config = metadata.get_metadata(File.read default_file)
|
75
77
|
end
|
76
78
|
|
77
79
|
# Loads command line arguments
|
data/lib/felix/file.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module PetitFelix
|
3
|
+
class FileManager
|
4
|
+
|
5
|
+
def file_from_string string
|
6
|
+
file_split = file_array_from_string string
|
7
|
+
|
8
|
+
if file_split.count > 0
|
9
|
+
string = File.join(file_split)
|
10
|
+
end
|
11
|
+
|
12
|
+
return string
|
13
|
+
end
|
14
|
+
|
15
|
+
def file_array_from_string string
|
16
|
+
file_split = []
|
17
|
+
|
18
|
+
if string.include? "/"
|
19
|
+
file_split = string.split("/")
|
20
|
+
elsif string.include? "\\"
|
21
|
+
file_split = string.split("\\")
|
22
|
+
end
|
23
|
+
|
24
|
+
return file_split
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
data/lib/felix/metadata.rb
CHANGED
@@ -7,16 +7,8 @@ module PetitFelix
|
|
7
7
|
## Gets image from path and location
|
8
8
|
def get_image_location img_dir, filename
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
if !File.file?(file)
|
13
|
-
|
14
|
-
file = ".#{img_dir}/#{filename}"
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
file
|
19
|
-
|
10
|
+
return File.join(img_dir,filename)
|
11
|
+
|
20
12
|
end
|
21
13
|
|
22
14
|
## Gets metadata from string into paired hashes
|
data/lib/felix/task_manager.rb
CHANGED
@@ -14,9 +14,11 @@ module PetitFelix
|
|
14
14
|
@error_printer = PetitFelix::Error.new
|
15
15
|
@task_list = {}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
load_task "task
|
17
|
+
File.join("..","task","template_pdf_task.rb")
|
18
|
+
|
19
|
+
load_task File.join(File.dirname(__FILE__),"..","task","template_pdf_task.rb")
|
20
|
+
load_task File.join(File.dirname(__FILE__),"..","task","pdf_single_task.rb")
|
21
|
+
load_task File.join(File.dirname(__FILE__),"..","task","basic_pdf_classic_task.rb")
|
20
22
|
|
21
23
|
task_list = PetitFelix::Task.constants.select {|c| PetitFelix::Task.const_get(c).is_a? Class}
|
22
24
|
|
data/lib/task/pdf_single_task.rb
CHANGED
@@ -43,7 +43,7 @@ module PetitFelix
|
|
43
43
|
metadata = @metaoptions.merge(metadata_helper.get_metadata(page_data[0]))
|
44
44
|
|
45
45
|
# Always forces you to use this template
|
46
|
-
@metaoptions["template"] = File.dirname(__FILE__)
|
46
|
+
@metaoptions["template"] = File.join(File.dirname(__FILE__),"..","..", "templates","zine-single.json")
|
47
47
|
|
48
48
|
if metadata["pdf"] == "true"
|
49
49
|
|
@@ -17,8 +17,8 @@ module PetitFelix
|
|
17
17
|
def self.default_options
|
18
18
|
|
19
19
|
return {
|
20
|
-
"template" => "
|
21
|
-
"output_file" => "
|
20
|
+
"template" => (File.join(File.dirname(__FILE__),"..","..","templates","test.json")),
|
21
|
+
"output_file" => (File.join("output","test.pdf"))
|
22
22
|
}
|
23
23
|
|
24
24
|
end
|
data/lib/version.rb
CHANGED
@@ -2,6 +2,7 @@ require "prawn"
|
|
2
2
|
require 'fileutils'
|
3
3
|
require "prawndown-ext"
|
4
4
|
require "felix/metadata"
|
5
|
+
require "felix/file"
|
5
6
|
require "worker/pdf_writer"
|
6
7
|
|
7
8
|
module PetitFelix
|
@@ -52,8 +53,15 @@ module PetitFelix
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def output
|
55
|
-
|
56
|
-
|
56
|
+
fileedit = PetitFelix::FileManager.new
|
57
|
+
|
58
|
+
file_output = fileedit.file_array_from_string(@options["output_dir"]) + [@options["output_file"]]
|
59
|
+
|
60
|
+
file = File.join(file_output)
|
61
|
+
|
62
|
+
FileUtils.mkdir_p File.dirname(file)
|
63
|
+
|
64
|
+
render_file(file)
|
57
65
|
end
|
58
66
|
|
59
67
|
# Draws page numbering
|
data/lib/worker/pdf_writer.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "prawn"
|
2
2
|
require 'fileutils'
|
3
3
|
require "prawndown-ext"
|
4
|
+
require "felix/file"
|
4
5
|
require "worker/pdf_writer/column_box"
|
5
6
|
require "worker/pdf_writer/bounding_box"
|
6
7
|
|
@@ -87,9 +88,15 @@ module PetitFelix
|
|
87
88
|
end
|
88
89
|
|
89
90
|
def output
|
91
|
+
|
92
|
+
fileedit = PetitFelix::FileManager.new
|
93
|
+
|
94
|
+
file_output = fileedit.file_array_from_string(@options["output_dir"]) + [@options["output_file"]]
|
95
|
+
|
96
|
+
file = File.join(file_output)
|
90
97
|
|
91
|
-
FileUtils.mkdir_p File.dirname(
|
92
|
-
render_file(
|
98
|
+
FileUtils.mkdir_p File.dirname(file)
|
99
|
+
render_file(file)
|
93
100
|
|
94
101
|
end
|
95
102
|
|
@@ -8,6 +8,11 @@ module PetitFelix
|
|
8
8
|
# Adds a font to the pdf document
|
9
9
|
def add_font font, font_name
|
10
10
|
|
11
|
+
args_has_file :normal, font
|
12
|
+
args_has_file :bold, font
|
13
|
+
args_has_file :italic, font
|
14
|
+
args_has_file :bold_italic, font
|
15
|
+
|
11
16
|
if font.key?(:normal)
|
12
17
|
|
13
18
|
if font.key?(:italic)
|
@@ -225,7 +225,7 @@ module PetitFelix
|
|
225
225
|
|
226
226
|
def com_image args, obj
|
227
227
|
|
228
|
-
validate =
|
228
|
+
validate = args_has_file :file, args
|
229
229
|
|
230
230
|
if validate != 0
|
231
231
|
return validate
|
@@ -925,7 +925,7 @@ module PetitFelix
|
|
925
925
|
# clears the current markdown file
|
926
926
|
com_clear_markdown args, obj
|
927
927
|
|
928
|
-
validate =
|
928
|
+
validate = args_has_file :file, args
|
929
929
|
|
930
930
|
if validate != 0
|
931
931
|
return validate
|
@@ -35,6 +35,24 @@ module PetitFelix
|
|
35
35
|
|
36
36
|
end
|
37
37
|
|
38
|
+
def args_has_file arg_name, args
|
39
|
+
|
40
|
+
if !args.key? arg_name
|
41
|
+
# text not defined
|
42
|
+
@error_param["arg"] = arg_name.to_s
|
43
|
+
return 7
|
44
|
+
end
|
45
|
+
|
46
|
+
file = replace_variable args[arg_name].to_s
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
args[arg_name] = file
|
51
|
+
|
52
|
+
return 0
|
53
|
+
|
54
|
+
end
|
55
|
+
|
38
56
|
def args_has_int arg_name, args
|
39
57
|
|
40
58
|
if !args.key? arg_name
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- PunishedFelix
|
@@ -67,6 +67,7 @@ extra_rdoc_files: []
|
|
67
67
|
files:
|
68
68
|
- lib/felix/config.rb
|
69
69
|
- lib/felix/error.rb
|
70
|
+
- lib/felix/file.rb
|
70
71
|
- lib/felix/generator.rb
|
71
72
|
- lib/felix/metadata.rb
|
72
73
|
- lib/felix/task_manager.rb
|