pdfmd 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71b69c4e8462e3e8e9b8fe27df5fc9b6a472292b
4
- data.tar.gz: 55cb0726b99937d3cbaad55bb803d8c652315f4c
3
+ metadata.gz: 910525eeb9a1498f7b6345e987367eca6bc1a16e
4
+ data.tar.gz: 4fe25f14ef7c6366e2cd2188c68b5a5a7e56bba5
5
5
  SHA512:
6
- metadata.gz: 01a4b983e7eaaade73851e51d8193ad5e3c6911db00f87852b816c0848b2d0042c3acc651419e1d77226129582691d544fef85cce4395eb665fa51274eee7d64
7
- data.tar.gz: 87b8640a0b5c3a1286a5fcd214afdc01c2c1f72a07a996da93a50603caa13a20699e6d907dcd18c03344266d686e7dc934114b93289e2e200da006b8506d5e4a
6
+ metadata.gz: f2016aae25674bb4be3366ffda1954a1b799b0662f3f050eaf74c68e00a9f0195593b9113850dbfe1c8155fa9a7901a86d2899abea0e66f80284dca3c53e4a20
7
+ data.tar.gz: c5aa754e21ac36ad4166111099b721e972b3a4524e3fa33917c278d6bb268cbe40707bcc17f12070a7cb9c14fe4fe780610e742a5504410ba8de6152ffb1e296
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
+ # Version 1.6.0
2
+ - Added command 'config'
3
+ - Added dependency 'yaml'
4
+ - Added logging to command 'rename'
5
+ - Bugfix for comand 'rename' with settings in Hiera.
6
+ - Added Batchmode for command 'edit'
7
+ - Bugfix: value '00' not longer accepted for a month in 'createdate'
8
+ - Added logging to command 'edit'
9
+ - Bugfix: Removing the ampersand (&) from authornames as well now.
10
+
1
11
  # Version 1.5.0
2
12
  - Added option 'dryrun' to command 'sort'.
3
13
  - Added option 'logfilepath' to command 'sort'
@@ -0,0 +1,40 @@
1
+ #
2
+ # == File: config.rb
3
+ #
4
+ # Show the current default configuration settings
5
+ #
6
+
7
+ # Options
8
+ opt_show = ENV.fetch('PDFMD_SHOW')
9
+
10
+ require_relative '../string_extend.rb'
11
+ require 'yaml'
12
+ require 'pp'
13
+
14
+ # TODO: the output can be probably made more pretty without
15
+ # adding another requirement, can't it?
16
+
17
+ #
18
+ # If now options are set,
19
+ # show the current settings
20
+ if opt_show.blank? or opt_show == 'true'
21
+ opt_show = true
22
+ end
23
+
24
+ case opt_show
25
+ # Show the current settings
26
+ when true
27
+
28
+ # As long as only Hiera is supported as external storage
29
+ # for configuration (unless I need otherwise), read the
30
+ # hiera configuration
31
+ puts 'Current default configuration:'
32
+ puts ''
33
+ hieraConfig = eval `hiera pdfmd::config`
34
+ hieraConfig.sort.each do |key,value|
35
+ puts 'Command : ' + key
36
+ puts value.to_yaml
37
+ puts "---\n\n"
38
+ end
39
+
40
+ end
data/lib/pdfmd/edit.rb CHANGED
@@ -1,12 +1,67 @@
1
1
  #
2
2
  # Thor command 'edit' for changing the common
3
3
  # ExifTags within the PDF file
4
+ # TODO: Put rename into Hiera
5
+ # TODO: Back backup file/path into hiera and options
4
6
  #
5
- filename = ENV.fetch('PDFMD_FILENAME')
6
- optTag = ENV['PDFMD_TAG'] || nil
7
- optRename = ENV['PDFMD_RENAME'] == 'true' ? true : false
8
- pdfmd = ENV['PDFMD']
9
7
 
