pdfmult 1.3.1 → 1.4.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c2332ed5eb863e47259f51eaedc2e6f26d9bc58190c2c0da9c13a2d1d128f7fd
4
+ data.tar.gz: 164a73cc0876f21ebacee131c000c74609f591784f46297fcfdb084ff4016b7f
5
+ SHA512:
6
+ metadata.gz: 42279e717e4991a3a5e4931e3a312b9603e436f45d706f6308989776eb96ca8af1c84a47780de8014793e63594d76d3fd90f6a5db99dab5bef2d2e3dcd0c6dea
7
+ data.tar.gz: f7de063d36bc0366059b9b65634e38b127f7bee228b033e7d3854a5c2cdf188779a07253c672cae2cefd532c84acc6c6190649b2c1aec2118ac83f32798c7405
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "minitest"
6
+ gem "rake"
data/README.md CHANGED
@@ -23,13 +23,13 @@ Use the program as shown in the examples below.
23
23
 
24
24
  writes 2 copies of `sample.pdf` to `sample_2.pdf`
25
25
 
26
- <img src="https://github.com/stomar/pdfmult/raw/master/example1.png" alt="" width="152" height="59">
26
+ <img src="example1.png" alt="" width="152" height="59">
27
27
 
28
28
  * `pdfmult -n 4 sample.pdf`
29
29
 
30
30
  writes 4 copies of `sample.pdf` to `sample_4.pdf`
31
31
 
32
- <img src="https://github.com/stomar/pdfmult/raw/master/example2.png" alt="" width="234" height="59">
32
+ <img src="example2.png" alt="" width="234" height="59">
33
33
 
34
34
  * `pdfmult sample.pdf -o outfile.pdf`
35
35
 
@@ -46,7 +46,7 @@ Use the program as shown in the examples below.
46
46
  Installation
47
47
  ------------
48
48
 
49
- Use `gem install pdfmult`.
49
+ Use `gem install pdfmult` to install from RubyGems.org.
50
50
 
51
51
  Or copy `lib/pdfmult.rb` under the name `pdfmult` into your search path.
52
52
 
@@ -60,7 +60,7 @@ As of now, `pdfmult` has only been tested on a Linux system.
60
60
 
61
61
  - `pdfmult` is written in [Ruby][Ruby], so Ruby must be installed on your system.
62
62
  - `pdfmult` uses `pdflatex` with the `pdfpages` package, so both have to be installed on the system.
