pdfmd 1.8.0 → 1.9.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 +5 -13
- data/CHANGELOG.md +13 -0
- data/Rakefile +24 -0
- data/lib/pdfmd.rb +56 -23
- data/lib/pdfmd/config.rb +27 -5
- data/lib/pdfmd/edit.rb +8 -6
- data/lib/pdfmd/explain.hiera-keys.md +36 -0
- data/lib/pdfmd/explain.hiera.md +7 -4
- data/lib/pdfmd/explain.rb +1 -0
- data/lib/pdfmd/methods.rb +15 -4
- data/lib/pdfmd/rename.rb +102 -101
- data/lib/pdfmd/show.rb +4 -2
- data/lib/pdfmd/sort.rb +28 -7
- data/test/test_default.pdf +0 -0
- data/test/test_rename.rb +10 -5
- data/test/test_show.rb +13 -0
- data/test/test_sort.rb +1 -10
- metadata +27 -26
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MGEwMDkwYTFmZjAyNmRlNTMzZmY1OTNkMjU5ZjFlNzhiNzhkMGY2NQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df76f47dcfbeabf7402e1ae6b11198430bef7233
|
4
|
+
data.tar.gz: ba937131f2b83cb52cbc9c534012397dbc986634
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YjUwYTMwOTMzNjZhOTBkMjExYWJmNTVmOWYwNjczOTdiZWIzMTUzMDQ1NzI1
|
11
|
-
YzdmMzM3YTY5NWQ5ZGZmYTU3MjIxZThjNDAyMTdmZDkxNzM0MmE=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NGE5NzcyN2MzOGRlYWFkOTUzMzEyNDQ4YTllNzZmZDViOTNmZTBiZDIwZDRm
|
14
|
-
Nzg2MWRkNmE4ZTE0M2YxMTEzZTZkMTdjYTJhZGMyZGUyMDE4NDRkMWEzZmQ3
|
15
|
-
YWM4YzM5ZDg4ZjBlZDcxOWRmZTNmYjE5MzA1Y2RjYTdhNmY2M2M=
|
6
|
+
metadata.gz: aab4cd58aacee00a636527a34929ea501f46eabbdd122a2bcb88824c54f14818fecbc559ca5a3ed1390efaaf2d4ca887b3784eb864b37ee27be2df72e29efbdf
|
7
|
+
data.tar.gz: 922695d6b0a21d1c7ec539ef764fe0480f989c047c09712c31da57af9f982f44bf9d0a9378379e8e47242a9248cf4c11565550ae9f40f856df28d29619618b9b
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
# Version 1.9.0
|
2
|
+
- Added explain 'hiera-keys'
|
3
|
+
- Added parameter to command 'config'
|
4
|
+
- Added single file sort support for command 'sort'
|
5
|
+
- Bugfix: Fixed to run commands without Hiera.
|
6
|
+
- Bugfix: Logfile parameter was not correctly recognized when renaming.
|
7
|
+
- Bugfix: Renaming dry-run ran into an error in developement mode.
|
8
|
+
- Key-abbreviations are now configureable from Hiera.
|
9
|
+
- Keywords matching the document type will now be listed first in the document name if the subject is meaningful.
|
10
|
+
- Simplyfied the renaming command code.
|
11
|
+
- Updated Documentation
|
12
|
+
- Updated Tests
|
13
|
+
|
1
14
|
# Version 1.8.0
|
2
15
|
- Added Support for password protected pdf files in command 'show' and 'edit'
|
3
16
|
- Cleaned up renaming key-string and added all string for NO,EN an DE language.
|
data/Rakefile
CHANGED
@@ -42,6 +42,30 @@ def initTmpDir
|
|
42
42
|
FileUtils.cp(EXAMPLEPDF, TMPDIR + '/')
|
43
43
|
end
|
44
44
|
|
45
|
+
#
|
46
|
+
# Build a new version
|
47
|
+
#
|
48
|
+
desc 'Build new gem file, optionally install it'
|
49
|
+
task :build, :arg1 do |t, args|
|
50
|
+
|
51
|
+
args.with_defaults(:arg1 => '')
|
52
|
+
|
53
|
+
installoutput = `gem build pdfmd.gemspec`
|
54
|
+
|
55
|
+
if args[:arg1] == 'install'
|
56
|
+
|
57
|
+
installoutput.each_line do |line|
|
58
|
+
|
59
|
+
if line.match(/File\:\s/)
|
60
|
+
filename = line.split(': ')
|
61
|
+
puts `gem install #{filename[1]}`
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
45
69
|
#
|
46
70
|
# Testing command 'sort'
|
47
71
|
#
|
data/lib/pdfmd.rb
CHANGED
@@ -57,7 +57,7 @@ require "i18n"
|
|
57
57
|
require 'pathname'
|
58
58
|
require 'logger'
|
59
59
|
|
60
|
-
VERSION = '1.
|
60
|
+
VERSION = '1.9.0'
|
61
61
|
|
62
62
|
# Include general usage methods
|
63
63
|
require_relative('pdfmd/methods.rb')
|
@@ -166,11 +166,28 @@ class DOC < Thor
|
|
166
166
|
desc 'config', 'Show config defaults'
|
167
167
|
long_desc <<-LONGDESC
|
168
168
|
|
169
|
+
Shows the current default configuration as available in Hiera.
|
170
|
+
|
171
|
+
== Usage
|
172
|
+
|
173
|
+
Example: `pdfmd config [<command>]`
|
174
|
+
|
175
|
+
|
176
|
+
== Parameter
|
177
|
+
|
178
|
+
[<commandname>]
|
179
|
+
|
180
|
+
Shows only the default configuration from hiera for the specified command.
|
181
|
+
The command parameter is not case-sensitive.
|
182
|
+
|
183
|
+
Example: `pdfmd config edit`
|
184
|
+
|
169
185
|
LONGDESC
|
170
186
|
method_option :show, :type => :boolean, :aliases => '-s', :required => false
|
171
|
-
def config
|
187
|
+
def config(subcommand = '')
|
172
188
|
|
173
|
-
ENV['PDFMD_SHOW']
|
189
|
+
ENV['PDFMD_SHOW'] = options[:show].to_s
|
190
|
+
ENV['PDFMD_COMMAND'] = subcommand
|
174
191
|
require_relative('./pdfmd/config.rb')
|
175
192
|
|
176
193
|
end
|
@@ -362,7 +379,7 @@ class DOC < Thor
|
|
362
379
|
|
363
380
|
When using this action a logfile with all actions will be generated in the
|
364
381
|
current working directory with the same name as the script and the ending
|
365
|
-
'.log'. This can be disabled with the parameter 'log' if required.
|
382
|
+
'.log'. This can be disabled with the parameter 'log' if required or adjusted to write the logfile to a different location.
|
366
383
|
|
367
384
|
If a document does not have an entry in the meta tag 'author', the file will
|
368
385
|
not be processed. This can be seen in the output of the logfile as well.
|
@@ -393,8 +410,6 @@ class DOC < Thor
|
|
393
410
|
|
394
411
|
Default: disabled.
|
395
412
|
|
396
|
-
|
397
|
-
|
398
413
|
=== Replacement rules
|
399
414
|
|
400
415
|
The subdirectories for the documents are generated from the values in the
|
@@ -447,6 +462,9 @@ class DOC < Thor
|
|
447
462
|
\x5 4. Disable the logging.
|
448
463
|
\x5> CLI sort -d /tmp/test -c -l false ./documents
|
449
464
|
|
465
|
+
# Sort only a single file
|
466
|
+
\x5> CLI sort -d /tmp/test -c -l false ./documents/test.pdf
|
467
|
+
|
450
468
|
LONGDESC
|
451
469
|
method_option :destination, :aliases => '-d', :required => false, :type => :string, :desc => 'Defines the output directory'
|
452
470
|
method_option :copy, :aliases => '-c', :required => false, :type => :boolean, :desc => 'Copy files instead of moving them'
|
@@ -534,6 +552,15 @@ class DOC < Thor
|
|
534
552
|
# Simulate renaming example.pdf according to the metatags (dry-run)
|
535
553
|
\x5> CLI rename -n example.pdf
|
536
554
|
|
555
|
+
== Hiera
|
556
|
+
|
557
|
+
There are Hiera settings available, that cannot be addressed by a commandline parameter.
|
558
|
+
|
559
|
+
defaultdoctype: Defines the appreviation for the default document type. This one isused when no other document type could be determined from the metadata-field 'title'. Default value is 'doc'.
|
560
|
+
|
561
|
+
For details on how to set the parameter, see 'pdfmd explain hiera'.
|
562
|
+
|
563
|
+
|
537
564
|
== Rules
|
538
565
|
|
539
566
|
There are some rules regarding how documents are being renamed
|
@@ -542,34 +569,40 @@ class DOC < Thor
|
|
542
569
|
|
543
570
|
<yyyymmdd>-<author>-<type>-<additionalInformation>.<extension>
|
544
571
|
|
545
|
-
\x5 # <yyyymmdd>: Year, month and day
|
546
|
-
document.
|
572
|
+
\x5 # <yyyymmdd>: Year, month and day identical to the meta information in the document.
|
547
573
|
\x5 # <author>: Author of the document, identical to the meta information
|
548
574
|
in the document. Special characters and whitespaces are replaced.
|
549
575
|
\x5 # <type>: Document type, is being generated from the title field in the metadata of the document. Document type is a three character abbreviation following the following logic:
|
550
576
|
|
551
|
-
\x5
|
552
|
-
\x5
|
553
|
-
\x5
|
554
|
-
\x5 ord => Order
|
555
|
-
\x5 avt => Kontrakt|Avtale|Vertrag|contract
|
556
|
-
\x5 kvi => Kvittering
|
577
|
+
\x5 con => Contract
|
578
|
+
\x5 inv => Invoice
|
579
|
+
\x5 inf => Information
|
557
580
|
\x5 man => Manual
|
558
|
-
\x5
|
559
|
-
\x5
|
560
|
-
\x5
|
581
|
+
\x5 off => Offer
|
582
|
+
\x5 ord => Order
|
583
|
+
\x5 rpt => Receipt
|
584
|
+
\x5 tic => Ticket
|
561
585
|
|
562
586
|
If the dokument type can not be determined automatically, it defaults to 'dok'.
|
563
587
|
|
588
|
+
This default behavior got introduced with version 1.8.1 and can be overwritten by hiera.
|
589
|
+
See `pdfmd explain hiera-keys` for information on how to do this.
|
590
|
+
|
564
591
|
# <additionalInformation>: Information generated from the metadata fields
|
565
592
|
'title', 'subject' and 'keywords'.
|
566
593
|
|
567
|
-
If 'Title' or 'Keywords' contains one of the following keywords,
|
594
|
+
If 'Title' or 'Keywords' contains one of the following keywords, they will be replaced with the corresponding abbreviation followed by the specified value:
|
595
|
+
|
596
|
+
\x5 Contract => con
|
597
|
+
\x5 Invoice => inv
|
598
|
+
\x5 Information => inf
|
599
|
+
\x5 Manual => man
|
600
|
+
\x5 Offer => off
|
601
|
+
\x5 Order => ord
|
602
|
+
\x5 Receipt => rpt
|
603
|
+
\x5 Ticket => tic
|
568
604
|
|
569
|
-
|
570
|
-
\x5 kdn => Kunde|Kundenummer|Kunde|Kundennummer
|
571
|
-
\x5 ord => Ordre|Ordrenummer|Bestellung|Bestellungsnummer
|
572
|
-
\x5 kvi => Kvittering|Kvitteringsnummer|Quittung|Quittungsnummer
|
605
|
+
This setting will be overwritten as well by defining the 'keys' hash in Hiera.
|
573
606
|
|
574
607
|
Rule 2: The number of keywords used in the filename is defined by the parameter '-k'. See the section of that parameter for more details and the default value.
|
575
608
|
|
@@ -625,7 +658,7 @@ class DOC < Thor
|
|
625
658
|
ENV['PDFMD_LOG'] = options[:log].to_s
|
626
659
|
ENV['PDFMD_LOGFILE'] = options[:logfile].to_s
|
627
660
|
ENV['PDFMD'] = __FILE__
|
628
|
-
require_relative('
|
661
|
+
require_relative('pdfmd/rename.rb')
|
629
662
|
|
630
663
|
end
|
631
664
|
|
data/lib/pdfmd/config.rb
CHANGED
@@ -5,7 +5,8 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
# Options
|
8
|
-
opt_show
|
8
|
+
opt_show = ENV.fetch('PDFMD_SHOW')
|
9
|
+
opt_command = ENV.fetch('PDFMD_COMMAND').downcase
|
9
10
|
|
10
11
|
require_relative '../string_extend.rb'
|
11
12
|
require 'yaml'
|
@@ -23,15 +24,36 @@ case opt_show
|
|
23
24
|
when true
|
24
25
|
|
25
26
|
# As long as only Hiera is supported as external storage
|
26
|
-
# for configuration (unless I need otherwise), read the
|
27
|
+
# for configuration (unless I need it otherwise), read the
|
27
28
|
# hiera configuration
|
28
29
|
puts 'Current default configuration:'
|
29
30
|
puts ''
|
30
31
|
hieraConfig = eval `hiera pdfmd::config`
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
|
33
|
+
# Show the configuration only for one key
|
34
|
+
if not opt_command.empty? and
|
35
|
+
|
36
|
+
hieraConfig.has_key?(opt_command)
|
37
|
+
|
38
|
+
puts 'Command: ' + opt_command
|
39
|
+
puts hieraConfig[opt_command].to_yaml
|
34
40
|
puts ''
|
41
|
+
|
42
|
+
# Strange key provided. Typo? Anyway: error
|
43
|
+
elsif not opt_command.empty? and
|
44
|
+
not hieraConfig.has_key?(opt_command)
|
45
|
+
|
46
|
+
puts "Command '#{opt_command}' not found in default configuration."
|
47
|
+
|
48
|
+
# Show all configuration from Hiera
|
49
|
+
else
|
50
|
+
|
51
|
+
hieraConfig.sort.each do |key,value|
|
52
|
+
puts 'Command: ' + key
|
53
|
+
puts value.to_yaml
|
54
|
+
puts ''
|
55
|
+
end
|
56
|
+
|
35
57
|
end
|
36
58
|
|
37
59
|
end
|
data/lib/pdfmd/edit.rb
CHANGED
@@ -19,18 +19,20 @@ if opt_rename == 'true'
|
|
19
19
|
opt_rename = true
|
20
20
|
elsif opt_rename == 'false'
|
21
21
|
opt_rename = false
|
22
|
-
elsif (
|
23
|
-
|
24
|
-
|
22
|
+
elsif (!hieraDefaults.nil? and
|
23
|
+
!hieraDefaults['edit'].nil? and
|
24
|
+
! hieraDefaults['edit']['rename'].nil? and
|
25
|
+
hieraDefaults['edit']['rename'] == true)
|
25
26
|
opt_rename = true
|
26
27
|
else
|
27
28
|
opt_rename = false
|
28
29
|
end
|
29
30
|
|
30
31
|
# Define logging state
|
31
|
-
if (
|
32
|
-
|
33
|
-
|
32
|
+
if (hieraDefaults.nil? or
|
33
|
+
hieraDefaults['edit'].nil? or
|
34
|
+
hieraDefaults['edit']['log'].nil? or
|
35
|
+
!hieraDefaults['edit']['log'] == true ) and
|
34
36
|
(opt_log == 'false' or opt_log.blank?)
|
35
37
|
|
36
38
|
logenable = false
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Keys in Hiera can be defined in order to overwrite the default renaming behaviour.
|
2
|
+
|
3
|
+
The default support is since version 1.8.1 only for the english language and will replace words in the meta-tag field 'keywords' with abbreviations.
|
4
|
+
|
5
|
+
The following default abbreviations will be used:
|
6
|
+
|
7
|
+
* 'off': 'Offer', 'Offernumber'
|
8
|
+
* 'inv': 'Invoice', 'Invoicenumber'
|
9
|
+
* 'con': 'Contract'
|
10
|
+
* 'ord': 'Order', 'Ordernumber'
|
11
|
+
* 'rec': 'Receipt', 'Receiptnumber'
|
12
|
+
* 'man': 'Manual'
|
13
|
+
|
14
|
+
# Example
|
15
|
+
|
16
|
+
Using the string 'Offernumber 1111' will result in the string 'off1111' in the filename, unless the number of keywords is higher than the maximum number of keywords to use.
|
17
|
+
The matching is case-insensitive. 'offernumber 1111' and 'Offernumber 1111' will result in the same replacement.
|
18
|
+
|
19
|
+
In order to overwrite the default you need to configure hiera and define a hash 'keys' with the abbreviation as sub-key and the string to replace as value. The value can either be defined as string or as array.
|
20
|
+
|
21
|
+
The following example mirrors the default replacement in the Hiera configuration:
|
22
|
+
|
23
|
+
``` YAML
|
24
|
+
pdfmd::config:
|
25
|
+
rename:
|
26
|
+
keys:
|
27
|
+
'off': ['Offer', 'Offernumber']
|
28
|
+
inv : ['Invoice', 'Invoicenumber']
|
29
|
+
con : Contract
|
30
|
+
ord : ['Order', 'Ordernumber']
|
31
|
+
rec : ['Receipt', 'Receiptnumber']
|
32
|
+
man : Manual
|
33
|
+
```
|
34
|
+
|
35
|
+
Warning: Keys like 'off' need to be set in apostrophe, otherwise the key will be interpreted as 'false' instead.
|
36
|
+
|
data/lib/pdfmd/explain.hiera.md
CHANGED
@@ -6,7 +6,8 @@ Installation:
|
|
6
6
|
$ gem install hiera
|
7
7
|
```
|
8
8
|
|
9
|
-
Configure default settings in hiera:
|
9
|
+
Configure default settings for pdfmd in hiera:
|
10
|
+
|
10
11
|
|
11
12
|
YAML
|
12
13
|
---
|
@@ -14,16 +15,18 @@ Configure default settings in hiera:
|
|
14
15
|
default:
|
15
16
|
password : secretpassword
|
16
17
|
sort:
|
17
|
-
destination : /data/output
|
18
18
|
copy : true
|
19
|
+
destination : /data/output
|
20
|
+
interactive : true
|
19
21
|
log : true
|
20
22
|
logfile : /var/log/pdfmd.log
|
21
|
-
interactive : true
|
22
23
|
rename:
|
23
24
|
allkeywords : true
|
25
|
+
copy : true
|
26
|
+
defaultdoctype: doc
|
24
27
|
keywords : 4
|
25
28
|
outputdir : /data/output/sorted
|
26
|
-
copy : true
|
27
29
|
edit:
|
28
30
|
rename : true
|
29
31
|
|
32
|
+
|
data/lib/pdfmd/explain.rb
CHANGED
data/lib/pdfmd/methods.rb
CHANGED
@@ -15,11 +15,21 @@ def queryHiera(keyword,facts = 'UNSET')
|
|
15
15
|
|
16
16
|
# If hiera isn't found, return false
|
17
17
|
# otherwise return the hash
|
18
|
-
if !system('which hiera > /dev/null 2>&1')
|
18
|
+
if !system('which hiera > /dev/null 2>&1')
|
19
19
|
puts 'Cannot find "hiera" command in $path.'
|
20
|
-
return
|
20
|
+
return eval('{}')
|
21
|
+
# elsif system('which hiera > /dev/null 2>&1') and
|
22
|
+
# !File.exists?('/etc/hiera.yaml')
|
23
|
+
# puts 'here too'
|
24
|
+
# return eval('{}')
|
21
25
|
else
|
22
|
-
|
26
|
+
commandreturn = ''
|
27
|
+
commandreturn = `hiera #{keyword} #{facts} 2>/dev/null`
|
28
|
+
if $?.exitstatus == 1
|
29
|
+
return eval('{}')
|
30
|
+
else
|
31
|
+
return eval(commandreturn)
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
end
|
@@ -34,7 +44,8 @@ end
|
|
34
44
|
# replaced with underscores
|
35
45
|
#
|
36
46
|
def setKeywordsPreface(metadata, doktype)
|
37
|
-
if metadata['subject'].match(/^\d+[^+s]+.*/)
|
47
|
+
if metadata['subject'].match(/^\d+[^+s]+.*/) and
|
48
|
+
doktype != 'dok'
|
38
49
|
return doktype + metadata['subject']
|
39
50
|
else
|
40
51
|
subject = metadata['subject']
|
data/lib/pdfmd/rename.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Thor command 'rename'
|
3
3
|
#
|
4
|
-
# TODO: Make keywords abbreviations configurable from Hiera
|
5
|
-
#
|
6
4
|
require_relative '../string_extend'
|
7
5
|
|
8
6
|
filename = ENV.fetch('PDFMD_FILENAME')
|
@@ -15,24 +13,28 @@ opt_log = ENV.fetch('PDFMD_LOG')
|
|
15
13
|
opt_logfile = ENV.fetch('PDFMD_LOGFILE')
|
16
14
|
hieraDefaults = queryHiera('pdfmd::config')
|
17
15
|
|
18
|
-
if
|
19
|
-
opt_log == 'false' or
|
20
|
-
opt_log.blank?
|
21
|
-
|
16
|
+
if opt_log == 'false'
|
22
17
|
logenable = false
|
23
|
-
|
18
|
+
elsif opt_log == 'true'
|
19
|
+
logenable = true
|
20
|
+
elsif opt_log.blank? and
|
21
|
+
!hieraDefaults.nil? and
|
22
|
+
!hieraDefaults['rename'].nil? and
|
23
|
+
!hieraDefaults['rename']['log'].nil? and
|
24
|
+
hieraDefaults['rename']['log'] == true
|
25
|
+
logenable = true
|
24
26
|
else
|
25
|
-
|
26
27
|
logenable = true
|
27
|
-
|
28
28
|
end
|
29
29
|
|
30
30
|
if logenable
|
31
31
|
|
32
32
|
if opt_logfile.blank? and
|
33
|
-
(
|
34
|
-
hieraDefaults
|
35
|
-
hieraDefaults['rename'].nil?
|
33
|
+
(
|
34
|
+
!hieraDefaults.nil? and
|
35
|
+
hieraDefaults['rename'].nil? and
|
36
|
+
(hieraDefaults['rename']['logfile'].nil? or
|
37
|
+
hieraDefaults['rename']['logfile'].blank?))
|
36
38
|
|
37
39
|
logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
|
38
40
|
|
@@ -46,9 +48,12 @@ if logenable
|
|
46
48
|
logfile = opt_logfile
|
47
49
|
|
48
50
|
elsif opt_logfile.blank? and
|
49
|
-
|
51
|
+
!hieraDefaults.nil? and
|
52
|
+
!hieraDefaults['rename'].nil? and
|
53
|
+
!hieraDefaults['rename']['logfile'].nil? and
|
54
|
+
not hieraDefaults['rename']['logfile'].blank?
|
50
55
|
|
51
|
-
logfile = hieraDefaults['rename']['
|
56
|
+
logfile = hieraDefaults['rename']['logfile']
|
52
57
|
|
53
58
|
else
|
54
59
|
|
@@ -77,7 +82,8 @@ end
|
|
77
82
|
if opt_allkeywords == 'true'
|
78
83
|
opt_allkeywords = true
|
79
84
|
elsif opt_allkeywords.blank? and
|
80
|
-
|
85
|
+
!hieraDefaults.nil? and
|
86
|
+
!hieraDefaults['rename'].nil? and
|
81
87
|
not hieraDefaults['rename']['allkeywords'].nil?
|
82
88
|
|
83
89
|
opt_allkeywords = hieraDefaults['rename']['allkeywords']
|
@@ -93,8 +99,9 @@ end
|
|
93
99
|
# Determine the number of keywords
|
94
100
|
# Default value is 3
|
95
101
|
if opt_numberKeywords.blank? and
|
96
|
-
|
97
|
-
|
102
|
+
!hieraDefaults.nil? and
|
103
|
+
!hieraDefaults['rename'].nil? and
|
104
|
+
!hieraDefaults['rename']['keywords'].nil?
|
98
105
|
|
99
106
|
opt_numberKeywords = hieraDefaults['rename']['keywords']
|
100
107
|
|
@@ -112,8 +119,9 @@ end
|
|
112
119
|
#
|
113
120
|
# Determine the status of the copy parameter
|
114
121
|
if opt_copy.blank? and
|
115
|
-
|
116
|
-
|
122
|
+
!hieraDefaults.nil? and
|
123
|
+
!hieraDefaults['rename'].nil? and
|
124
|
+
!hieraDefaults['rename']['copy'].nil?
|
117
125
|
|
118
126
|
opt_copy = hieraDefaults['rename']['copy']
|
119
127
|
|
@@ -127,6 +135,29 @@ else
|
|
127
135
|
|
128
136
|
end
|
129
137
|
|
138
|
+
# Use a default set for the keywords or (if provided) the keywords from hiera
|
139
|
+
# The default set is only in english
|
140
|
+
if !hieraDefaults.nil? and
|
141
|
+
!hieraDefaults['rename'].nil? and
|
142
|
+
!hieraDefaults['rename']['keys'].nil? and
|
143
|
+
hieraDefaults['rename']['keys'] != ''
|
144
|
+
|
145
|
+
keymappings = hieraDefaults['rename']['keys']
|
146
|
+
|
147
|
+
else
|
148
|
+
keymappings = {
|
149
|
+
'cno' => ['Customer','Customernumber'],
|
150
|
+
'con' => ['Contract'],
|
151
|
+
'inf' => ['Information'],
|
152
|
+
'inv' => ['Invoice', 'Invoicenumber'],
|
153
|
+
'man' => ['Manual'],
|
154
|
+
'off' => ['Offer', 'Offernumber'],
|
155
|
+
'ord' => ['Order', 'Ordernumber'],
|
156
|
+
'rec' => ['Receipt', 'Receiptnumber'],
|
157
|
+
'tic' => ['Ticket'],
|
158
|
+
}
|
159
|
+
end
|
160
|
+
|
130
161
|
|
131
162
|
date = metadata['createdate'].gsub(/\ \d{2}\:\d{2}\:\d{2}.*$/,'').gsub(/\:/,'')
|
132
163
|
author = metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'').gsub(/\s/,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
|
@@ -135,129 +166,99 @@ author = I18n.transliterate(author) # Normalising
|
|
135
166
|
|
136
167
|
keywords_preface = ''
|
137
168
|
# Determine the document type from the title.
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
doktype = '
|
146
|
-
when /Orderbekreftelse/i
|
147
|
-
doktype = 'odb'
|
148
|
-
when /faktura/i
|
149
|
-
doktype = 'fak'
|
150
|
-
when /invoice/i
|
151
|
-
doktype = 'inv'
|
152
|
-
when /rechnung/i
|
153
|
-
doktype = 'rec'
|
154
|
-
when /order/i
|
155
|
-
doktype = 'ord'
|
156
|
-
when /bestilling/i
|
157
|
-
doktype = 'bes'
|
158
|
-
when /(kontrakt|avtale)/i
|
159
|
-
doktype = 'avt'
|
160
|
-
when /vertrag/i
|
161
|
-
doktype = 'ver'
|
162
|
-
when /contract/i
|
163
|
-
doktype = 'con'
|
164
|
-
when /kvittering/i
|
165
|
-
doktype = 'kvi'
|
166
|
-
when /manual/i
|
167
|
-
doktype = 'man'
|
168
|
-
when /billett/i
|
169
|
-
doktype = 'bil'
|
170
|
-
when /ticket/i
|
171
|
-
doktype = 'tik'
|
172
|
-
when /(informasjon|information)/i
|
173
|
-
doktype = 'inf'
|
169
|
+
|
170
|
+
# Default docment type
|
171
|
+
if !hieraDefaults.nil? and
|
172
|
+
!hieraDefaults['rename'].nil? and
|
173
|
+
!hieraDefaults['rename']['defaultdoctype'].nil? and
|
174
|
+
hieraDefaults['rename']['defaultdoctype'].empty?
|
175
|
+
|
176
|
+
doktype = hieraDefaults['rename']['defaultdoctype']
|
174
177
|
else
|
175
|
-
doktype = '
|
178
|
+
doktype = 'doc'
|
179
|
+
end
|
180
|
+
|
181
|
+
|
182
|
+
## Iterate through the keymappings and try to find a matching doktype
|
183
|
+
keymappings.each do |key,value|
|
184
|
+
value.kind_of?(String) ? value = value.split : ''
|
185
|
+
value.each do |keyword|
|
186
|
+
metadata['title'].match(/#{keyword}/i) ? doktype = key : ''
|
187
|
+
end
|
176
188
|
end
|
189
|
+
|
177
190
|
# Set the preface from the doktype
|
191
|
+
# This must be added to the beginning of the hash when generating
|
192
|
+
# the filename so it will come first after the doktype
|
178
193
|
keywords_preface = setKeywordsPreface(metadata,doktype.gsub(/\-/,''))
|
179
194
|
|
180
195
|
if not metadata['keywords'].empty?
|
181
|
-
|
196
|
+
keywords = ''
|
197
|
+
#keywords_preface == '' ? keywords = '' : keywords = keywords_preface
|
182
198
|
keywordsarray = metadata['keywords'].split(',')
|
183
199
|
|
184
200
|
#
|
185
201
|
# Sort array
|
186
202
|
# and replace key-strings with the abbreviations
|
187
|
-
# in combination with the titel information
|
188
|
-
#
|
189
|
-
#
|
190
|
-
#
|
203
|
+
# in combination with the titel information for the filename
|
204
|
+
# BTW: When the value is identical with the title, then it should be
|
205
|
+
# the first keyword IMHO. TODO
|
191
206
|
keywordssorted = Array.new
|
192
207
|
keywordsarray.each_with_index do |value,index|
|
193
208
|
value = value.lstrip.chomp
|
194
|
-
|
195
|
-
# Invoices
|
196
|
-
value = value.gsub(/Faktura(nummer)? /i,'fak')
|
197
|
-
value = value.gsub(/Rechnung(snummer)? /i, 'rec')
|
198
|
-
value = value.gsub(/Invoice(number)? /i, 'inv')
|
199
|
-
|
200
|
-
# Customernumbers
|
201
|
-
value = value.gsub(/Kunde(n)?(nummer)? /i,'kdn')
|
202
|
-
value = value.gsub(/Customer(number)? /i, 'cno')
|
203
|
-
|
204
|
-
# Ordernumbers
|
205
|
-
value = value.gsub(/Bestellung(s?nummer)? /i,'bes')
|
206
|
-
value = value.gsub(/(Ordre)(nummer)? /i,'ord')
|
207
|
-
value = value.gsub(/Bestilling(snummer)? /i,'bst')
|
208
|
-
|
209
|
-
# Receiptnumbers
|
210
|
-
value = value.gsub(/(Kvittering)(snummer)? /i,'kvi')
|
211
|
-
value = value.gsub(/Quittung(snummer)? /i,'qui')
|
212
|
-
value = value.gsub(/Receipt(number)? /i, 'rpt')
|
213
209
|
|
210
|
+
# Replace strings for the filename with abbreviations
|
211
|
+
keymappings.each do |abbreviation,keyvaluesarray|
|
212
|
+
keyvaluesarray.kind_of?(String) ? keyvaluesarray = keyvaluesarray.split : ''
|
213
|
+
keyvaluesarray.each do |keystring|
|
214
|
+
value = value.gsub(/#{keystring.lstrip.chomp} /i, abbreviation.to_s)
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
214
218
|
# Remove special characters from string
|
215
219
|
value = value.gsub(/\s|\/|\-|\./,'_')
|
216
220
|
|
217
221
|
keywordsarray[index] = value
|
218
|
-
|
222
|
+
|
223
|
+
# If the current values matches some of the replacement-abbreviations,
|
224
|
+
# put the keyword on the top of the array to be listed first later on
|
225
|
+
# in the filename
|
226
|
+
if value.match(/^#{keymappings.keys.join('|')} /i)
|
219
227
|
keywordssorted.insert(0, value)
|
220
228
|
else
|
221
229
|
keywordssorted.push(value)
|
222
230
|
end
|
231
|
+
|
223
232
|
end
|
224
233
|
|
225
|
-
|
226
|
-
|
234
|
+
# Insert the document preface in the beginning when it's available
|
235
|
+
if not keywords_preface.empty?
|
236
|
+
keywordssorted.insert(0, keywords_preface)
|
237
|
+
end
|
227
238
|
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
if value.match(/^(fak|rec|inv|cno|kdn|bes|ord|bst|kvi|qui|rpt)/)
|
234
|
-
keywords == '' ? keywords = '-' + value : keywords = value + '-' + keywords
|
235
|
-
else
|
236
|
-
keywords == '' ? keywords = '-' + value : keywords.concat('-' + value)
|
237
|
-
end
|
239
|
+
# all keywords as a string
|
240
|
+
if not opt_allkeywords
|
241
|
+
keywords = keywordssorted.values_at(*(0..opt_numberKeywords-1)).join('-')
|
242
|
+
else
|
243
|
+
keywords = keywordssorted.join('-')
|
238
244
|
end
|
239
245
|
|
240
246
|
# Normalise the keywords as well
|
241
|
-
#
|
242
247
|
I18n.enforce_available_locales = false
|
243
248
|
keywords = I18n.transliterate(keywords)
|
244
249
|
|
245
|
-
# There are no keywords
|
246
|
-
# Rare, but it happens
|
247
250
|
else
|
248
251
|
|
249
252
|
# There are no keywords.
|
250
253
|
# we are using the title and the subject
|
251
|
-
|
252
|
-
keywords = keywords_preface
|
253
|
-
end
|
254
|
+
keywords_preface != '' ? keywords = keywords_preface : ''
|
254
255
|
|
255
256
|
end
|
257
|
+
|
256
258
|
extension = 'pdf'
|
257
259
|
if keywords != nil and keywords[0] != '-'
|
258
260
|
keywords = '-' + keywords
|
259
261
|
end
|
260
|
-
keywords == nil ? keywords = '' : ''
|
261
262
|
newFilename = date + '-' +
|
262
263
|
author + '-' +
|
263
264
|
doktype +
|
@@ -275,7 +276,7 @@ if outputdir
|
|
275
276
|
else
|
276
277
|
|
277
278
|
# Try to get the outputdir from hiera
|
278
|
-
outputdir = (
|
279
|
+
outputdir = (!hieraDefaults.nil? and !hieraDefaults['rename'].nil? and !hieraDefaults['rename']['outputdir'].nil?) ? hieraDefaults['rename']['outputdir'] : File.dirname(filename)
|
279
280
|
|
280
281
|
end
|
281
282
|
|
data/lib/pdfmd/show.rb
CHANGED
@@ -29,6 +29,7 @@ end
|
|
29
29
|
|
30
30
|
# Determine format from Hiera if possible
|
31
31
|
if opt_format.nil? and
|
32
|
+
!hieraDefaults.nil? and
|
32
33
|
not hieraDefaults['show'].nil? and
|
33
34
|
not hieraDefaults['show']['format'].nil? and
|
34
35
|
hieraDefaults['show']['format'] != ''
|
@@ -40,8 +41,9 @@ end
|
|
40
41
|
|
41
42
|
# Determine tags from Hiera if possible
|
42
43
|
if optTag.nil? and
|
43
|
-
|
44
|
-
|
44
|
+
!hieraDefaults.nil? and
|
45
|
+
!hieraDefaults['show'].nil? and
|
46
|
+
!hieraDefaults['show']['tag'].nil? and
|
45
47
|
hieraDefaults['show']['tag'] != ''
|
46
48
|
|
47
49
|
optTag = hieraDefaults['show']['tag']
|
data/lib/pdfmd/sort.rb
CHANGED
@@ -3,6 +3,8 @@
|
|
3
3
|
#
|
4
4
|
# Actions for the sort command
|
5
5
|
#
|
6
|
+
# TODO: Put in file overwrite parameter
|
7
|
+
#
|
6
8
|
inputDir = ENV.fetch('PDFMD_INPUTDIR')
|
7
9
|
|
8
10
|
require_relative('./methods.rb')
|
@@ -20,14 +22,22 @@ hieraDefaults = queryHiera('pdfmd::config')
|
|
20
22
|
# Determin the setting for the copy/move action when sorting
|
21
23
|
# Use HieraDefaults if nothing has been set.
|
22
24
|
copyAction = opt_copy
|
23
|
-
if copyAction.blank? and
|
25
|
+
if copyAction.blank? and
|
26
|
+
!hieraDefaults.nil? and
|
27
|
+
!hieraDefaults['sort'].nil? and
|
28
|
+
!hieraDefaults['sort']['copy'].nil? and
|
29
|
+
hieraDefaults['sort']['copy'] == true
|
24
30
|
copyAction = true
|
25
31
|
elsif copyAction.blank? or copyAction == 'false'
|
26
32
|
copyAction = false
|
27
33
|
end
|
28
34
|
|
29
35
|
# Determine the setting for interaction
|
30
|
-
if opt_interactive.blank? and
|
36
|
+
if opt_interactive.blank? and
|
37
|
+
!hieraDefaults.nil? and
|
38
|
+
!hieraDefaults['sort'].nil? and
|
39
|
+
!hieraDefaults['sort']['interactive'].nil? and
|
40
|
+
hieraDefaults['sort']['interactive'] == true
|
31
41
|
puts 'Setting interactive from hiera'
|
32
42
|
interactiveAction = true
|
33
43
|
elsif opt_interactive == 'true'
|
@@ -41,7 +51,9 @@ destination = opt_destination
|
|
41
51
|
if destination.nil? or destination == ''
|
42
52
|
|
43
53
|
hieraHash = queryHiera('pdfmd::config')
|
44
|
-
if !hieraHash
|
54
|
+
if !hieraHash.nil? and
|
55
|
+
!hieraHash['sort'].nil? and
|
56
|
+
!hieraHash['sort']['destination'].nil?
|
45
57
|
destination = hieraHash['sort']['destination']
|
46
58
|
else
|
47
59
|
puts 'No information about destination found.'
|
@@ -52,7 +64,11 @@ if destination.nil? or destination == ''
|
|
52
64
|
end
|
53
65
|
|
54
66
|
# Determine the state of the logging
|
55
|
-
if (opt_log.blank? and
|
67
|
+
if (opt_log.blank? and
|
68
|
+
!hieraDefaults.nil? and
|
69
|
+
!hieraDefaults['sort'].nil? and
|
70
|
+
!hieraDefaults['sort']['log'].nil? and
|
71
|
+
hieraDefaults['sort']['log'] == true) or
|
56
72
|
opt_log == 'true'
|
57
73
|
logenable = true
|
58
74
|
elsif opt_log.blank? or opt_log == 'false'
|
@@ -91,9 +107,12 @@ if logenable
|
|
91
107
|
$logger = Logger.new(logfile)
|
92
108
|
end
|
93
109
|
|
110
|
+
# Create array of Files to iterate through
|
111
|
+
pdfDocuments = File.directory?(inputDir) ? Dir[inputDir.chomp('/') + '/*.pdf'].sort : inputDir.split
|
112
|
+
|
113
|
+
|
94
114
|
# Input validation
|
95
|
-
!File.exist?(inputDir) ? abort('Input
|
96
|
-
File.directory?(inputDir) ? '' : abort('Input is a single file. Not implemented yet. Abort.')
|
115
|
+
!File.exist?(inputDir) ? abort('Input does not exist. Abort.'): ''
|
97
116
|
File.file?(destination) ? abort("Output '#{destination}' is an existing file. Cannot create directory with the same name. Abort") : ''
|
98
117
|
|
99
118
|
if not File.directory?(destination)
|
@@ -109,7 +128,7 @@ if not File.directory?(destination)
|
|
109
128
|
end
|
110
129
|
|
111
130
|
# Iterate through all files
|
112
|
-
|
131
|
+
pdfDocuments.each do |file|
|
113
132
|
|
114
133
|
if interactiveAction
|
115
134
|
answer = readUserInput("Process '#{file}' ([y]/n): ")
|
@@ -142,6 +161,8 @@ Dir[inputDir.chomp('/') + '/*.pdf'].sort.each do |file|
|
|
142
161
|
|
143
162
|
filedestination = destination.chomp('/') + '/' + author + '/' + Pathname.new(file).basename.to_s
|
144
163
|
|
164
|
+
puts filedestination
|
165
|
+
|
145
166
|
|
146
167
|
# Final check before touching the filesystem
|
147
168
|
if not File.exist?(filedestination)
|
data/test/test_default.pdf
CHANGED
Binary file
|
data/test/test_rename.rb
CHANGED
@@ -5,9 +5,10 @@ commandparameter = " rename -o #{TMPDIR} -c false "
|
|
5
5
|
`#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
|
6
6
|
files = readFilesInDir(TMPDIR)
|
7
7
|
if files.size == 1 and
|
8
|
-
File.basename(files.keys[0]) == '19700101-example_author-
|
8
|
+
File.basename(files.keys[0]) == '19700101-example_author-doc-test_subject-cno1111111-some_keywords.pdf'
|
9
9
|
result = 'OK'
|
10
10
|
else
|
11
|
+
puts File.basename(files.keys[0])
|
11
12
|
result = 'failed'
|
12
13
|
end
|
13
14
|
$testResults = { '001' => {:result => result, :command => commandparameter }}
|
@@ -20,10 +21,11 @@ commandparameter = " rename -c -o #{TMPDIR}"
|
|
20
21
|
`#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
|
21
22
|
files = readFilesInDir(TMPDIR)
|
22
23
|
if files.size == 2 and
|
23
|
-
File.basename(files.keys[0]) == '19700101-example_author-
|
24
|
+
File.basename(files.keys[0]) == '19700101-example_author-doc-test_subject-cno1111111-some_keywords.pdf'
|
24
25
|
File.basename(files.keys[1]) == 'test_default.pdf'
|
25
26
|
result = 'OK'
|
26
27
|
else
|
28
|
+
puts File.basename(files.keys[0])
|
27
29
|
result = 'failed'
|
28
30
|
end
|
29
31
|
$testResults.store('002', {:result => result, :command => commandparameter })
|
@@ -49,9 +51,10 @@ commandparameter = " rename -a -o #{TMPDIR} -c false"
|
|
49
51
|
`#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
|
50
52
|
files = readFilesInDir(TMPDIR)
|
51
53
|
if files.size == 1 and
|
52
|
-
File.basename(files.keys[0]) == '19700101-example_author-
|
54
|
+
File.basename(files.keys[0]) == '19700101-example_author-doc-test_subject-cno1111111-some_keywords-author-some_feature-kundenummer_1111111.pdf'
|
53
55
|
result = 'OK'
|
54
56
|
else
|
57
|
+
puts File.basename(files.keys[0])
|
55
58
|
result = 'failed'
|
56
59
|
end
|
57
60
|
$testResults.store('004', {:result => result, :command => commandparameter })
|
@@ -64,9 +67,10 @@ commandparameter = " rename -k 1 -o #{TMPDIR} -c false"
|
|
64
67
|
`#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
|
65
68
|
files = readFilesInDir(TMPDIR)
|
66
69
|
if files.size == 1 and
|
67
|
-
File.basename(files.keys[0]) == '19700101-example_author-
|
70
|
+
File.basename(files.keys[0]) == '19700101-example_author-doc-test_subject.pdf'
|
68
71
|
result = 'OK'
|
69
72
|
else
|
73
|
+
puts File.basename(files.keys[0])
|
70
74
|
result = 'failed'
|
71
75
|
end
|
72
76
|
$testResults.store('005', {:result => result, :command => commandparameter })
|
@@ -78,10 +82,11 @@ commandparameter = " rename -l -p #{TMPDIR}/pdfmd.log -c false"
|
|
78
82
|
`#{PDFMD} #{commandparameter} #{TARGETPDF}`.chomp
|
79
83
|
files = readFilesInDir(TMPDIR)
|
80
84
|
if files.size == 1 and
|
81
|
-
File.basename(files.keys[0]) == '19700101-example_author-
|
85
|
+
File.basename(files.keys[0]) == '19700101-example_author-doc-test_subject-cno1111111-some_keywords.pdf' and
|
82
86
|
`tail -n 1 #{TMPDIR}/pdfmd.log | wc -l`.to_i == 1
|
83
87
|
result = 'OK'
|
84
88
|
else
|
89
|
+
puts File.basename(files.keys[0])
|
85
90
|
result = 'failed'
|
86
91
|
end
|
87
92
|
$testResults.store('006', {:result => result, :command => commandparameter })
|
data/test/test_show.rb
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
def show_content(actualContent,expectedContent)
|
2
|
+
puts "Expteced: \n #{expectedContent}"
|
3
|
+
puts '---'
|
4
|
+
puts "Got : \n #{showContent}"
|
5
|
+
end
|
6
|
+
|
1
7
|
# Standard Show
|
2
8
|
# Test 001
|
3
9
|
initTmpDir
|
@@ -13,6 +19,7 @@ if showContent == expectedContent
|
|
13
19
|
result = 'OK'
|
14
20
|
else
|
15
21
|
result = 'failed'
|
22
|
+
show_content(showContent,expectedContent)
|
16
23
|
end
|
17
24
|
$testResults = { '001' => {:result => result, :command => commandparameter }}
|
18
25
|
|
@@ -26,6 +33,7 @@ if showContent == expectedContent
|
|
26
33
|
result = 'OK'
|
27
34
|
else
|
28
35
|
result = 'failed'
|
36
|
+
show_content(showContent,expectedContent)
|
29
37
|
end
|
30
38
|
$testResults.store('002', {:result => result, :command => commandparameter })
|
31
39
|
|
@@ -40,6 +48,7 @@ if showContent == expectedContent
|
|
40
48
|
result = 'OK'
|
41
49
|
else
|
42
50
|
result = 'failed'
|
51
|
+
show_content(showContent,expectedContent)
|
43
52
|
end
|
44
53
|
$testResults.store('003', {:result => result, :command => commandparameter })
|
45
54
|
|
@@ -55,6 +64,7 @@ if showContent == expectedContent
|
|
55
64
|
result = 'OK'
|
56
65
|
else
|
57
66
|
result = 'failed'
|
67
|
+
show_content(showContent,expectedContent)
|
58
68
|
end
|
59
69
|
$testResults.store('004', {:result => result, :command => commandparameter })
|
60
70
|
|
@@ -68,6 +78,7 @@ if showContent == expectedContent
|
|
68
78
|
result = 'OK'
|
69
79
|
else
|
70
80
|
result = 'failed'
|
81
|
+
show_content(showContent,expectedContent)
|
71
82
|
end
|
72
83
|
$testResults.store('005', {:result => result, :command => commandparameter })
|
73
84
|
|
@@ -81,6 +92,7 @@ if showContent == expectedContent
|
|
81
92
|
result = 'OK'
|
82
93
|
else
|
83
94
|
result = 'failed'
|
95
|
+
show_content(showContent,expectedContent)
|
84
96
|
end
|
85
97
|
$testResults.store('006', {:result => result, :command => commandparameter })
|
86
98
|
|
@@ -94,6 +106,7 @@ if showContent == expectedContent
|
|
94
106
|
result = 'OK'
|
95
107
|
else
|
96
108
|
result = 'failed'
|
109
|
+
show_content(showContent,expectedContent)
|
97
110
|
end
|
98
111
|
$testResults.store('007', {:result => result, :command => commandparameter })
|
99
112
|
|
data/test/test_sort.rb
CHANGED
@@ -2,16 +2,7 @@
|
|
2
2
|
#
|
3
3
|
# Test 001
|
4
4
|
# Testing Abort when running on a single file
|
5
|
-
|
6
|
-
commandparameter = " sort -d #{TMPDIR}/target "
|
7
|
-
`#{PDFMD} #{commandparameter} #{TARGETPDF} 2>/dev/null`
|
8
|
-
if $?.to_s.match(/.*exit 1/)
|
9
|
-
result = 'OK'
|
10
|
-
else
|
11
|
-
result = 'failed'
|
12
|
-
end
|
13
|
-
$testResults = { '001' => {:result => result, :command => commandparameter }}
|
14
|
-
|
5
|
+
# Disabled since single file support in version 1.9.0
|
15
6
|
|
16
7
|
# Test 002
|
17
8
|
# Testing Sorting on a dir
|
metadata
CHANGED
@@ -1,106 +1,106 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.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-
|
11
|
+
date: 2015-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0.19'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 0.19.1
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0.19'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.19.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: highline
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - ~>
|
37
|
+
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '1.7'
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: 1.7.1
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - ~>
|
47
|
+
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '1.7'
|
50
|
-
- -
|
50
|
+
- - ">="
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: 1.7.1
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: fileutils
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
|
-
- - ~>
|
57
|
+
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0.7'
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0.7'
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0.7'
|
70
|
-
- -
|
70
|
+
- - ">="
|
71
71
|
- !ruby/object:Gem::Version
|
72
72
|
version: '0.7'
|
73
73
|
- !ruby/object:Gem::Dependency
|
74
74
|
name: i18n
|
75
75
|
requirement: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
- - ~>
|
77
|
+
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
79
|
version: '0.6'
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.6.11
|
83
83
|
type: :runtime
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - ~>
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.6'
|
90
|
-
- -
|
90
|
+
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: 0.6.11
|
93
|
-
description:
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
description: |2
|
94
|
+
Managing the common pdf metadata values and renaming the pdf file accordingly.
|
95
|
+
Sets common tags like 'author', 'createdate', 'title', 'subject' and 'keywords'
|
96
|
+
and re-uses them for renaming the file with to a human-readable identifier.
|
97
97
|
email: pdfmd@micronarrativ.org
|
98
98
|
executables:
|
99
99
|
- pdfmd
|
100
100
|
extensions: []
|
101
101
|
extra_rdoc_files: []
|
102
102
|
files:
|
103
|
-
- .gitignore
|
103
|
+
- ".gitignore"
|
104
104
|
- CHANGELOG.md
|
105
105
|
- LICENSE
|
106
106
|
- README.md
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- lib/pdfmd/explain.author.md
|
114
114
|
- lib/pdfmd/explain.createdate.md
|
115
115
|
- lib/pdfmd/explain.csv.md
|
116
|
+
- lib/pdfmd/explain.hiera-keys.md
|
116
117
|
- lib/pdfmd/explain.hiera.md
|
117
118
|
- lib/pdfmd/explain.keywords.md
|
118
119
|
- lib/pdfmd/explain.password.md
|
@@ -139,16 +140,16 @@ require_paths:
|
|
139
140
|
- lib
|
140
141
|
required_ruby_version: !ruby/object:Gem::Requirement
|
141
142
|
requirements:
|
142
|
-
- -
|
143
|
+
- - ">="
|
143
144
|
- !ruby/object:Gem::Version
|
144
145
|
version: '0'
|
145
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
147
|
requirements:
|
147
|
-
- -
|
148
|
+
- - ">="
|
148
149
|
- !ruby/object:Gem::Version
|
149
150
|
version: '0'
|
150
151
|
requirements:
|
151
|
-
-
|
152
|
+
- "[exiftools](http://www.sno.phy.queensu.ca/~phil/exiftool/)"
|
152
153
|
rubyforge_project:
|
153
154
|
rubygems_version: 2.4.6
|
154
155
|
signing_key:
|