8
+ require_relative '../string_extend'
9
+
10
+ filename = ENV.fetch('PDFMD_FILENAME')
11
+ optTag = ENV['PDFMD_TAG'] || nil
12
+ optRename = ENV['PDFMD_RENAME'] == 'true' ? true : false
13
+ pdfmd = ENV['PDFMD']
14
+ opt_log = ENV['PDFMD_LOG']
15
+ opt_logfile = ENV['PDFMD_LOGFILE']
16
+ hieraDefaults = queryHiera('pdfmd::config')
17
+
18
+ # Define logging state
19
+ if ( hieraDefaults['edit'].nil? or
20
+ hieraDefaults['edit']['log'].nil? or
21
+ not hieraDefaults['edit']['log'] == true ) and
22
+ (opt_log == 'false' or opt_log.blank?)
23
+
24
+ logenable = false
25
+
26
+ else
27
+
28
+ logenable = true
29
+
30
+ end
31
+
32
+ # If logging is enabled, set parameters and create the obkject
33
+ if logenable
34
+
35
+ if opt_logfile.nil? and
36
+ ( hieraDefaults['edit'].nil? or
37
+ hieraDefaults['edit']['logfile'].nil? or
38
+ hieraDefaults['edit']['logfile'].blank? )
39
+
40
+ logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
41
+
42
+ elsif not opt_logfile.nil? and not opt_logfile.blank?
43
+
44
+ if File.directory? opt_logfile
45
+ abort('Logfile path is a directory. Abort.')
46
+ exit 1
47
+ end
48
+
49
+ logfile = opt_logfile
50
+
51
+ elsif (opt_logfile.nil? or opt_logfile.blank?) and
52
+ not hieraDefaults['edit']['logfile'].blank?
53
+
54
+ logfile = hieraDefaults['edit']['logfile']
55
+
56
+ else
57
+
58
+ logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
59
+
60
+ end
61
+
62
+ $logger = Logger.new(logfile)
63
+
64
+ end
10
65
 
11
66
  metadata = readMetadata(filename)
12
67
 
@@ -15,19 +70,42 @@ if optTag == 'all'
15
70
  else
16
71
  tags = optTag.split(',')
17
72
  end
73
+
18
74
  tags.each do |currentTag|
19
75
 
20
- # Change the tag to something we can use here
21
- puts "Current value: '#{metadata[currentTag.downcase]}'"
22
- answer = readUserInput("Enter new value for #{currentTag} :")
23
- if currentTag.downcase == 'createdate'
24
- while not answer = identifyDate(answer)
25
- puts 'Invalid date format'
26
- answer = readUserInput("Enter new value for #{currentTag} :")
76
+ # If the tags contain an '=', set the value for the tag
77
+ # automatically. Otherwise enter interactive mode.
78
+ if currentTag.match(/\=/)
79
+
80
+ tag, value = currentTag.split('=')
81
+
82
+ # Include Date identifier
83
+ if tag.downcase == 'createdate'
84
+ value = identifyDate(value)
27
85
  end
28
- end
29
- puts "Changing value for #{currentTag}: '#{metadata[currentTag]}' => #{answer}"
30
- `exiftool -#{currentTag.downcase}='#{answer}' -overwrite_original '#{filename}'`
86
+
87
+ logenable ? $logger.info("#{filename}: Setting value for tag '#{tag.downcase}': '#{value}'") : ''
88
+ `exiftool -#{tag.downcase}='#{value}' -overwrite_original '#{filename}'`
89
+
90
+ else
91
+
92
+ # Change the tag to something we can use here
93
+ puts "Current value: '#{metadata[currentTag.downcase]}'"
94
+ answer = readUserInput("Enter new value for #{currentTag} :")
95
+ answerCopy = answer
96
+ if currentTag.downcase == 'createdate'
97
+ while not answer = identifyDate(answer)
98
+ logenable ? $logger.warn("${filename}: Invalid date provided: '#{answerCopy}'.") : ''
99
+ logenable ? $logger.info("${filename}: Asking for new user provided date.") : ''
100
+ puts 'Invalid date format.'
101
+ answer = readUserInput("Enter new value for #{currentTag} :")
102
+ end
103
+ end
104
+ puts "Changing value for #{currentTag}: '#{metadata[currentTag]}' => #{answer}"
105
+ logenable ? $logger.info("#{filename}: Setting value for tag '#{currentTag.downcase}': '#{answer}'") : ''
106
+ `exiftool -#{currentTag.downcase}='#{answer}' -overwrite_original '#{filename}'`
107
+
108
+ end # If interactive/batch mode
31
109
  end
32
110
 
33
111
  #
@@ -35,6 +113,7 @@ end
35
113
  # This is not pretty, but seems to be the only way to do this in THOR
36
114
  #
37
115
  if optRename
116
+ logenable ? $logger.info("#{filename}: Trigger file renaming.") : ''
38
117
  `#{pdfmd} rename '#{filename}'`
39
118
  end
40
119
 
data/lib/pdfmd/methods.rb CHANGED
@@ -107,7 +107,7 @@ end
107
107
  def identifyDate(datestring)
108
108
  identifiedDate = ''
109
109
  year = '[1-2][90][0-9][0-9]'
110
- month = '0[0-9]|10|11|12'
110
+ month = '0[1-9]|10|11|12'
111
111
  day = '[1-9]|0[1-9]|1[0-9]|2[0-9]|3[0-1]'
112
112
  hour = '[0-1][0-9]|2[0-3]|[1-9]'
113
113
  minute = '[0-5][0-9]'
data/lib/pdfmd/rename.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  #
2
2
  # Thor command 'rename'
3
3
  #
4
- # TODO: Add option to create outputdir if not existing
5
- # TODO: Define option to create outputdir via Hiera
4
+ # TODO: align keyword abbreviations for all languages
6
5
  #
7
6
  require_relative '../string_extend'
8
7
 
@@ -12,8 +11,55 @@ outputdir = ENV.fetch('PDFMD_OUTPUTDIR') == 'false' ? false : ENV.fetc
12
11
  dryrun = ENV.fetch('PDFMD_DRYRUN') == 'false' ? false : true
13
12
  opt_numberKeywords = ENV.fetch('PDFMD_NUMBERKEYWORDS')
14
13
  opt_copy = ENV.fetch('PDFMD_COPY')
14
+ opt_log = ENV.fetch('PDFMD_LOG')
15
+ opt_logfile = ENV.fetch('PDFMD_LOGFILE')
15
16
  hieraDefaults = queryHiera('pdfmd::config')
16
17
 
18
+ if (opt_log.blank? and not hieraDefaults['rename'].nil? and not hieraDefaults['rename']['log'].nil? and hieraDefaults['rename']['log'] == true) or
19
+ opt_log == 'false' or
20
+ opt_log.blank?
21
+
22
+ logenable = false
23
+
24
+ else
25
+
26
+ logenable = true
27
+
28
+ end
29
+
30
+ if logenable
31
+
32
+ if opt_logfile.blank? and
33
+ ( hieraDefaults['rename']['logfilepath'].nil? or
34
+ hieraDefaults['rename']['logfilepath'].blank? or
35
+ hieraDefaults['rename'].nil? )
36
+
37
+ logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
38
+
39
+ elsif not opt_logfile.blank?
40
+
41
+ if File.directory? opt_logfile
42
+ abort('Logfilepath is a directory. Abort.')
43
+ exit 1
44
+ end
45
+
46
+ logfile = opt_logfile
47
+
48
+ elsif opt_logfile.blank? and
49
+ not hieraDefaults['rename']['logfilepath'].blank?
50
+
51
+ logfile = hieraDefaults['rename']['logfilepath']
52
+
53
+ else
54
+
55
+ logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
56
+
57
+ end
58
+
59
+ $logger = Logger.new(logfile)
60
+
61
+ end
62
+
17
63
  metadata = readMetadata(filename).each do |key,value|
18
64
 
19
65
  # Check if the metadata is complete
@@ -83,7 +129,7 @@ end
83
129
 
84
130
 
85
131
  date = metadata['createdate'].gsub(/\ \d{2}\:\d{2}\:\d{2}.*$/,'').gsub(/\:/,'')