63
- (If `pdfmult` can not find the `pdflatex` command on your system
63
+ (If `pdfmult` cannot find the `pdflatex` command on your system
64
64
  you might want to use the `--latex` option.)
65
65
  - `pdfmult` tries to obtain the page count of PDF files with `pdfinfo`.
66
66
  If it fails, by default only the first page of a PDF file will be processed.
@@ -81,7 +81,7 @@ Report bugs on the `pdfmult` home page: <https://github.com/stomar/pdfmult/>
81
81
  License
82
82
  -------
83
83
 
84
- Copyright &copy; 2011-2012, Marcus Stollsteimer
84
+ Copyright &copy; 2011-2024 Marcus Stollsteimer
85
85
 
86
86
  `pdfmult` is free software: you can redistribute it and/or modify
87
87
  it under the terms of the GNU General Public License version 3 or later (GPLv3+),
data/Rakefile CHANGED
@@ -1,52 +1,49 @@
1
- # rakefile for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'rake/testtask'
3
+ require "rake/testtask"
6
4
 
7
- require './lib/pdfmult'
5
+ require "./lib/pdfmult"
8
6
 
9
7
  PROGNAME = Pdfmult::PROGNAME
10
8
  HOMEPAGE = Pdfmult::HOMEPAGE
11
9
  TAGLINE = Pdfmult::TAGLINE
12
10
 
13
- BINDIR = '/usr/local/bin'
14
- MANDIR = '/usr/local/man/man1'
11
+ BINDIR = "/usr/local/bin"
12
+ MANDIR = "/usr/local/man/man1"
15
13
 
16
- HELP2MAN = 'help2man'
17
- SED = 'sed'
14
+ HELP2MAN = "help2man"
15
+ SED = "sed"
18
16
 
19
- BINARY = 'lib/pdfmult.rb'
20
- BINARYNAME = 'pdfmult' # install using this name
21
- MANPAGE = 'man/pdfmult.1'
22
- H2MFILE = 'pdfmult.h2m'
17
+ BINARY = "lib/pdfmult.rb"
18
+ BINARYNAME = "pdfmult" # install using this name
19
+ MANPAGE = "man/pdfmult.1"
20
+ H2MFILE = "pdfmult.h2m"
23
21
 
24
22
 
25
23
  def gemspec_file
26
- 'pdfmult.gemspec'
24
+ "pdfmult.gemspec"
27
25
  end
28
26
 
29
27
 
30
- task :default => [:test]
28
+ task default: [:test]
31
29
 
32
30
  Rake::TestTask.new do |t|
33
- t.pattern = 'test/**/test_*.rb'
34
- t.ruby_opts << '-rubygems'
31
+ t.pattern = "test/**/test_*.rb"
35
32
  t.verbose = true
36
33
  t.warning = true
37
34
  end
38
35
 
39
36
 
40
- desc 'Install binary and man page'
41
- task :install => [BINARY, MANPAGE] do
37
+ desc "Install binary and man page"
38
+ task install: [BINARY, MANPAGE] do
42
39
  mkdir_p BINDIR
43
40
  install(BINARY, "#{BINDIR}/#{BINARYNAME}")
44
41
  mkdir_p MANDIR
45
- install(MANPAGE, MANDIR, :mode => 0644)
42
+ install(MANPAGE, MANDIR, mode: 0o644)
46
43
  end
47
44
 
48
45
 
49
- desc 'Uninstall binary and man page'
46
+ desc "Uninstall binary and man page"
50
47
  task :uninstall do
51
48
  rm "#{BINDIR}/#{BINARYNAME}"
52
49
  manfile = File.basename(MANPAGE)
@@ -54,19 +51,18 @@ task :uninstall do
54
51
  end
55
52
 
56
53
 
57
- desc 'Create man page'
58
- task :man => [MANPAGE]
54
+ desc "Create man page"
55
+ task man: [MANPAGE]
59
56
 
60
57
  file MANPAGE => [BINARY, H2MFILE] do
61
58
  sh "#{HELP2MAN} --no-info --name='#{TAGLINE}' --include=#{H2MFILE} -o #{MANPAGE} ./#{BINARY}"
62
- sh "#{SED} -i '/\.PP/{N;s/\.PP\\nOptions/.SH OPTIONS/}' #{MANPAGE}"
63
59
  sh "#{SED} -i 's/^License GPL/.br\\nLicense GPL/;s/There is NO WARRANTY/.br\\nThere is NO WARRANTY/' #{MANPAGE}"
64
60
  sh "#{SED} -i 's!%HOMEPAGE%!#{HOMEPAGE}!g' #{MANPAGE}"
65
61
  sh "#{SED} -i 's!%PROGNAME%!#{PROGNAME}!g' #{MANPAGE}"
66
62
  end
67
63
 
68
64
 
69
- desc 'Build gem'
70
- task :build => [MANPAGE] do
65
+ desc "Build gem"
66
+ task build: [MANPAGE] do
71
67
  sh "gem build #{gemspec_file}"
72
68
  end
data/bin/pdfmult CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require 'pdfmult'
4
+ require "pdfmult"
4
5
 
5
- Pdfmult::Application.run!
6
+ Pdfmult::Application.new.run!
data/lib/pdfmult.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
2
4
  # == Name
3
5
  #
4
6
  # pdfmult - put multiple copies of a PDF page on one page
@@ -16,31 +18,33 @@
16
18
  #
17
19
  # == Author
18
20
  #
19
- # Copyright (C) 2011-2013 Marcus Stollsteimer
21
+ # Copyright (C) 2011-2024 Marcus Stollsteimer
20
22
  #
21
23
  # License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
22
24
 
23
- require 'optparse'
24
- require 'tempfile'
25
- require 'open3'
26
- require 'erb'
25
+ require "optparse"
26
+ require "tempfile"
27
+ require "open3"
28
+ require "erb"
27
29
 
28
30
  # This module contains the classes for the +pdfmult+ tool.
29
31
  module Pdfmult
30
32
 
31
- PROGNAME = 'pdfmult'
32
- VERSION = '1.3.1'
33
- DATE = '2013-01-04'
34
- HOMEPAGE = 'https://github.com/stomar/pdfmult/'
35
- TAGLINE = 'puts multiple copies of a PDF page on one page'
33
+ PROGNAME = "pdfmult"
34
+ VERSION = "1.4.0"
35
+ DATE = "2024-01-05"
36
+ HOMEPAGE = "https://github.com/stomar/pdfmult/"
37
+ TAGLINE = "puts multiple copies of a PDF page on one page"
36
38
 
37
- COPYRIGHT = "Copyright (C) 2011-2013 Marcus Stollsteimer.\n" +
38
- "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n" +
39
- "This is free software: you are free to change and redistribute it.\n" +
40
- "There is NO WARRANTY, to the extent permitted by law."
39
+ COPYRIGHT = <<~TEXT
40
+ Copyright (C) 2011-2024 Marcus Stollsteimer.
41
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
42
+ This is free software: you are free to change and redistribute it.
43
+ There is NO WARRANTY, to the extent permitted by law.
44
+ TEXT
41
45
 
42
- PDFLATEX = '/usr/bin/pdflatex'
43
- KPSEWHICH = '/usr/bin/kpsewhich'
46
+ PDFLATEX = "/usr/bin/pdflatex"
47
+ KPSEWHICH = "/usr/bin/kpsewhich"
44
48
 
45
49
  # Parser for the command line options.
46
50
  # The class method parse! does the job.
@@ -54,95 +58,96 @@ module Pdfmult
54
58
  #
55
59
  # Returns a hash containing the option parameters.
56
60
  def self.parse!(argv)
57
-
58
61
  options = {
59
- :force => false,
60
- :infile => nil,
61
- :latex => false,
62
- :number => 2,
63
- :outfile => nil,
64
- :silent => false,
65
- :pages => nil
62
+ force: false,
63
+ infile: nil,
64
+ latex: false,
65
+ number: 2,
66
+ outfile: nil,
67
+ silent: false,
68
+ pages: nil
66
69
  }
67
70
 
68
71
  opt_parser = OptionParser.new do |opt|
69
72
  opt.banner = "Usage: #{PROGNAME} [options] file"
70
- opt.separator ''
71
- opt.separator 'pdfmult is a command line tool that'
72
- opt.separator 'rearranges multiple copies of a PDF page (shrunken) on one page.'
73
- opt.separator ''
74
- opt.separator 'The paper size of the produced PDF file is A4,'
75
- opt.separator 'the input file is also assumed to be in A4 format.'
76
- opt.separator 'The input PDF file may consist of several pages.'
77
- opt.separator 'If pdfmult succeeds in obtaining the page count it will rearrange all pages,'
78
- opt.separator 'if not, only the first page is processed'
79
- opt.separator '(unless the page count was specified via command line option).'
80
- opt.separator ''
81
- opt.separator 'pdfmult uses pdflatex with the pdfpages package,'
82
- opt.separator 'so both have to be installed on the system.'
83
- opt.separator 'If the --latex option is used, though, pdflatex is not run'
84
- opt.separator 'and a LaTeX file is created instead of a PDF.'
85
- opt.separator ''
86
- opt.separator 'Options'
87
- opt.separator ''
73
+ opt.separator ""
74
+ opt.separator <<~DESCRIPTION
75
+ pdfmult is a command line tool that
76
+ rearranges multiple copies of a PDF page (shrunken) on one page.
77
+
78
+ The paper size of the produced PDF file is A4,
79
+ the input file is also assumed to be in A4 format.
80
+ The input PDF file may consist of several pages.
81
+ If pdfmult succeeds in obtaining the page count it will rearrange all pages,
82
+ if not, only the first page is processed
83
+ (unless the page count was specified via command line option).
84
+
85
+ pdfmult uses pdflatex with the pdfpages package,
86
+ so both have to be installed on the system.
87
+ If the --latex option is used, though, pdflatex is not run
88
+ and a LaTeX file is created instead of a PDF.
89
+
90
+ Options:
91
+ DESCRIPTION
88
92
 
89
93
  # process --version and --help first,
90
94
  # exit successfully (GNU Coding Standards)
91
- opt.on_tail('-h', '--help', 'Print a brief help message and exit.') do
95
+ opt.on_tail("-h", "--help", "Print a brief help message and exit.") do
92
96
  puts opt_parser
93
97
  puts "\nReport bugs on the #{PROGNAME} home page: <#{HOMEPAGE}>"
94
98
  exit
95
99
  end
96
100
 
97
- opt.on_tail('-v', '--version',
98
- 'Print a brief version information and exit.') do
101
+ opt.on_tail("-v", "--version",
102
+ "Print a brief version information and exit.") do
99
103
  puts "#{PROGNAME} #{VERSION}"
100
104
  puts COPYRIGHT
101
105
  exit
102
106
  end
103
107
 
104
- opt.on('-n', '--number NUMBER', ['2', '4', '8', '9', '16'], Integer,
105
- 'Number of copies to put on one page: 2 (default), 4, 8, 9, 16.') do |n|
108
+ opt.on("-n", "--number NUMBER", %w[2 4 8 9 16], Integer,
109
+ "Number of copies to put on one page: 2 (default), 4, 8, 9, 16.") do |n|
106
110
  options[:number] = n
107
111
  end
108
112
 
109
- opt.on('-f', '--[no-]force', 'Do not prompt before overwriting.') do |f|
113
+ opt.on("-f", "--[no-]force", "Do not prompt before overwriting.") do |f|
110
114
  options[:force] = f
111
115
  end
112
116
 
113
- opt.on('-l', '--latex', 'Create a LaTeX file instead of a PDF file (default: file_2.tex).') do
117
+ opt.on("-l", "--latex", "Create a LaTeX file instead of a PDF file (default: file_2.tex).") do
114
118
  options[:latex] = true
115
119
  end
116
120
 
117
- opt.on('-o', '--output FILE', String,
118
- 'Output file (default: file_2.pdf). Use - to output to stdout.') do |f|
121
+ opt.on("-o", "--output FILE", String,
122
+ "Output file (default: file_2.pdf). Use - to output to stdout.") do |f|
119
123
  options[:outfile] = f
120
124
  end
121
125
 
122
- opt.on('-p', '--pages NUMBER', Integer,
123
- 'Number of pages to convert.',
126
+ opt.on("-p", "--pages NUMBER", Integer,
127
+ "Number of pages to convert.",
124
128
  "If given, #{PROGNAME} does not try to obtain the page count from the source PDF.") do |p|
125
- raise(OptionParser::InvalidArgument, p) unless p > 0
129
+ raise(OptionParser::InvalidArgument, p) unless p.positive?
130
+
126
131
  options[:pages] = p
127
132
  end
128
133
 
129
- opt.on('-s', '--[no-]silent', 'Do not output progress information.') do |s|
134
+ opt.on("-s", "--[no-]silent", "Do not output progress information.") do |s|
130
135
  options[:silent] = s
131
136
  end
132
137
 
133
- opt.separator ''
138
+ opt.separator ""
134
139
  end
135
140
  opt_parser.parse!(argv)
136
141
 
137
142
  # only input file should be left in argv
138
- raise(ArgumentError, 'wrong number of arguments') if (argv.size != 1 || argv[0].empty?)
143
+ raise(ArgumentError, "wrong number of arguments") if argv.size != 1 || argv[0].empty?
139
144
 
140
145
  options[:infile] = argv.pop
141
146
 
142
147
  # set output file unless set by option
143
- ext = options[:latex] ? 'tex' : 'pdf'
144
- infile_without_ext = options[:infile].gsub(/(.pdf)\Z/, '')
145
- options[:outfile] ||= "#{infile_without_ext}_#{options[:number].to_s}.#{ext}"
148
+ ext = options[:latex] ? "tex" : "pdf"
149
+ infile_without_ext = options[:infile].delete_suffix(".pdf")
150
+ options[:outfile] ||= "#{infile_without_ext}_#{options[:number]}.#{ext}"
146
151
 
147
152
  options
148
153
  end
@@ -158,12 +163,12 @@ module Pdfmult
158
163
  attr_reader :pages, :geometry
159
164
 
160
165
  GEOMETRY = {
161
- 2 => '2x1',
162
- 4 => '2x2',
163
- 8 => '4x2',
164
- 9 => '3x3',
165
- 16 => '4x4'
166
- }
166
+ 2 => "2x1",
167
+ 4 => "2x2",
168
+ 8 => "4x2",
169
+ 9 => "3x3",
170
+ 16 => "4x4"
171
+ }.freeze
167
172
 
168
173
  def initialize(pages)
169
174
  @pages = pages
@@ -171,30 +176,31 @@ module Pdfmult
171
176
  end
172
177
 
173
178
  def landscape?
174
- ['2x1', '4x2'].include?(geometry)
179
+ %w[2x1 4x2].include?(geometry)
175
180
  end
176
181
  end
177
182
 
178
183
  # Class for the LaTeX document.
179
184
  #
180
- # Create an instance with LaTeXDocument.new, specifying
181
- # the input file, the number of pages to put on one page,
182
- # and the page count of the input file.
185
+ # Create an instance with LaTeXDocument.new, specifying the
186
+ # input file, the layout, and the page count of the input file.
183
187
  #
184
188
  # The method +to_s+ returns the document as multiline string.
185
189
  class LaTeXDocument
186
190
 
187
- TEMPLATE = %q(
191
+ attr_reader :pdffile, :layout, :page_count
192
+
193
+ TEMPLATE = <<~'LATEX'
188
194
  \documentclass[<%= class_options %>]{article}
189
195
  \usepackage{pdfpages}
190
196
  \pagestyle{empty}
191
197
  \setlength{\parindent}{0pt}
192
198
  \begin{document}
193
199
  % pages_strings.each do |pages|
194
- \includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= @pdffile %>}%
200
+ \includepdf[pages={<%= pages %>},nup=<%= geometry %>]{<%= pdffile %>}%
195
201
  % end
196
202
  \end{document}
197
- ).gsub(/\A\n/,'').gsub(/^ +/, '')
203
+ LATEX
198
204
 
