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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86191af109a9e5c6a646f9a449e00fdf1d24d88238f5b10ecd48ae0de4c8b589
4
- data.tar.gz: 2719d5612122b24fae5af26bd6367df98a86774d1e4e41dea6abdb3ab642122c
3
+ metadata.gz: 9a5819e6778a8ae5227fcc22048592b939e2d4fc649043cca1dd8659d97bc2c4
4
+ data.tar.gz: e7e3abd0742011659a1269c33c5997cc58115e3929cf524dfcf4bf42d3ca33a8
5
5
  SHA512:
6
- metadata.gz: a6b1647e10bf8507b53421b9f0515a87360c73bec8a1f3c67ec94bcbc87af01f9618a69160281b61352a08a31016c60bb41544b826be702576da21059efa9126
7
- data.tar.gz: 73534102890ef599b1f4baf87b3d0d30f5e7701e12e08ec36cc6c3bb0fc2c5bc7b4ea7455150805e563c6ea8a313d292c63cda6bc35a0c9ea6716921872a351d
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
@@ -0,0 +1,9 @@
1
+ module PetitFelix
2
+ class Error
3
+
4
+ def print_err(error)
5
+ print "\n\nError: " + error + "\n"
6
+ end
7
+
8
+ end
9
+ end
@@ -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["output_dir"] = output_path
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
- PetitFelix::Task::BasicPDFTask.new.render_files options
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
@@ -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
@@ -58,7 +58,6 @@ module PetitFelix
58
58
 
59
59
  dir = options["output_dir"]
60
60
 
61
-
62
61
  page = File.read(options["filename"])
63
62
 
64
63
  # splits the page into parts for metadata and content
data/lib/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  module PetitFelix
4
4
  module Felix
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -40,7 +40,7 @@ module PetitFelix
40
40
  height: box_width) do
41
41
 
42
42
  if metadata.key?("back_cover_image")
43
- var = "./assets/images/" + metadata["back_cover_image"]
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 = "./assets/images/" + metadata["front_cover_image"]
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.0
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.9
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.9
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