86
- author = metadata['author'].gsub(/\./,'_').gsub(/\-/,'').gsub(/\s/,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
132
+ author = metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'').gsub(/\s/,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
87
133
  I18n.enforce_available_locales = false
88
134
  author = I18n.transliterate(author) # Normalising
89
135
 
@@ -93,9 +139,12 @@ case metadata['title']
93
139
  when /(Tilbudt|Angebot|Offer)/i
94
140
  doktype = 'til'
95
141
  keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
96
- when /Orderbekrefelse/i
142
+ when /Orderbekreftelse/i
97
143
  doktype = 'odb'
98
144
  keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
145
+ when /Auftragsbestätigung/i
146
+ doktype = 'abg'
147
+ keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
99
148
  when /faktura/i
100
149
  doktype = 'fak'
101
150
  keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
@@ -108,6 +157,9 @@ when /rechnung/i
108
157
  when /order/i
109
158
  doktype = 'ord'
110
159
  keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
160
+ when /bestilling/i
161
+ doktype = 'bes'
162
+ keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
111
163
  when /(kontrakt|avtale|vertrag|contract)/i
112
164
  doktype = 'avt'
113
165
  keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
@@ -211,10 +263,14 @@ end
211
263
 
212
264
  if not dryrun and filename != newFilename.downcase
213
265
 
266
+ logenable ? $logger.info(filename + ' => ' + outputdir + '/' + newFilename.downcase): ''
267
+
214
268
  # Copy of me the file to the new name
215
269
  command = opt_copy ? 'cp' : 'mv'
216
270
  `#{command} -v '#{filename}' '#{outputdir}/#{newFilename.downcase}'`
217
271
 
218
272
  else
219
- puts filename + "\n => " + outputdir + '/' + newFilename.downcase
273
+
274
+ logenable ? $logger.info('Dryrun: ' + filename + ' => ' + outputdir + '/' + newFilename.downcase): ''
275
+
220
276
  end
data/lib/pdfmd.rb CHANGED
@@ -1,6 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
- # == Version 1.3
3
- #
4
2
  # == File: pdfmd.rb
5
3
  #
6
4
  # Show and edit Metadata of PDF files and rename the files accordingly.
@@ -40,8 +38,7 @@
40
38
  #
41
39
  # TODO: Include password protected PDF documents as well
42
40
  # TODO: Fix broken PDF files automatically
43
- # TODO: Enable logging in more functions than only "sort"
44
- # TODO: command 'hiera' to show the current settings
41
+ # TODO: Enable logging in 'edit'
45
42
  # TODO: Read this: http://lostechies.com/derickbailey/2011/04/29/writing-a-thor-application/
46
43
  # TODO: ... and this: http://blog.paracode.com/2012/05/17/building-your-tools-with-thor/
47
44
  # gs \
@@ -62,7 +59,7 @@ require "i18n"
62
59
  require 'pathname'
63
60
  require 'logger'
64
61
 
65
- VERSION = '1.5.0'
62
+ VERSION = '1.6.0'
66
63
 
67
64
  # Include general usage methods
68
65
  require_relative('pdfmd/methods.rb')
@@ -79,6 +76,7 @@ class DOC < Thor
79
76
  desc 'show', 'Show metadata of a file'
80
77
  method_option :all, :type => :boolean, :aliases => '-a', :desc => 'Show all metatags', :default => false, :required => false
81
78
  method_option :tag, :type => :string, :aliases => '-t', :desc => 'Show specific tag(s), comma separated', :required => false
79
+ #method_option :format, :type => :string, :aliases => '-f', :desc => 'Define output format', :required => false
82
80
  long_desc <<-LONGDESC
83
81
  == General
84
82
 
@@ -128,6 +126,21 @@ class DOC < Thor
128
126
 
129
127
  end
130
128
 
129
+ #
130
+ # Show current settings
131
+ #
132
+ desc 'config', 'Show config defaults'
133
+ long_desc <<-LONGDESC
134
+
135
+ LONGDESC
136
+ method_option :show, :type => :boolean, :aliases => '-s', :required => false
137
+ def config
138
+
139
+ ENV['PDFMD_SHOW'] = options[:show].to_s
140
+ require_relative('./pdfmd/config.rb')
141
+
142
+ end
143
+
131
144
  #
132
145
  # Change a MetaTag Attribute
133
146
  #
@@ -141,7 +154,7 @@ class DOC < Thor
141
154
  specified or 'all'.
142
155
 
143
156
  The command will invoke an interactive user input and request the values
144
- for the metatag.
157
+ for the metatag if no value is provided.
145
158
 
146
159
  Additionally the file can be renamed at the end according to the new meta
147
160
  tags. See `$ #{__FILE__} help rename` for details.
@@ -151,6 +164,8 @@ class DOC < Thor
151
164
  --tag, -t
152
165
  \x5 Names or list of names of Metatag fields to set, separated by commata.
153
166
 
167
+ If a value is provided, the current Value will be replaced by the new value.
168
+
154
169
  --rename, -r
155
170
  \x5 Rename file after updating the meta tag information according to the fields.
156
171
 
@@ -164,9 +179,11 @@ class DOC < Thor
164
179
  # Edit tag 'Author' and set new value interactive.
165
180
  \x5>CLI edit -t author example.pdf
166
181
 
167
- # Edit mulitple Tags and set a new value.
182
+ # Edit multiple Tags and set a new value interactive.
168
183
  \x5>CLI edit -t tag1,tag2,tag3 <filename>
169
184
 
185
+ # Edit multiple Tags and set a new value in batch mode.
186
+ \x5 CLI edit -t tag1='value1',tag2='value2' <filename>
170
187
 
171
188
  == Multiple Tags
172
189
 
@@ -178,9 +195,14 @@ class DOC < Thor
178
195
  \x5>CLI edit -t author,title,subject example.pdf`
179
196
 
180
197
  # Set tags 'Author', 'Title', 'Subject', 'CreateDate', 'Keywords' in
181
- example.pdf interactive.
198
+ example.pdf interactive:
182
199
  \x5>CLI edit -t all example.pdf
183
200
 
201
+ # Set tags 'Author', 'CreateDate' in example.pdf in batch mode (non-interactive:
202
+
203
+ CLI edit -t author='Me',createdate='1970:00:00 01:01:01' example.pdf
204
+ CLI edit -t author='Me',Createdate=19700000 example.pdf
205
+
184
206
  == Tag: CreateDate
185
207
 
186
208
  In order to enter a value for the 'CreateDate' field, some internal matching is going on in order to make it easier and faster to enter dates and times.
@@ -217,12 +239,17 @@ class DOC < Thor
217
239
  LONGDESC
218
240
  method_option :tag, :type => :string, :aliases => '-t', :desc => 'Name of the Tag(s) to Edit', :default => false, :required => true
219
241
  method_option :rename, :type => :boolean, :aliases => '-r', :desc => 'Rename file after changing meta-tags', :default => false, :required => false
242
+ method_option :log, :aliases => '-l', :type => :boolean, :desc => 'Enable logging'
243
+ method_option :logfile, :aliases => '-p', :type => :string, :desc => 'Define path to logfile'
220
244
  def edit(filename)
221
245
 
222
246
  ENV['PDFMD_FILENAME'] = filename
223
247
  ENV['PDFMD_TAG'] = options[:tag]
224
248
  ENV['PDFMD_RENAME'] = options[:rename].to_s
225
249
  ENV['PDFMD'] = __FILE__
250
+ ENV['PDFMD_LOG'] = options[:log].to_s
251
+ ENV['PDFMD_LOGFILE'] = options[:logfile]
252
+
226
253
  require_relative('./pdfmd/edit.rb')
227
254
 
228
255
  end
@@ -322,6 +349,10 @@ class DOC < Thor
322
349
  [*logfilepath|p*]
323
350
  \x5 Set an alternate path for the logfile. If not path is chosen, the logfile is being created in the current working directory as `pdfmd.log`.
324
351
 
352
+ [*logfilepath|p*]
353
+ \x5 Set an alternate path for the logfile. If not path is chosen, the logfile
354
+ is being created in the current working directory as `pdfmd.log`.
355
+
325
356
  [*interactive|i*]
326
357
  \x5 Disable/Enable interactive sorting. This will ask for confirmation for each sorting action.
327
358
 
@@ -367,6 +398,10 @@ class DOC < Thor
367
398
  [*logfilepath*]
368
399
  \x5 Specifes the default path for the logfile. If no path is set and logging is enable, the logfile will be created in the current working directory.
369
400
 
401
+ [*logfilepath*]
402
+ \5x Specifes the default path for the logfile. If no path is set and logging is enable,
403
+ the logfile will be created in the current working directory.
404
+
370
405
  Default is the current working directory with the filename `pdfmd.log`
371
406
 
372
407
  [*interactive*]
@@ -447,6 +482,16 @@ class DOC < Thor
447
482
 
448
483
  The directory must exist at runtime.
449
484
 
485
+ --log, -l
486
+ \x5 Enable logging.
487
+
488
+ Values: true|false
489
+
490
+ --logfile, -p
491
+ \x5 Define logfile path
492
+
493
+ Default: current working-dir/pdfmd.log
494
+
450
495
  == Example
451
496
 
452
497
  # Rename the file according to the metatags
@@ -536,6 +581,8 @@ class DOC < Thor
536
581
  method_option :keywords, :type => :numeric, :aliases => '-k', :desc => 'Number of keywords to include (Default: 3)', :required => false
537
582
  method_option :outputdir, :aliases => '-o', :type => :string, :desc => 'Speficy output directory', :default => false, :required => :false
538
583
  method_option :copy, :aliases => '-c', :type => :boolean, :desc => 'Copy instead of moving the file when renaming'
584
+ method_option :log, :aliases => '-l', :type => :boolean, :desc => 'Enable logging'
585
+ method_option :logfile, :aliases => '-p', :type => :string, :desc => 'Define path to logfile'
539
586
  def rename(filename)
540
587
 
541
588
  ENV['PDFMD_FILENAME'] = filename
@@ -544,6 +591,9 @@ class DOC < Thor
544
591
  ENV['PDFMD_OUTPUTDIR'] = options[:outputdir].to_s
545
592
  ENV['PDFMD_NUMBERKEYWORDS'] = options[:keywords].to_s
546
593
  ENV['PDFMD_COPY'] = options[:copy].to_s
594
+ ENV['PDFMD_LOG'] = options[:log].to_s
595
+ ENV['PDFMD_LOGFILE'] = options[:logfile].to_s
596
+ ENV['PDFMD'] = __FILE__
547
597
  require_relative('./pdfmd/rename.rb')
548
598
 
549
599
  end
data/test/test_rename.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # Standard renaming
2
2
  # Test 001
3
3
  initTmpDir
4
- commandparameter = " rename -o #{TMPDIR}"
4
+ commandparameter = " rename -o #{TMPDIR} -c false "
5
5
  `#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
6
6
  files = readFilesInDir(TMPDIR)
7
7
  if files.size == 1 and
@@ -45,7 +45,7 @@ $testResults.store('003', {:result => result, :command => commandparameter })
45
45
  # Test 004
46
46
  # Testing all keywords (-a)
47
47
  initTmpDir
48
- commandparameter = " rename -a -o #{TMPDIR}"
48
+ commandparameter = " rename -a -o #{TMPDIR} -c false"
49
49
  `#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
50
50
  files = readFilesInDir(TMPDIR)
51
51
  if files.size == 1 and
@@ -60,7 +60,7 @@ $testResults.store('004', {:result => result, :command => commandparameter })
60
60
  # Testing number of keywords
61
61
  # this might be buggy
62
62
  initTmpDir
63
- commandparameter = " rename -k 1 -o #{TMPDIR}"
63
+ commandparameter = " rename -k 1 -o #{TMPDIR} -c false"
64
64
  `#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
65
65
  files = readFilesInDir(TMPDIR)
66
66
  if files.size == 1 and
@@ -70,3 +70,19 @@ else
70
70
  result = 'failed'
71
71
  end
72
72
  $testResults.store('005', {:result => result, :command => commandparameter })
73
+
74
+ # Test 006
75
+ # Testing logging enabled
76
+ initTmpDir
77
+ commandparameter = " rename -l -p #{TMPDIR}/pdfmd.log -c false"
78
+ `#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
79
+ files = readFilesInDir(TMPDIR)
80
+ if files.size == 1 and
81
+ File.basename(files.keys[0]) == '19700101-example_author-dok-some_keywords-kdn1111111-test_subject.pdf' and
82
+ `tail -n 1 #{TMPDIR}/pdfmd.log | wc -l`.to_i == 1
83
+ result = 'OK'
84
+ else
85
+ result = 'failed'
86
+ end
87
+ $testResults.store('006', {:result => result, :command => commandparameter })
88
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pdfmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Roos
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-31 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -108,6 +108,7 @@ files:
108
108
  - bin/pdfmd
109
109
  - lib/pdfmd.rb
110
110
  - lib/pdfmd/check.rb
111
+ - lib/pdfmd/config.rb
111
112
  - lib/pdfmd/edit.rb
112
113
  - lib/pdfmd/explain.author.md
113
114
  - lib/pdfmd/explain.createdate.md