pdfmult 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
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="/stomar/pdfmult/raw/master/example1.png" alt="" width="152" height="59">
26
+ <img src="https://github.com/stomar/pdfmult/raw/master/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="/stomar/pdfmult/raw/master/example2.png" alt="" width="234" height="59">
32
+ <img src="https://github.com/stomar/pdfmult/raw/master/example2.png" alt="" width="234" height="59">
33
33
 
34
34
  * `pdfmult sample.pdf -o outfile.pdf`
35
35
 
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ end
34
34
  desc 'Install binary and man page'
35
35
  task :install => [BINARY, MANPAGE] do
36
36
  mkdir_p BINDIR
37
- install(BINARY, BINDIR + '/' + BINARYNAME)
37
+ install(BINARY, "#{BINDIR}/#{BINARYNAME}")
38
38
  mkdir_p MANDIR
39
39
  install(MANPAGE, MANDIR, :mode => 0644)
40
40
  end
@@ -27,13 +27,15 @@
27
27
  #
28
28
  # -n, --number:: Number of copies to put on one page: 2 (default), 4, 8, 9, 16.
29
29
  #
30
+ # -f, --force:: Do not prompt before overwriting.
31
+ #
32
+ # -l, --latex:: Create a LaTeX file instead of a PDF file (default: infile_NUMBER.tex).
33
+ #
30
34
  # -o, --output:: Output file (default: infile_NUMBER.pdf).
31
35
  #
32
36
  # -p, --pages:: Number of pages to convert.
33
37
  # If given, +pdfmult+ does not try to obtain the page count from the source PDF.
34
38
  #
35
- # -l, --latex:: Create a LaTeX file instead of a PDF file (default: infile_NUMBER.tex).
36
- #
37
39
  # -h, --help:: Prints a brief help message and exits.
38
40
  #
39
41
  # -v, --version:: Prints a brief version information and exits.
@@ -61,8 +63,10 @@ require 'fileutils'
61
63
  module Pdfmult
62
64
 
63
65
  PROGNAME = 'pdfmult'
64
- VERSION = '1.1.0'
65
- DATE = '2012-03-16'
66
+ VERSION = '1.2.0'
67
+ DATE = '2012-04-15'
68
+ HOMEPAGE = 'https://github.com/stomar/pdfmult/'
69
+
66
70
  COPYRIGHT = "Copyright (C) 2011-2012 Marcus Stollsteimer.\n" +
67
71
  "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n" +
68
72
  "This is free software: you are free to change and redistribute it.\n" +
@@ -85,9 +89,10 @@ module Pdfmult
85
89
  def self.parse!(argv)
86
90
 
87
91
  options = {
88
- :number => 2,
92
+ :force => false,
89
93
  :infile => nil,
90
94
  :latex => false,
95
+ :number => 2,
91
96
  :outfile => nil,
92
97
  :pages => nil
93
98
  }
@@ -117,7 +122,7 @@ module Pdfmult
117
122
  # exit successfully (GNU Coding Standards)
118
123
  opt.on_tail('-h', '--help', 'Prints a brief help message and exits.') do
119
124
  puts opt_parser
120
- puts "\nReport bugs on the pdfmult home page: <https://github.com/stomar/pdfmult/>"
125
+ puts "\nReport bugs on the #{PROGNAME} home page: <#{HOMEPAGE}>"
121
126
  exit
122
127
  end
123
128
 
@@ -133,6 +138,14 @@ module Pdfmult
133
138
  options[:number] = n
134
139
  end
135
140
 
141
+ opt.on('-f', '--force', 'Do not prompt before overwriting.') do
142
+ options[:force] = true
143
+ end
144
+
145
+ opt.on('-l', '--latex', 'Create a LaTeX file instead of a PDF file (default: file_2.tex).') do
146
+ options[:latex] = true
147
+ end
148
+
136
149
  opt.on('-o', '--output FILE', String,
137
150
  'Output file (default: file_2.pdf).') do |f|
138
151
  options[:outfile] = f
@@ -145,10 +158,6 @@ module Pdfmult
145
158
  options[:pages] = p
146
159
  end
147
160
 
148
- opt.on('-l', '--latex', 'Create a LaTeX file instead of a PDF file (default: file_2.tex).') do
149
- options[:latex] = true
150
- end
151
-
152
161
  opt.separator ''
153
162
  end
154
163
  opt_parser.parse!(argv)
@@ -160,7 +169,8 @@ module Pdfmult
160
169
 
161
170
  # set output file unless set by option
162
171
  ext = options[:latex] ? 'tex' : 'pdf'
163
- options[:outfile] ||= options[:infile].gsub(/(.pdf)$/, '') + "_#{options[:number].to_s}.#{ext}"
172
+ infile_without_ext = options[:infile].gsub(/(.pdf)\Z/, '')
173
+ options[:outfile] ||= "#{infile_without_ext}_#{options[:number].to_s}.#{ext}"
164
174
 
165
175
  options
166
176
  end
@@ -207,12 +217,12 @@ module Pdfmult
207
217
 
208
218
  case @number
209
219
  when 2
210
- class_options += ',landscape'
220
+ class_options << ',landscape'
211
221
  geometry = '2x1'
212
222
  when 4
213
223
  geometry = '2x2'
214
224
  when 8
215
- class_options += ',landscape'
225
+ class_options << ',landscape'
216
226
  geometry = '4x2'
217
227
  when 9
218
228
  geometry = '3x3'
@@ -266,7 +276,7 @@ module Pdfmult
266
276
 
267
277
  # Returns true if default +pdfinfo+ system tool is available (for unit tests).
268
278
  def self.infocmd_available? # :nodoc:
269
- Application.command_available?(PDFINFOCMD + ' -v')
279
+ Application.command_available?("#{PDFINFOCMD} -v")
270
280
  end
271
281
  end
272
282
 
@@ -302,7 +312,7 @@ module Pdfmult
302
312
  usage_fail("specified input not of the type `file'") unless File.ftype(infile) == 'file'
303
313
 
304
314
  # test for existing output file
305
- if File.exist?(outfile)
315
+ if File.exist?(outfile) and !options[:force]
306
316
  overwrite_ok = ask("File `#{outfile}' already exists. Overwrite?")
307
317
  exit unless overwrite_ok
308
318
  end
@@ -316,9 +326,7 @@ module Pdfmult
316
326
  document = LaTeXDocument.new(infile, options[:number], pages)
317
327
 
318
328
  if options[:latex]
319
- open(outfile, 'w') do |f|
320
- f.write(document.to_s)
321
- end
329
+ open(outfile, 'w') {|f| f.write(document.to_s) }
322
330
  else
323
331
  Dir.mktmpdir('pdfmult') do |dir|
324
332
  open("#{dir}/pdfmult.tex", 'w') do |f|
@@ -340,7 +348,7 @@ module Pdfmult
340
348
  # Returns +true+ if the answer is yes.
341
349
  def self.ask(question) # :nodoc:
342
350
  while true
343
- print question + ' [y/n] '
351
+ print "#{question} [y/n] "
344
352
  reply = $stdin.gets.chomp.downcase # $stdin: avoids gets / ARGV problem
345
353
  return true if reply == 'y'
346
354
  return false if reply == 'n'
@@ -365,7 +373,7 @@ module Pdfmult
365
373
  #
366
374
  # +command+ - command to test
367
375
  def self.command_available?(command) # :nodoc:
368
- !!system(command + ' >/dev/null 2>&1')
376
+ !!system("#{command} >/dev/null 2>&1")
369
377
  end
370
378
  end
371
379
 
@@ -1,5 +1,5 @@
1
1
  .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.40.4.
2
- .TH PDFMULT "1" "March 2012" "pdfmult 1.1.0" "User Commands"
2
+ .TH PDFMULT "1" "April 2012" "pdfmult 1.2.0" "User Commands"
3
3
  .SH NAME
4
4
  pdfmult \- puts multiple copies of a PDF page on one page
5
5
  .SH SYNOPSIS
@@ -25,6 +25,12 @@ and a LaTeX file is created instead of a PDF.
25
25
  \fB\-n\fR, \fB\-\-number\fR NUMBER
26
26
  Number of copies to put on one page: 2 (default), 4, 8, 9, 16.
27
27
  .TP
28
+ \fB\-f\fR, \fB\-\-force\fR
29
+ Do not prompt before overwriting.
30
+ .TP
31
+ \fB\-l\fR, \fB\-\-latex\fR
32
+ Create a LaTeX file instead of a PDF file (default: file_2.tex).
33
+ .TP
28
34
  \fB\-o\fR, \fB\-\-output\fR FILE
29
35
  Output file (default: file_2.pdf).
30
36
  .TP
@@ -32,9 +38,6 @@ Output file (default: file_2.pdf).
32
38
  Number of pages to convert.
33
39
  If given, pdfmult does not try to obtain the page count from the source PDF.
34
40
  .TP
35
- \fB\-l\fR, \fB\-\-latex\fR
36
- Create a LaTeX file instead of a PDF file (default: file_2.tex).
37
- .TP
38
41
  \fB\-h\fR, \fB\-\-help\fR
39
42
  Prints a brief help message and exits.
40
43
  .TP
@@ -1,7 +1,8 @@
1
1
  require 'lib/pdfmult'
2
2
 
3
- version = Pdfmult::VERSION
4
- date = Pdfmult::DATE
3
+ version = Pdfmult::VERSION
4
+ date = Pdfmult::DATE
5
+ homepage = Pdfmult::HOMEPAGE
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = 'pdfmult'
@@ -16,7 +17,7 @@ Gem::Specification.new do |s|
16
17
 
17
18
  s.authors = ['Marcus Stollsteimer']
18
19
  s.email = 'sto.mar@web.de'
19
- s.homepage = 'https://github.com/stomar/pdfmult/'
20
+ s.homepage = homepage
20
21
 
21
22
  s.license = 'GPL-3'
22
23
 
@@ -29,12 +30,12 @@ Gem::Specification.new do |s|
29
30
 
30
31
  s.rdoc_options = ['--charset=UTF-8']
31
32
 
32
- s.files = %w[
33
+ s.files = %w{
33
34
  README.md
34
35
  Rakefile
35
36
  pdfmult.gemspec
36
37
  pdfmult.h2m
37
- ] +
38
+ } +
38
39
  Dir.glob('example*.*') +
39
40
  Dir.glob('{bin,lib,man,test}/**/*')
40
41
 
@@ -13,11 +13,12 @@ describe Pdfmult::Optionparser do
13
13
  it 'should return the correct default values' do
14
14
  options = Pdfmult::Optionparser.parse!(['sample.pdf'])
15
15
  expected = {
16
- :infile => 'sample.pdf',
16
+ :force => false,
17
+ :infile => 'sample.pdf',
18
+ :latex => false,
19
+ :number => 2,
17
20
  :outfile => 'sample_2.pdf',
18
- :number => 2,
19
- :pages => nil,
20
- :latex => false
21
+ :pages => nil
21
22
  }
22
23
  options.must_equal expected
23
24
  end
@@ -42,6 +43,11 @@ describe Pdfmult::Optionparser do
42
43
  options[:pages].must_equal 4
43
44
  end
44
45
 
46
+ it 'should recognize the -f option' do
47
+ options = Pdfmult::Optionparser.parse!(['sample.pdf', '-f'])
48
+ options[:force].must_equal true
49
+ end
50
+
45
51
  it 'should recognize the -l option and set the corresponding output filename' do
46
52
  options = Pdfmult::Optionparser.parse!(['sample.pdf', '-l'])
47
53
  options[:outfile].must_equal 'sample_2.tex'
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfmult
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Marcus Stollsteimer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-16 00:00:00 Z
18
+ date: 2012-04-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rake