199
205
  # Initializes a LaTeXDocument instance.
200
206
  # Expects an argument hash with:
@@ -209,9 +215,7 @@ module Pdfmult
209
215
  end
210
216
 
211
217
  def to_s
212
- class_options = "a4paper"
213
- class_options << ',landscape' if @layout.landscape?
214
- latex = ERB.new(TEMPLATE, 0, '%<>')
218
+ latex = ERB.new(TEMPLATE, trim_mode: "%<>")
215
219
 
216
220
  latex.result(binding)
217
221
  end
@@ -219,15 +223,23 @@ module Pdfmult
219
223
  private
220
224
 
221
225
  def geometry
222
- @layout.geometry
226
+ layout.geometry
227
+ end
228
+
229
+ def class_options
230
+ layout.landscape? ? "a4paper,landscape" : "a4paper"
231
+ end
232
+
233
+ def pages_per_sheet
234
+ layout.pages
223
235
  end
224
236
 
225
237
  # Returns an array of pages strings.
226
238
  # For 4 copies and 2 pages: ["1,1,1,1", "2,2,2,2"].
227
239
  def pages_strings
228
- template = 'PAGE,' * (@layout.pages - 1) + 'PAGE'
240
+ pages = (1..page_count).to_a
229
241
 
230
- Array.new(@page_count) {|i| template.gsub(/PAGE/, "#{i+1}") }
242
+ pages.map {|page| ([page] * pages_per_sheet).join(",") }
231
243
  end
232
244
  end
233
245
 
@@ -239,7 +251,7 @@ module Pdfmult
239
251
  # else the attribute is set to +nil+.
240
252
  class PDFInfo
241
253
 
242
- PDFINFOCMD = '/usr/bin/pdfinfo'
254
+ PDFINFOCMD = "/usr/bin/pdfinfo"
243
255
 
244
256
  # Returns the page count of the input file, or nil.
245
257
  attr_reader :page_count
@@ -247,11 +259,16 @@ module Pdfmult
247
259
  # This is the initialization method for the class.
248
260
  #
249
261
  # +file+ - file name of the PDF file
250
- def initialize(file, options={})
262
+ def initialize(file, options = {})
251
263
  @file = file
252
264
  @binary = options[:pdfinfocmd] || PDFINFOCMD # for unit tests
253
- @infos = retrieve_infos
254
- @page_count = @infos['Pages'] && @infos['Pages'].to_i
265
+ infos = retrieve_infos
266
+ @page_count = infos["Pages"]&.to_i
267
+ end
268
+
269
+ # Returns true if default +pdfinfo+ system tool is available (for unit tests).
270
+ def self.infocmd_available?
271
+ Application.command_available?("#{PDFINFOCMD} -v")
255
272
  end
256
273
 
257
274
  private
@@ -261,14 +278,9 @@ module Pdfmult
261
278
  command = "#{@binary} #{@file}"
262
279
  return {} unless Application.command_available?(command)
263
280
 
264
- info_array = `#{command}`.split(/\n/)
281
+ info_array = `#{command}`.split("\n")
265
282
 
266
- Hash[info_array.map {|line| line.split(/\s*:\s*/, 2) }]
267
- end
268
-
269
- # Returns true if default +pdfinfo+ system tool is available (for unit tests).
270
- def self.infocmd_available?
271
- Application.command_available?("#{PDFINFOCMD} -v")
283
+ info_array.to_h {|line| line.split(/\s*:\s*/, 2) }
272
284
  end
273
285
  end
274
286
 
@@ -277,62 +289,62 @@ module Pdfmult
277
289
  # It parses the command line arguments and does the job.
278
290
  class Application
279
291
 
280
- ERRORCODE = {:general => 1, :usage => 2}
281
-
282
- # The main program.
283
- def self.run!
292
+ ERRORCODE = { general: 1, usage: 2 }.freeze
284
293
 
285
- # parse options
294
+ def initialize
286
295
  begin
287
296
  options = Optionparser.parse!(ARGV)
288
- rescue => e
297
+ rescue StandardError => e
289
298
  usage_fail(e.message)
290
299
  end
300
+ @infile = options[:infile]
301
+ @outfile = options[:outfile]
302
+ @use_stdout = (@outfile == "-")
303
+ @silent = options[:silent]
304
+ @force = options[:force]
305
+ @latex = options[:latex]
306
+ @number = options[:number]
307
+ @pages = options[:pages] || PDFInfo.new(@infile).page_count || 1
308
+ end
291
309
 
292
- infile = options[:infile]
293
- outfile = options[:outfile]
294
- use_stdout = (outfile == '-')
295
- silent = options[:silent]
296
-
310
+ # The main program.
311
+ def run!
297
312
  # test for pdflatex installation
298
- unless options[:latex]
299
- message = 'seems not to be installed (you might try using the -l option)'
300
- general_fail("`#{PDFLATEX}' #{message}") unless command_available?("#{PDFLATEX} --version")
301
- general_fail("`pdfpages.sty' #{message}") unless command_available?("#{KPSEWHICH} pdfpages.sty")
313
+ unless @latex
314
+ message = "seems not to be installed (you might try using the -l option)"
315
+ general_fail("`#{PDFLATEX}' #{message}") unless self.class.command_available?("#{PDFLATEX} --version")
316
+ general_fail("`pdfpages.sty' #{message}") unless self.class.command_available?("#{KPSEWHICH} pdfpages.sty")
302
317
  end
303
318
 
304
319
  # test input file
305
- usage_fail("no such file: `#{infile}'") unless File.exist?(infile)
306
- usage_fail("specified input not of the type `file'") unless File.ftype(infile) == 'file'
320
+ usage_fail("no such file: `#{@infile}'") unless File.exist?(@infile)
321
+ usage_fail("specified input not of the type `file'") unless File.ftype(@infile) == "file"
307
322
 
308
323
  # test for existing output file
309
- if !use_stdout and !options[:force] and File.exist?(outfile)
310
- overwrite_ok = ask("File `#{outfile}' already exists. Overwrite?")
324
+ if !@use_stdout && !@force && File.exist?(@outfile)
325
+ overwrite_ok = confirm("File `#{@outfile}' already exists. Overwrite?")
311
326
  exit unless overwrite_ok
312
327
  end
313
328
 
314
- # set page number (get PDF info if necessary)
315
- pages = options[:pages] || PDFInfo.new(infile).page_count || 1
316
-
317
329
  # create LaTeX document
318
330
  args = {
319
- :pdffile => infile,
320
- :layout => Layout.new(options[:number]),
321
- :page_count => pages
331
+ pdffile: @infile,
332
+ layout: Layout.new(@number),
333
+ page_count: @pages
322
334
  }
323
335
  document = LaTeXDocument.new(args)
324
336
 
325
337
  output = nil
326
- if options[:latex]
338
+ if @latex
327
339
  output = document.to_s
328
340
  else
329
- Dir.mktmpdir('pdfmult') do |dir|
330
- texfile = 'pdfmult.tex'
331
- pdffile = 'pdfmult.pdf'
332
- open("#{dir}/#{texfile}", 'w') {|f| f.write(document.to_s) }
341
+ Dir.mktmpdir("pdfmult") do |dir|
342
+ texfile = "pdfmult.tex"
343
+ pdffile = "pdfmult.pdf"
344
+ File.write("#{dir}/#{texfile}", document.to_s)
333
345
  command = "#{PDFLATEX} -output-directory #{dir} #{texfile}"
334
- Open3.popen3(command) do |stdin, stdout, stderr|
335
- stdout.each_line {|line| warn line.chomp } unless silent # redirect progress messages to stderr
346
+ Open3.popen3(command) do |_stdin, stdout, stderr|
347
+ stdout.each_line {|line| warn line.chomp } unless @silent # redirect progress messages to stderr
336
348
  stderr.read # make sure all streams are read (and command has finished)
337
349
  end
338
350
  output = File.read("#{dir}/#{pdffile}")
@@ -340,52 +352,51 @@ module Pdfmult
340
352
  end
341
353
 
342
354
  # redirect stdout to output file
343
- $stdout.reopen(outfile, 'w') unless use_stdout
355
+ $stdout.reopen(@outfile, "w") unless @use_stdout
344
356
 
345
- warn "Writing on #{outfile}." unless (use_stdout || silent)
357
+ warn "Writing on #{@outfile}." unless @use_stdout || @silent
346
358
  puts output
347
359
  end
348
360
 
361
+ # Tests silently whether the given system command is available.
362
+ #
363
+ # +command+ - command to test
364
+ def self.command_available?(command) # :nodoc:
365
+ !!system("#{command} >/dev/null 2>&1")
366
+ end
367
+
368
+ private
369
+
349
370
  # Asks for yes or no (y/n).
350
371
  #
351
372
  # +question+ - string to be printed
352
373
  #
353
374
  # Returns +true+ if the answer is yes.
354
- def self.ask(question) # :nodoc:
375
+ def confirm(question)
355
376
  loop do
356
377
  $stderr.print "#{question} [y/n] "
357
- reply = $stdin.gets.chomp.downcase # $stdin: avoids gets / ARGV problem
358
- return true if reply == 'y'
359
- return false if reply == 'n'
378
+ reply = $stdin.gets.chomp.downcase # $stdin avoids gets/ARGV problem
379
+ return reply == "y" if reply.match?(/\A[yn]\z/)
380
+
360
381
  warn "Please answer `y' or `n'."
361
382
  end
362
383
  end
363
384
 
364
385
  # Prints an error message and exits.
365
- def self.general_fail(message) # :nodoc:
386
+ def general_fail(message)
366
387
  warn "#{PROGNAME}: #{message}"
367
388
  exit ERRORCODE[:general]
368
389
  end
369
390
 
370
391
  # Prints an error message and a short help information, then exits.
371
- def self.usage_fail(message) # :nodoc:
392
+ def usage_fail(message)
372
393
  warn "#{PROGNAME}: #{message}"
373
394
  warn "Use `#{PROGNAME} --help' for valid options."
374
395
  exit ERRORCODE[:usage]
375
396
  end
376
-
377
- # Tests silently whether the given system command is available.
378
- #
379
- # +command+ - command to test
380
- def self.command_available?(command) # :nodoc:
381
- !!system("#{command} >/dev/null 2>&1")
382
- end
383
397
  end
398
+ end
384
399
 
385
400
  ### call main method only if called on command line
386
401
 
387
- if __FILE__ == $0
388
- Application.run!
389
- end
390
-
391
- end # module
402
+ Pdfmult::Application.new.run! if __FILE__ == $PROGRAM_NAME
data/man/pdfmult.1 CHANGED
@@ -1,10 +1,10 @@
1
- .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4.
2
- .TH PDFMULT "1" "January 2013" "pdfmult 1.3.1" "User Commands"
1
+ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.1.
2
+ .TH PDFMULT "1" "January 2024" "pdfmult 1.4.0" "User Commands"
3
3
  .SH NAME
4
4
  pdfmult \- puts multiple copies of a PDF page on one page
5
5
  .SH SYNOPSIS
6
6
  .B pdfmult
7
- [\fIoptions\fR] \fIfile\fR
7
+ [\fI\,options\/\fR] \fI\,file\/\fR
8
8
  .SH DESCRIPTION
9
9
  pdfmult is a command line tool that
10
10
  rearranges multiple copies of a PDF page (shrunken) on one page.
@@ -55,7 +55,7 @@ Print a brief version information and exit.
55
55
  .SH "REPORTING BUGS"
56
56
  Report bugs on the pdfmult home page: <https://github.com/stomar/pdfmult/>
57
57
  .SH COPYRIGHT
