libis-format 2.0.1 → 2.0.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: bfe52fc3216a0da8528941b4232c252880006137cc92fe8d42512840f5b7ab7d
4
- data.tar.gz: 349303abd8b4d8748960713933f532bae3ca83d45613a79321269497baa6ae2a
3
+ metadata.gz: 7f89add0e88c5d7a136475b303e5eec4da7af65ae6469ed24487e00c900871aa
4
+ data.tar.gz: '0902a88e237a8cf7a42f0ec0ea6aac4370590649aca894853a4f5de8b12dbb1e'
5
5
  SHA512:
6
- metadata.gz: '0917e66b03e3bf008dd3a86761f9004d93d1fbc3c02c8c692a1f6f312f25c4edc0a1536b73e4a01043b4e03c85125437ae1307c49349bdee7c46d3f5b2503231'
7
- data.tar.gz: 29bd68dce1a8f5f2c0216299b29268d3fdcbafaed4282b7076fac4810762fb377a403dbc08dc23672a3eda4bb17cae8c8882bb24d21980396d3c2943935d1437
6
+ metadata.gz: 90d3b575f8b87aca635d7b526d26ce8a899626b83950e66ed7df382b4e983cf93e3bab4526d5fdbdd268c94e158c99f9296858816f4f630a29d7a7ae89ea73e0
7
+ data.tar.gz: dfb7854cacec55c33fe6e01d3cc834eb3debe1657366c0247803b3227e84113f9f230e6809462c212c659388b576faeed038464752f959997d39a84aabe52858
@@ -26,13 +26,26 @@ module Libis
26
26
 
27
27
  def initialize
28
28
  super
29
- @options[:range] = []
29
+ @options[:ranges] = []
30
30
  end
31
31
 
32
32
  # Select a partial list of pages
33
33
  # @param [String] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
34
34
  def range(selection)
35
- @options[:range] << selection unless selection.blank?
35
+ @options[:ranges] += selection.split(/\s*,\s*/) unless selection.blank?
36
+ end
37
+
38
+ # Select a partial list of pages
39
+ # @param [String|Array<String>] selection as described in com.itextpdf.text.pdf.SequenceList: [!][o][odd][e][even]start-end
40
+ def ranges(selection)
41
+ case selection
42
+ when Array
43
+ @options[:ranges] += selection unless selection.empty?
44
+ when String
45
+ range(selection)
46
+ else
47
+ # nothing
48
+ end
36
49
  end
37
50
 
38
51
  def convert(source, target, format, opts = {})
@@ -52,15 +65,8 @@ module Libis
52
65
  def convert_pdf(source, target)
53
66
 
54
67
  using_temp(target) do |tmpname|
55
- result = Libis::Format::Tool::PdfSelect.run(
56
- source, tmpname,
57
- @options.map { |k, v|
58
- if v.nil?
59
- nil
60
- else
61
- ["--#{k}", v]
62
- end }.compact.flatten
63
- )
68
+ opts = @options[:ranges].map { |range| ["-r", range] }.compact.flatten
69
+ result = Libis::Format::Tool::PdfSelect.run(source, tmpname, opts)
64
70
  unless result[:err].empty?
65
71
  error("Pdf selection encountered errors:\n%s", result[:err].join(join("\n")))
66
72
  next nil
@@ -1,5 +1,5 @@
1
1
  module Libis
2
2
  module Format
3
- VERSION = '2.0.1'
3
+ VERSION = '2.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: libis-format
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kris Dekeyser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake