petit-felix 0.1.10 → 0.1.11

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: 2709ae62f534f69b2f394dfb49ca307fd6602ffcbdae735803abf565dc0da54c
4
- data.tar.gz: c1beb16e7c071dba1f13dc43c7e19912fa09715bc28b05423af6c2ede3740a2c
3
+ metadata.gz: 1d2e8b23995447848c4ca2a9aa1fc32d714d13c103474af97b4de7b15a9b909e
4
+ data.tar.gz: 7ce09991565bb9129a30f9ed51024d669b41077b8462e1343ab40091f7471f18
5
5
  SHA512:
6
- metadata.gz: c0f453504b5a168de33733685603a6a29fe19c4226cbd023f9446fef141e927afde08392677c07610c600abed939c16fb1154161f955ef9ce297a28f49b65223
7
- data.tar.gz: 20dc63d0e0d917ecccb81adfe85ad8d181a06522c1dea4ac8865437a599c77d1ca11e00af13af9439a4a61fcfbcaed0334d48120190dae584db7d60cd8d21457
6
+ metadata.gz: 001ade81df3dc72cb4672cea3c295cda649d47a8a55d55290a3e141c68b38faf338a0f6e7f9875aefd1e1ab7f6fb3c58807626fc14bbfa5ac09b8e661718a780
7
+ data.tar.gz: 86c720c74ecd9181c6b6527187af8511241cb50d67760c8a454142476fce8ab9ae1aaacab0527daece7522be9bc0f4830d8f58ecda3edae5f8ecb6bec76a1772
data/lib/felix/config.rb CHANGED
@@ -21,29 +21,12 @@ module PetitFelix
21
21
 
22
22
  ## Hash for custom command line argument calls
23
23
  CL_DATA = {
24
- "columns" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
25
- "default_font_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
26
- "header1_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
27
- "header2_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
28
- "header3_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
29
- "header4_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
30
- "header5_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
31
- "header6_size" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
32
- "margin" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args).to_i },
33
- "font_normal" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
34
- "font_italic" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
35
- "font_bold" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
36
- "font_bold_italic" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
37
- "page_layout" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
38
- "input_files" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
39
- "image_dir" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
40
- "task" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
41
- "template" => -> (command, args, index, cl_args) { cl_add_config(command, args, index, cl_args) },
24
+
42
25
  }
43
26
 
44
27
  ### Command Line Arguments
45
28
 
46
- def self.cl_add_config command,args, index, cl_args
29
+ def cl_add_config command, args, index, cl_args
47
30
  cl_args[command] = args[index + 1]
48
31
  end
49
32
 
@@ -155,6 +138,10 @@ module PetitFelix
155
138
 
156
139
  CL_DATA[command].call command, args, index, cl_args
157
140
 
141
+ else
142
+
143
+ cl_add_config command, args, index, cl_args
144
+
158
145
  end
159
146
 
160
147
  @processed_arguments << command
@@ -31,7 +31,7 @@ module PetitFelix
31
31
  pdf = PetitFelix::Worker::TemplatePDFWriter.new(
32
32
  page_layout: @metaoptions["page_layout"],
33
33
  print_scaling: @metaoptions["print_scaling"])
34
-
34
+
35
35
  pdf.set_options @metaoptions
36
36
 
37
37
  pdf.init_values @metaoptions, pdf
data/lib/version.rb CHANGED
@@ -4,6 +4,6 @@
4
4
 
5
5
  module PetitFelix
6
6
  module Felix
7
- VERSION = "0.1.10"
7
+ VERSION = "0.1.11"
8
8
  end
9
9
  end
@@ -35,7 +35,9 @@ module Prawn
35
35
  @margins = {}
36
36
 
37
37
  if @base_margins.count > 0
38
- @margins = @base_margins[@document.page_count % @base_margins.count]
38
+
39
+ @margins = @base_margins[(@document.page_count - 1) % @base_margins.count]
40
+
39
41
  end
40
42
  end
41
43
 
@@ -12,6 +12,14 @@ module PetitFelix
12
12
 
13
13
  class DefaultPDFWriter < Prawn::Document
14
14
 
15
+ def alternates_pages
16
+ return @alternates_pages
17
+ end
18
+
19
+ def set_alternate_pages
20
+ @alternates_pages = true
21
+ end
22
+
15
23
  # Initializes fonts
16
24
  def initialize_font
17
25
 
@@ -82,7 +90,8 @@ module PetitFelix
82
90
  end
83
91
 
84
92
  def set_options metaoptions
85
-
93
+ @alternates_pages = false
94
+
86
95
  @options = metaoptions
87
96
 
88
97
  end
@@ -61,6 +61,7 @@ module PetitFelix
61
61
 
62
62
  # special custom functions
63
63
  :alternate_pages => -> (obj, args) { obj.com_alternate_pages args, obj },
64
+ :set_alternate_pages => -> (obj, args) { obj.com_set_alternate_pages args, obj },
64
65
  }
65
66
 
66
67
  ## Debug test command
@@ -474,8 +475,6 @@ module PetitFelix
474
475
  args_has_int :page_start, args
475
476
  args_has_int :page_finish, args
476
477
 
477
- odd_options[:start_count_at] += 1
478
-
479
478
  if !args.key?(:page_start)
480
479
  @variables["paginator_start"] = @metaoptions["paginator_start"]
481
480
  else
@@ -484,13 +483,26 @@ module PetitFelix
484
483
 
485
484
  @variables["paginator_end"] = args[:page_finish]
486
485
 
487
- if @metaoptions["paginator_switch"]
488
- odd_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 1 }
489
- even_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 0 }
490
-
486
+ if obj.alternates_pages
487
+ even_options[:start_count_at] = ((obj.page_count - 1) * 0.5).floor
488
+
489
+ even_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg > obj.page_count * 0.5 }
490
+
491
+ odd_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg <= obj.page_count * 0.5 }
492
+
491
493
  else
492
- even_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 1 }
493
- odd_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 0 }
494
+
495
+ odd_options[:start_count_at] += 1
496
+
497
+ if @metaoptions["paginator_switch"]
498
+ odd_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 1 }
499
+ even_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 0 }
500
+
501
+ else
502
+ even_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 1 }
503
+ odd_options[:page_filter] = ->(pg) { pg > @variables["paginator_start"] && (pg < @variables["paginator_end"] || @variables["paginator_end"] <= -1) && pg % 2 == 0 }
504
+
505
+ end
494
506
 
495
507
  end
496
508
 
@@ -1118,6 +1130,12 @@ module PetitFelix
1118
1130
  return 0
1119
1131
  end
1120
1132
 
1133
+ def com_set_alternate_pages args, obj
1134
+ obj.set_alternate_pages
1135
+
1136
+ return 0
1137
+ end
1138
+
1121
1139
  end
1122
1140
  end
1123
1141
  end
@@ -730,7 +730,20 @@
730
730
  }
731
731
  ],
732
732
 
733
+ "set_alternate_output" : [
734
+ {
735
+ "cmd" : "set_alternate_pages"
736
+ }
737
+ ],
738
+
733
739
  "main": [
740
+ {
741
+ "cmd" : "if",
742
+ "args" : {
743
+ "exp" : "${alternate_output}",
744
+ "func" : "set_alternate_output"
745
+ }
746
+ },
734
747
  {
735
748
  "cmd": "set",
736
749
  "args": {
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.10
4
+ version: 0.1.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - PunishedFelix