58
- Copyright \(co 2011\-2013 Marcus Stollsteimer.
58
+ Copyright \(co 2011\-2024 Marcus Stollsteimer.
59
59
  .br
60
60
  License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
61
61
  .br
data/pdfmult.gemspec CHANGED
@@ -1,4 +1,6 @@
1
- require './lib/pdfmult'
1
+ # frozen_string_literal: true
2
+
3
+ require "./lib/pdfmult"
2
4
 
3
5
  version = Pdfmult::VERSION
4
6
  date = Pdfmult::DATE
@@ -6,40 +8,42 @@ homepage = Pdfmult::HOMEPAGE
6
8
  tagline = Pdfmult::TAGLINE
7
9
 
8
10
  Gem::Specification.new do |s|
9
- s.name = 'pdfmult'
11
+ s.name = "pdfmult"
10
12
  s.version = version
11
13
  s.date = date
12
- s.rubyforge_project = 'pdfmult'
13
14
 
14
- s.description = 'pdfmult is a command line tool that rearranges ' +
15
- 'multiple copies of a PDF page (shrunken) on one page. ' +
16
- 'It is a wrapper for pdflatex with the pdfpages package.'
15
+ s.description = "pdfmult is a command line tool that rearranges " \
16
+ "multiple copies of a PDF page (shrunken) on one page. " \
17
+ "It is a wrapper for pdflatex with the pdfpages package."
17
18
  s.summary = "pdfmult - #{tagline}"
18
19
 
19
- s.authors = ['Marcus Stollsteimer']
20
- s.email = 'sto.mar@web.de'
20
+ s.authors = ["Marcus Stollsteimer"]
21
+ s.email = "sto.mar@web.de"
21
22
  s.homepage = homepage
22
23
 
23
- s.license = 'GPL-3'
24
+ s.license = "GPL-3.0"
25
+
26
+ s.required_ruby_version = ">= 3.1.0"
27
+
28
+ s.requirements << "pdflatex and the pdfpages package"
24
29
 
25
- s.requirements << 'pdflatex and the pdfpages package'
30
+ s.executables = ["pdfmult"]
31
+ s.bindir = "bin"
26
32
 
27
- s.executables = ['pdfmult']
28
- s.bindir = 'bin'
29
- s.require_path = 'lib'
30
- s.test_files = Dir.glob('test/**/test_*.rb')
33
+ s.require_paths = ["lib"]
31
34
 
32
- s.rdoc_options = ['--charset=UTF-8']
35
+ s.test_files = Dir.glob("test/**/test_*.rb")
33
36
 
34
- s.files = %w{
37
+ s.files =
38
+ %w[
35
39
  README.md
36
40
  Rakefile
41
+ Gemfile
37
42
  pdfmult.gemspec
38
43
  pdfmult.h2m
39
- } +
40
- Dir.glob('example*.*') +
41
- Dir.glob('{bin,lib,man,test}/**/*')
44
+ ] +
45
+ Dir.glob("example*.*") +
46
+ Dir.glob("{bin,lib,man,test}/**/*")
42
47
 
43
- s.add_development_dependency('rake')
44
- s.add_development_dependency('minitest')
48
+ s.rdoc_options = ["--charset=UTF-8"]
45
49
  end
@@ -1,10 +1,7 @@
1
- # test_latex_document.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::LaTeXDocument do
@@ -13,27 +10,27 @@ describe Pdfmult::LaTeXDocument do
13
10
  @layout_class = Pdfmult::Layout
14
11
  end
15
12
 
16
- it 'should return the expected LaTeX code for 4 pages' do
13
+ it "should return the expected LaTeX code for 4 pages" do
17
14
  args = {
18
- :pdffile => 'sample.pdf',
19
- :layout => @layout_class.new(4),
20
- :page_count => 3
15
+ pdffile: "sample.pdf",
16
+ layout: @layout_class.new(4),
17
+ page_count: 3
21
18
  }
22
- document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
23
- document_lines[0].must_equal '\documentclass[a4paper]{article}'
24
- document_lines[-2].must_equal '\includepdf[pages={3,3,3,3},nup=2x2]{sample.pdf}%'
25
- document_lines.grep(/includepdf/).size.must_equal args[:page_count]
19
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split("\n")
20
+ _(document_lines[0]).must_equal '\documentclass[a4paper]{article}'
21
+ _(document_lines[-2]).must_equal '\includepdf[pages={3,3,3,3},nup=2x2]{sample.pdf}%'
22
+ _(document_lines.grep(/includepdf/).size).must_equal args[:page_count]
26
23
  end
27
24
 
28
- it 'should return the expected LaTeX code for 8 pages' do
25
+ it "should return the expected LaTeX code for 8 pages" do
29
26
  args = {
30
- :pdffile => 'sample.pdf',
31
- :layout => @layout_class.new(8),
32
- :page_count => 5
27
+ pdffile: "sample.pdf",
28
+ layout: @layout_class.new(8),
29
+ page_count: 5
33
30
  }
34
- document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split(/\n/)
35
- document_lines[0].must_equal '\documentclass[a4paper,landscape]{article}'
36
- document_lines[-2].must_equal '\includepdf[pages={5,5,5,5,5,5,5,5},nup=4x2]{sample.pdf}%'
37
- document_lines.grep(/includepdf/).size.must_equal args[:page_count]
31
+ document_lines = Pdfmult::LaTeXDocument.new(args).to_s.split("\n")
32
+ _(document_lines[0]).must_equal '\documentclass[a4paper,landscape]{article}'
33
+ _(document_lines[-2]).must_equal '\includepdf[pages={5,5,5,5,5,5,5,5},nup=4x2]{sample.pdf}%'
34
+ _(document_lines.grep(/includepdf/).size).must_equal args[:page_count]
38
35
  end
39
36
  end
data/test/test_layout.rb CHANGED
@@ -1,10 +1,7 @@
1
- # test_layout.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::Layout do
@@ -13,45 +10,45 @@ describe Pdfmult::Layout do
13
10
  @layout = Pdfmult::Layout.new(2)
14
11
  end
15
12
 
16
- it 'can return the number of pages' do
17
- @layout.pages.must_equal 2
13
+ it "can return the number of pages" do
14
+ _(@layout.pages).must_equal 2
18
15
  end
19
16
 
20
- it 'can return the geometry' do
21
- @layout.geometry.must_equal '2x1'
17
+ it "can return the geometry" do
18
+ _(@layout.geometry).must_equal "2x1"
22
19
  end
23
20
 
24
- it 'knows whether it is landscape' do
25
- @layout.landscape?.must_equal true
21
+ it "knows whether it is landscape" do
22
+ _(@layout.landscape?).must_equal true
26
23
  end
27
24
 
28
- it 'returns the correct layout for 2 pages' do
25
+ it "returns the correct layout for 2 pages" do
29
26
  layout = Pdfmult::Layout.new(2)
30
- layout.geometry.must_equal '2x1'
31
- layout.landscape?.must_equal true
27
+ _(layout.geometry).must_equal "2x1"
28
+ _(layout.landscape?).must_equal true
32
29
  end
33
30
 
34
- it 'returns the correct layout for 4 pages' do
31
+ it "returns the correct layout for 4 pages" do
35
32
  layout = Pdfmult::Layout.new(4)
36
- layout.geometry.must_equal '2x2'
37
- layout.landscape?.must_equal false
33
+ _(layout.geometry).must_equal "2x2"
34
+ _(layout.landscape?).must_equal false
38
35
  end
39
36
 
40
- it 'returns the correct layout for 8 pages' do
37
+ it "returns the correct layout for 8 pages" do
41
38
  layout = Pdfmult::Layout.new(8)
42
- layout.geometry.must_equal '4x2'
43
- layout.landscape?.must_equal true
39
+ _(layout.geometry).must_equal "4x2"
40
+ _(layout.landscape?).must_equal true
44
41
  end
45
42
 
46
- it 'returns the correct layout for 9 pages' do
43
+ it "returns the correct layout for 9 pages" do
47
44
  layout = Pdfmult::Layout.new(9)
48
- layout.geometry.must_equal '3x3'
49
- layout.landscape?.must_equal false
45
+ _(layout.geometry).must_equal "3x3"
46
+ _(layout.landscape?).must_equal false
50
47
  end
51
48
 
52
- it 'returns the correct layout for 16 pages' do
49
+ it "returns the correct layout for 16 pages" do
53
50
  layout = Pdfmult::Layout.new(16)
54
- layout.geometry.must_equal '4x4'
55
- layout.landscape?.must_equal false
51
+ _(layout.geometry).must_equal "4x4"
52
+ _(layout.landscape?).must_equal false
56
53
  end
57
54
  end
@@ -1,87 +1,84 @@
1
- # test_optionparser.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
 
10
7
  describe Pdfmult::Optionparser do
11
8
 
12
- it 'should return the correct default values' do
13
- options = Pdfmult::Optionparser.parse!(['sample.pdf'])
9
+ it "should return the correct default values" do
10
+ options = Pdfmult::Optionparser.parse!(["sample.pdf"])
14
11
  expected = {
15
- :force => false,
16
- :infile => 'sample.pdf',
17
- :latex => false,
18
- :number => 2,
19
- :outfile => 'sample_2.pdf',
20
- :pages => nil,
21
- :silent => false
12
+ force: false,
13
+ infile: "sample.pdf",
14
+ latex: false,
15
+ number: 2,
16
+ outfile: "sample_2.pdf",
17
+ pages: nil,
18
+ silent: false
22
19
  }
23
- options.must_equal expected
20
+ _(options).must_equal expected
24
21
  end
25
22
 
26
- it 'should recognize the -n option and set the corresponding output filename' do
27
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-n', '4'])
28
- options[:outfile].must_equal 'sample_4.pdf'
29
- options[:number].must_equal 4
23
+ it "should recognize the -n option and set the corresponding output filename" do
24
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-n", "4"])
25
+ _(options[:outfile]).must_equal "sample_4.pdf"
26
+ _(options[:number]).must_equal 4
30
27
  end
31
28
 
32
- it 'should not accept invalid -n option values' do
33
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-n', '3']) }.must_raise OptionParser::InvalidArgument
29
+ it "should not accept invalid -n option values" do
30
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-n", "3"]) }.must_raise OptionParser::InvalidArgument
34
31
  end
35
32
 
36
- it 'should recognize the -o option' do
37
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-o', 'outfile.pdf'])
38
- options[:outfile].must_equal 'outfile.pdf'
33
+ it "should recognize the -o option" do
34
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-o", "outfile.pdf"])
35
+ _(options[:outfile]).must_equal "outfile.pdf"
39
36
  end
40
37
 
41
- it 'should recognize the -p option' do
42
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '4'])
43
- options[:pages].must_equal 4
38
+ it "should recognize the -p option" do
39
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "4"])
40
+ _(options[:pages]).must_equal 4
44
41
  end
45
42
 
46
- it 'should recognize the -f option' do
47
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-f'])
48
- options[:force].must_equal true
43
+ it "should recognize the -f option" do
44
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-f"])
45
+ _(options[:force]).must_equal true
49
46
  end
50
47
 
51
- it 'should recognize the --no-force option' do
52
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '--no-force'])
53
- options[:force].must_equal false
48
+ it "should recognize the --no-force option" do
49
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "--no-force"])
50
+ _(options[:force]).must_equal false
54
51
  end
55
52
 
56
- it 'should recognize the -l option and set the corresponding output filename' do
57
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-l'])
58
- options[:outfile].must_equal 'sample_2.tex'
59
- options[:latex].must_equal true
53
+ it "should recognize the -l option and set the corresponding output filename" do
54
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-l"])
55
+ _(options[:outfile]).must_equal "sample_2.tex"
56
+ _(options[:latex]).must_equal true
60
57
  end
61
58
 
62
- it 'should only accept positive -p option values' do
63
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '0.5']) }.must_raise OptionParser::InvalidArgument
64
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '0']) }.must_raise OptionParser::InvalidArgument
65
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', '-p', '-1']) }.must_raise OptionParser::InvalidArgument
59
+ it "should only accept positive -p option values" do
60
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "0.5"]) }.must_raise OptionParser::InvalidArgument
61
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "0"]) }.must_raise OptionParser::InvalidArgument
62
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "-p", "-1"]) }.must_raise OptionParser::InvalidArgument
66
63
  end
67
64
 
68
- it 'should recognize the -s option' do
69
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '-s'])
70
- options[:silent].must_equal true
65
+ it "should recognize the -s option" do
66
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "-s"])
67
+ _(options[:silent]).must_equal true
71
68
  end
72
69
 
73
- it 'should recognize the --no-silent option' do
74
- options = Pdfmult::Optionparser.parse!(['sample.pdf', '--no-silent'])
75
- options[:silent].must_equal false
70
+ it "should recognize the --no-silent option" do
71
+ options = Pdfmult::Optionparser.parse!(["sample.pdf", "--no-silent"])
72
+ _(options[:silent]).must_equal false
76
73
  end
77
74
 
78
- it 'should not accept wrong number of arguments' do
79
- lambda { Pdfmult::Optionparser.parse!(['sample.pdf', 'sample2.pdf']) }.must_raise ArgumentError
80
- lambda { Pdfmult::Optionparser.parse!(['']) }.must_raise ArgumentError
81
- lambda { Pdfmult::Optionparser.parse!([]) }.must_raise ArgumentError
75
+ it "should not accept wrong number of arguments" do
76
+ _ { Pdfmult::Optionparser.parse!(["sample.pdf", "sample2.pdf"]) }.must_raise ArgumentError
77
+ _ { Pdfmult::Optionparser.parse!([""]) }.must_raise ArgumentError
78
+ _ { Pdfmult::Optionparser.parse!([]) }.must_raise ArgumentError
82
79
  end
83
80
 
84
- it 'should not accept invalid options' do
85
- lambda { Pdfmult::Optionparser.parse!(['-x']) }.must_raise OptionParser::InvalidOption
81
+ it "should not accept invalid options" do
82
+ _ { Pdfmult::Optionparser.parse!(["-x"]) }.must_raise OptionParser::InvalidOption
86
83
  end
87
84
  end
data/test/test_pdfinfo.rb CHANGED
@@ -1,10 +1,7 @@
1
- # test_pdfinfo.rb: Unit tests for the pdfmult script.
2
- #
3
- # Copyright (C) 2011-2013 Marcus Stollsteimer
1
+ # frozen_string_literal: true
4
2
 
5
- require 'minitest/spec'
6
- require 'minitest/autorun'
7
- require 'pdfmult'
3
+ require "minitest/autorun"
4
+ require "pdfmult"
8
5
 
9
6
  SRCPATH = File.dirname(__FILE__)
10
7
 
@@ -15,20 +12,20 @@ describe Pdfmult::PDFInfo do
15
12
  @sample_pdf = File.expand_path("#{SRCPATH}/sample.pdf")
16
13
  end
17
14
 
18
- describe 'when asked about the page count' do
19
- it 'should return the page count for existing file and system tool' do
15
+ describe "when asked about the page count" do
16
+ it "should return the page count for existing file and system tool" do
20
17
  infocmd = Pdfmult::PDFInfo::PDFINFOCMD
21
18
  skip("Skipped: `#{infocmd}' not available on the system") unless Pdfmult::PDFInfo.infocmd_available?
22
- Pdfmult::PDFInfo.new(@sample_pdf).page_count.must_equal 3
23
- Pdfmult::PDFInfo.new(@sample_pdf, :pdfinfocmd => infocmd).page_count.must_equal 3
19
+ _(Pdfmult::PDFInfo.new(@sample_pdf).page_count).must_equal 3
20
+ _(Pdfmult::PDFInfo.new(@sample_pdf, pdfinfocmd: infocmd).page_count).must_equal 3
24
21
  end
25
22
 
26
- it 'should return nil for non-existent files' do
27
- Pdfmult::PDFInfo.new('not_a_file.pdf').page_count.must_be_nil
23
+ it "should return nil for non-existent files" do
24
+ _(Pdfmult::PDFInfo.new("not_a_file.pdf").page_count).must_be_nil
28
25
  end
29
26
 
30
27
  it "should return nil for non-existent `pdfinfo' system tool" do
31
- Pdfmult::PDFInfo.new(@sample_pdf, :pdfinfocmd => 'not_a_command').page_count.must_be_nil
28
+ _(Pdfmult::PDFInfo.new(@sample_pdf, pdfinfocmd: "not_a_command").page_count).must_be_nil
32
29
  end
33
30
  end
34
31
  end
metadata CHANGED
@@ -1,111 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: pdfmult
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 1
8
- - 3
9
- - 1
10
- version: 1.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.4.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Marcus Stollsteimer
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-01-04 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
32
- type: :development
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: minitest
36
- prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
46
- type: :development
47
- version_requirements: *id002
48
- description: pdfmult is a command line tool that rearranges multiple copies of a PDF page (shrunken) on one page. It is a wrapper for pdflatex with the pdfpages package.
11
+ date: 2024-01-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: pdfmult is a command line tool that rearranges multiple copies of a PDF
14
+ page (shrunken) on one page. It is a wrapper for pdflatex with the pdfpages package.
49
15
  email: sto.mar@web.de
50
- executables:
16
+ executables:
51
17
  - pdfmult
52
18
  extensions: []
53
-
54
19
  extra_rdoc_files: []
55
-
56
- files:
20
+ files:
21
+ - Gemfile
57
22
  - README.md
58
23
  - Rakefile
59
- - pdfmult.gemspec
60
- - pdfmult.h2m
24
+ - bin/pdfmult
61
25
  - example1.fig
62
26
  - example1.png
63
27
  - example2.fig
64
28
  - example2.png
65
- - bin/pdfmult
66
29
  - lib/pdfmult.rb
67
30
  - man/pdfmult.1
68
- - test/test_pdfinfo.rb
69
- - test/test_latex_document.rb
31
+ - pdfmult.gemspec
32
+ - pdfmult.h2m
33
+ - test/sample.pdf
70
34
  - test/sample.tex
35
+ - test/test_latex_document.rb
71
36
  - test/test_layout.rb
72
37
  - test/test_optionparser.rb
73
- - test/sample.pdf
38
+ - test/test_pdfinfo.rb
74
39
  homepage: https://github.com/stomar/pdfmult/
75
- licenses:
76
- - GPL-3
40
+ licenses:
41
+ - GPL-3.0
42
+ metadata: {}
77
43
  post_install_message:
78
- rdoc_options:
79
- - --charset=UTF-8
80
- require_paths:
44
+ rdoc_options:
45
+ - "--charset=UTF-8"
46
+ require_paths:
81
47
  - lib
82
- required_ruby_version: !ruby/object:Gem::Requirement
83
- none: false
84
- requirements:
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
85
50
  - - ">="
86
- - !ruby/object:Gem::Version
87
- hash: 3
88
- segments:
89
- - 0
90
- version: "0"
91
- required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
- requirements:
51
+ - !ruby/object:Gem::Version
52
+ version: 3.1.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
94
55
  - - ">="
95
- - !ruby/object:Gem::Version
96
- hash: 3
97
- segments:
98
- - 0
99
- version: "0"
100
- requirements:
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements:
101
59
  - pdflatex and the pdfpages package
102
- rubyforge_project: pdfmult
103
- rubygems_version: 1.8.24
60
+ rubygems_version: 3.5.3
104
61
  signing_key:
105
- specification_version: 3
62
+ specification_version: 4
106
63
  summary: pdfmult - puts multiple copies of a PDF page on one page
107
- test_files:
108
- - test/test_pdfinfo.rb
64
+ test_files:
109
65
  - test/test_latex_document.rb
110
66
  - test/test_layout.rb
111
67
  - test/test_optionparser.rb
68
+ - test/test_pdfinfo.rb