pdfmd 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +1 -3
- data/TODO.mkd +0 -6
- data/bin/pdfmd +84 -34
- data/lib/pdfmd.rb +1 -0
- data/lib/pdfmd/.pdfmd.log +3 -0
- data/lib/pdfmd/long_desc.pdfmdclean.txt +28 -0
- data/lib/pdfmd/long_desc.pdfmdconfig.txt +0 -7
- data/lib/pdfmd/pdfmdclean.rb +37 -0
- data/lib/pdfmd/pdfmdrename.rb +31 -2
- data/lib/pdfmd/pdfmdsort.rb +1 -1
- data/lib/run.rb +85 -34
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e4dab486ed68d69f67afc23637cc18389c0e83d
|
4
|
+
data.tar.gz: 893abb0820f6828ccb60b9ce18780d4e4608dc1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef3bfde7c7b34cb1633d4857709bb8470618f31d07a4b58759ee1e3899a16b8c97fbb382c0c7d34e5e31025b0ea4d26c40e10641ba15f48543effd042a1740c
|
7
|
+
data.tar.gz: cbbb4db188e3aea5c1c6edd88b71288da1ef8dfa5ee779582da66af135cd38926d2354d47226119da3ba2e3ebce2e64bb7a810648cbde8ce184d35ade7ade9ff
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# Version 2.1.0
|
2
|
+
- Added command 'clean' to delete values for Metatags
|
3
|
+
- Added multiple file support for commands 'clean', 'edit', 'rename', 'show'
|
4
|
+
- Bugfix: Renaming
|
5
|
+
- Bugfix: Sorting
|
6
|
+
- Added abort when renaming a file with incomplete metadata.
|
7
|
+
|
1
8
|
# Version 2.0.0
|
2
9
|
- Rewritten the gem using classes.
|
3
10
|
- Shorter Code (optimizing)
|
@@ -16,7 +23,7 @@
|
|
16
23
|
- Added parameter '-r' which shows the revision of the gem.
|
17
24
|
- Bug: Renaming files with a '/' in the metadatafield 'author'.
|
18
25
|
- Bug: Renaming files with spaces in the metadatafield 'subject'.
|
19
|
-
- Collected
|
26
|
+
- Collected Todos in `TODO.mkd`.
|
20
27
|
|
21
28
|
# Version 1.9.1
|
22
29
|
- Removed some inactive Code
|
data/README.md
CHANGED
@@ -144,8 +144,6 @@ pdfmd::config:
|
|
144
144
|
|
145
145
|
Information about which hiera configuration settings are available can be either found in `pdfmd help <command>` or `pdfmd explain hiera`.
|
146
146
|
|
147
|
-
**PDFMD** expects currently the hiera configuration file to be at `/etc/hiera.yaml`. With Hiera2 the default location has changed to `/etc/puppetlabs/code/hiera.yaml`. This might be addressed in a future version. Currently you have to create at least a symlink to `/etc/hiera.yaml`.
|
148
|
-
|
149
147
|
Test your hiera configuration with
|
150
148
|
|
151
149
|
``` bash
|
@@ -155,4 +153,4 @@ $ hiera pdfmd::config
|
|
155
153
|
# Contact
|
156
154
|
|
157
155
|
If you have improvements and suggestions -> let me know.
|
158
|
-
|
156
|
+
If you can help me writing tests for this, please let me know as well.
|
data/TODO.mkd
CHANGED
@@ -3,18 +3,12 @@
|
|
3
3
|
## pdfmd.rb
|
4
4
|
* The logfile is a bit annoying. It should be possible to configure the logfile to be placed whereever convenient without creating double log files.
|
5
5
|
* Replace system copy command with fileutils.copy.
|
6
|
-
* Run commands on multiple PDF documents as one.
|
7
|
-
* Method for removing all metadata from a PDF document.
|
8
6
|
|
9
7
|
### Method: _stat_
|
10
8
|
* Parameter to ignore differences in upper and lowercase
|
11
9
|
* Parameter to disable percentage output
|
12
10
|
* Parameter to set output format: json,yaml, hash
|
13
11
|
|
14
|
-
## pdfmdrename.rb
|
15
|
-
|
16
|
-
* Refuse renaming if values are missing for either: author, title, subject or createdate. Keywords are optional.
|
17
|
-
|
18
12
|
## pdfmdedit.rb
|
19
13
|
|
20
14
|
* keywords are added differently according to the documentation, http://www.sno.phy.queensu.ca/~phil/exiftool/faq.html
|
data/bin/pdfmd
CHANGED
@@ -7,7 +7,7 @@ require "fileutils"
|
|
7
7
|
require "i18n"
|
8
8
|
require 'pathname'
|
9
9
|
|
10
|
-
VERSION = '2.
|
10
|
+
VERSION = '2.1.0'
|
11
11
|
NAME = 'pdfmd'
|
12
12
|
|
13
13
|
#
|
@@ -53,16 +53,49 @@ class DOC < Thor
|
|
53
53
|
method_option :tag, :type => :string, :aliases => '-t', :desc => 'Show specific tag(s), comma separated', :required => false
|
54
54
|
method_option :format, :type => :string, :aliases => '-f', :desc => 'Define output format', :required => false
|
55
55
|
method_option :includepdf, :type => :boolean, :aliases => '-i', :desc => 'Include the filename in output', :required => false
|
56
|
-
def show(filename)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
def show(*filename)
|
57
|
+
|
58
|
+
filename.each do |current_file|
|
59
|
+
|
60
|
+
# Skip non-pdf documents
|
61
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
62
|
+
|
63
|
+
pdfdoc = Pdfmdshow.new current_file
|
64
|
+
format = pdfdoc.determineValidSetting(options[:format], 'show:format')
|
65
|
+
show_filename = pdfdoc.determineValidSetting(options[:includepdf], 'show:includepdf')
|
66
|
+
show_tags = pdfdoc.determineValidSetting(options[:tag], 'show:tags')
|
67
|
+
pdfdoc.set_outputformat format
|
68
|
+
pdfdoc.show_filename show_filename
|
69
|
+
pdfdoc.set_tags show_tags
|
70
|
+
puts pdfdoc.show_metatags
|
71
|
+
|
72
|
+
# Unset
|
73
|
+
pdfdoc = ''
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
# Clean all metadata from a document
|
80
|
+
#
|
81
|
+
desc 'clean', 'Clean metadata from file'
|
82
|
+
long_desc readLongDesc 'pdfmd/long_desc.pdfmdclean.txt'
|
83
|
+
method_option :tags, :aliases => '-t', :type => :string, :required => false
|
84
|
+
def clean(*filename)
|
85
|
+
|
86
|
+
filename.each do |current_file|
|
87
|
+
|
88
|
+
# Skip non-pdf documents
|
89
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
90
|
+
|
91
|
+
pdfdoc = Pdfmdclean.new current_file
|
92
|
+
pdfdoc.tags = options[:tags]
|
93
|
+
pdfdoc.run
|
94
|
+
|
95
|
+
# Unset
|
96
|
+
pdfdoc = ''
|
97
|
+
|
98
|
+
end
|
66
99
|
end
|
67
100
|
|
68
101
|
|
@@ -88,22 +121,29 @@ long_desc readLongDesc 'pdfmd/long_desc.pdfmdedit.txt'
|
|
88
121
|
method_option :tag, :type => :string, :aliases => '-t', :desc => 'Name of the Tag(s) to Edit', :required => true, :lazy_default => 'all'
|
89
122
|
method_option :rename, :type => :boolean, :aliases => '-r', :desc => 'Rename file after changing meta-tags', :required => false
|
90
123
|
method_option :opendoc, :type => :boolean, :aliases => '-o', :desc => 'Open the PDF document in a separate window.', :required => false, :lazy_default => true
|
91
|
-
def edit(filename)
|
124
|
+
def edit(*filename)
|
125
|
+
|
126
|
+
filename.each do |current_file|
|
92
127
|
|
93
|
-
|
94
|
-
|
95
|
-
pdfdoc.opendoc = pdfdoc.determineValidSetting(options[:opendoc], 'edit:opendoc')
|
96
|
-
pdfdoc.pdfviewer = pdfdoc.determineValidSetting(nil, 'edit:pdfviewer')
|
97
|
-
pdfdoc.set_tags tags
|
98
|
-
pdfdoc.update_tags
|
99
|
-
pdfdoc.write_tags filename
|
128
|
+
# Skip non-pdf documents
|
129
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
100
130
|
|
101
|
-
|
102
|
-
|
131
|
+
pdfdoc = Pdfmdedit.new current_file
|
132
|
+
tags = pdfdoc.determineValidSetting(options[:tag],'edit:tags')
|
133
|
+
pdfdoc.opendoc = pdfdoc.determineValidSetting(options[:opendoc], 'edit:opendoc')
|
134
|
+
pdfdoc.pdfviewer = pdfdoc.determineValidSetting(nil, 'edit:pdfviewer')
|
135
|
+
pdfdoc.set_tags tags
|
136
|
+
pdfdoc.update_tags
|
137
|
+
pdfdoc.write_tags current_file
|
103
138
|
|
104
|
-
#
|
105
|
-
pdfdoc.
|
106
|
-
|
139
|
+
# If the file shall be renamed at the same time, trigger the other task
|
140
|
+
if pdfdoc.determineValidSetting(options[:rename], 'edit:rename')
|
141
|
+
|
142
|
+
#rename filename
|
143
|
+
pdfdoc.log('info', 'Running rename command.')
|
144
|
+
rename current_file
|
145
|
+
|
146
|
+
end
|
107
147
|
|
108
148
|
end
|
109
149
|
|
@@ -205,17 +245,27 @@ end
|
|
205
245
|
method_option :nrkeywords, :type => :string, :aliases => '-k', :desc => 'Number of keywords to include (Default: 3)', :required => false
|
206
246
|
method_option :outputdir, :aliases => '-o', :type => :string, :desc => 'Specify output directory', :required => false
|
207
247
|
method_option :copy, :aliases => '-c', :type => :boolean, :desc => 'Copy instead of moving the file when renaming', :lazy_default => true
|
208
|
-
def rename(filename)
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
pdfdoc.
|
248
|
+
def rename(*filename)
|
249
|
+
|
250
|
+
filename.each do |current_file|
|
251
|
+
|
252
|
+
# Skip non-pdf documents
|
253
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
254
|
+
|
255
|
+
pdfdoc = Pdfmdrename.new current_file
|
256
|
+
pdfdoc.dryrun = pdfdoc.determineValidSetting(options[:dryrun],'rename:dryrun')
|
257
|
+
pdfdoc.allkeywords = pdfdoc.determineValidSetting(options[:allkeywords],'rename:allkeywords')
|
258
|
+
pdfdoc.outputdir = pdfdoc.determineValidSetting(options[:outputdir], 'rename:outputdir')
|
259
|
+
if nrkeywords = pdfdoc.determineValidSetting(options[:nrkeywords], 'rename:nrkeywords' )
|
260
|
+
pdfdoc.nrkeywords = nrkeywords
|
261
|
+
end
|
262
|
+
pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'rename:copy')
|
263
|
+
pdfdoc.rename
|
264
|
+
|
265
|
+
# Unset
|
266
|
+
pdfdoc = ''
|
267
|
+
|
216
268
|
end
|
217
|
-
pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'rename:copy')
|
218
|
-
pdfdoc.rename
|
219
269
|
|
220
270
|
end
|
221
271
|
|
data/lib/pdfmd.rb
CHANGED
@@ -21,6 +21,7 @@ class Pdfmd
|
|
21
21
|
require_relative 'pdfmd/pdfmdrename.rb'
|
22
22
|
require_relative 'pdfmd/pdfmdsort.rb'
|
23
23
|
require_relative 'pdfmd/string_extend.rb'
|
24
|
+
require_relative 'pdfmd/pdfmdclean.rb'
|
24
25
|
require 'logger'
|
25
26
|
|
26
27
|
@@default_tags = ['createdate', 'author', 'title', 'subject', 'keywords']
|
@@ -0,0 +1,3 @@
|
|
1
|
+
# Logfile created on 2015-07-07 20:42:01 +0200 by logger.rb/44203
|
2
|
+
I, [2015-07-07T20:42:01.345848 #14145] INFO -- : Starting with file '/home/jt/Nedlastinger/pdfsort/test.pdf'.
|
3
|
+
I, [2015-07-07T20:42:02.000264 #14145] INFO -- : Showing metatags for '/home/jt/Nedlastinger/pdfsort/test.pdf' in format 'yaml'.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== General
|
2
|
+
|
3
|
+
Clean metatags of a PDF document.
|
4
|
+
|
5
|
+
== Usage
|
6
|
+
|
7
|
+
Example: `pdfmd clean <file>`
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
== Parameter
|
12
|
+
|
13
|
+
|
14
|
+
<file>
|
15
|
+
|
16
|
+
|
17
|
+
Path to file to work with.
|
18
|
+
|
19
|
+
|
20
|
+
--tags, -t <list_of_tags>
|
21
|
+
|
22
|
+
Tags to remove from the file. If no tag is provided, all tags are assumed (all Tags managed by pdfmd, not really all available tags ;) ).
|
23
|
+
Tags are listed as a comma separated string.
|
24
|
+
Additionally the value 'all' is allowed.
|
25
|
+
|
26
|
+
Example: `pdfmd clean -t author,title example.pdf`
|
27
|
+
|
28
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# == Class: pdfmdclean
|
2
|
+
#
|
3
|
+
# Clean metadata from a document
|
4
|
+
#
|
5
|
+
class Pdfmdclean < Pdfmd
|
6
|
+
|
7
|
+
attr_accessor :filename, :tags
|
8
|
+
|
9
|
+
def initialize(filename)
|
10
|
+
super(filename)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Run the actual cleaning
|
14
|
+
def run()
|
15
|
+
|
16
|
+
# Figure out which tags actually to reset.
|
17
|
+
if @tags.nil? or @tags == 'all'
|
18
|
+
@tags = @@default_tags
|
19
|
+
elsif @tags.is_a?(String)
|
20
|
+
@tags = @tags.split(',')
|
21
|
+
end
|
22
|
+
|
23
|
+
# Create the command to delete all the metatags
|
24
|
+
command = 'exiftool'
|
25
|
+
parameter = ' -overwrite_original'
|
26
|
+
@tags.each do |current_tag|
|
27
|
+
parameter << " -#{current_tag}="
|
28
|
+
end
|
29
|
+
parameter << ' '
|
30
|
+
|
31
|
+
`#{command} #{parameter} #{@filename}`
|
32
|
+
self.log('info', "Cleaning tags '#{@tags.join(', ').to_s}' from file '#{@filename}'.")
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
end
|
data/lib/pdfmd/pdfmdrename.rb
CHANGED
@@ -47,6 +47,11 @@ class Pdfmdrename < Pdfmd
|
|
47
47
|
newFilename[:extension] = @fileextension
|
48
48
|
newFilename[:outputdir] = get_outputdir(@outputdir)
|
49
49
|
|
50
|
+
# Verify that all data is available for renaming and fail otherwise
|
51
|
+
if !verifyDocumentData(newFilename)
|
52
|
+
abort 'Document metadata not complete. Abort renaming.'
|
53
|
+
end
|
54
|
+
|
50
55
|
command = @copy ? 'cp' : 'mv'
|
51
56
|
|
52
57
|
filetarget = get_filename(newFilename)
|
@@ -72,6 +77,30 @@ class Pdfmdrename < Pdfmd
|
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
80
|
+
#
|
81
|
+
# Data verification
|
82
|
+
# returns false is any metatadag is missing
|
83
|
+
# other than keywords
|
84
|
+
def verifyDocumentData(filedata = {})
|
85
|
+
|
86
|
+
@@default_tags.each do |current_tag|
|
87
|
+
|
88
|
+
if not @@metadata[current_tag].nil? and not @@metadata[current_tag] == ''
|
89
|
+
|
90
|
+
# Skip over keywords (optional tag)
|
91
|
+
current_tag.match(/keywords/) ? next : ''
|
92
|
+
|
93
|
+
else
|
94
|
+
|
95
|
+
return false
|
96
|
+
|
97
|
+
end
|
98
|
+
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
|
75
104
|
#
|
76
105
|
# Return the filename from the available filedata
|
77
106
|
def get_filename(filedata = {})
|
@@ -200,7 +229,7 @@ class Pdfmdrename < Pdfmd
|
|
200
229
|
end
|
201
230
|
|
202
231
|
if !filedata[:subject].nil? and !filedata[:subject].empty? and
|
203
|
-
|
232
|
+
filedata[:doctype] != @defaultDoctype
|
204
233
|
|
205
234
|
I18n.transliterate(filedata[:subject])
|
206
235
|
|
@@ -235,7 +264,7 @@ class Pdfmdrename < Pdfmd
|
|
235
264
|
# Get the author from the metatags and
|
236
265
|
# normalize the string
|
237
266
|
def get_author()
|
238
|
-
author = @@metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'').gsub(/\s|\//,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
|
267
|
+
author = @@metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'_').gsub(/\s|\//,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
|
239
268
|
I18n.enforce_available_locales = false
|
240
269
|
I18n.transliterate(author).downcase # Normalising
|
241
270
|
end
|
data/lib/pdfmd/pdfmdsort.rb
CHANGED
@@ -39,7 +39,7 @@ class Pdfmdsort < Pdfmd
|
|
39
39
|
if not self.check_metatags('author')
|
40
40
|
return false
|
41
41
|
end
|
42
|
-
author = @@metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'').gsub(/\s/,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
|
42
|
+
author = @@metadata['author'].gsub(/\./,'_').gsub(/\&/,'').gsub(/\-/,'_').gsub(/\s/,'_').gsub(/\,/,'_').gsub(/\_\_/,'_')
|
43
43
|
I18n.enforce_available_locales = false
|
44
44
|
I18n.transliterate(author).downcase # Normalising
|
45
45
|
end
|
data/lib/run.rb
CHANGED
@@ -3,7 +3,7 @@ require './pdfmd.rb'
|
|
3
3
|
require './pdfmd/pdfmdstat.rb'
|
4
4
|
require "thor"
|
5
5
|
|
6
|
-
VERSION = '2.
|
6
|
+
VERSION = '2.1.0'
|
7
7
|
NAME = 'pdfmd'
|
8
8
|
|
9
9
|
#
|
@@ -49,16 +49,47 @@ class DOC < Thor
|
|
49
49
|
method_option :tag, :type => :string, :aliases => '-t', :desc => 'Show specific tag(s), comma separated', :required => false
|
50
50
|
method_option :format, :type => :string, :aliases => '-f', :desc => 'Define output format', :required => false
|
51
51
|
method_option :includepdf, :type => :boolean, :aliases => '-i', :desc => 'Include the filename in output', :required => false
|
52
|
-
def show(filename)
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
def show(*filename)
|
53
|
+
|
54
|
+
filename.each do |current_file|
|
55
|
+
|
56
|
+
# Skip non-pdf documents
|
57
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
58
|
+
|
59
|
+
pdfdoc = Pdfmdshow.new current_file
|
60
|
+
format = pdfdoc.determineValidSetting(options[:format], 'show:format')
|
61
|
+
show_filename = pdfdoc.determineValidSetting(options[:includepdf], 'show:includepdf')
|
62
|
+
show_tags = pdfdoc.determineValidSetting(options[:tag], 'show:tags')
|
63
|
+
pdfdoc.set_outputformat format
|
64
|
+
pdfdoc.show_filename show_filename
|
65
|
+
pdfdoc.set_tags show_tags
|
66
|
+
puts pdfdoc.show_metatags
|
67
|
+
|
68
|
+
pdfdoc = ''
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Clean all metadata from a document
|
74
|
+
#
|
75
|
+
desc 'clean', 'Clean metadata from file'
|
76
|
+
long_desc readLongDesc 'pdfmd/long_desc.pdfmdclean.txt'
|
77
|
+
method_option :tags, :aliases => '-t', :type => :string, :required => false
|
78
|
+
def clean(*filename)
|
79
|
+
|
80
|
+
filename.each do |current_file|
|
81
|
+
|
82
|
+
# Skip non-pdf documents
|
83
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
84
|
+
|
85
|
+
pdfdoc = Pdfmdclean.new current_file
|
86
|
+
pdfdoc.tags = options[:tags]
|
87
|
+
pdfdoc.run
|
88
|
+
|
89
|
+
# Unset
|
90
|
+
pdfdoc = ''
|
91
|
+
|
92
|
+
end
|
62
93
|
end
|
63
94
|
|
64
95
|
|
@@ -82,22 +113,32 @@ class DOC < Thor
|
|
82
113
|
method_option :tag, :type => :string, :aliases => '-t', :desc => 'Name of the Tag(s) to Edit', :required => true, :lazy_default => 'all'
|
83
114
|
method_option :rename, :type => :boolean, :aliases => '-r', :desc => 'Rename file after changing meta-tags', :required => false
|
84
115
|
method_option :opendoc, :type => :boolean, :aliases => '-o', :desc => 'Open the PDF document in a separate window.', :required => false, :lazy_default => true
|
85
|
-
def edit(filename)
|
116
|
+
def edit(*filename)
|
117
|
+
|
118
|
+
filename.each do |current_file|
|
119
|
+
|
120
|
+
# Skip non-pdf documents
|
121
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
86
122
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
123
|
+
pdfdoc = Pdfmdedit.new current_file
|
124
|
+
tags = pdfdoc.determineValidSetting(options[:tag],'edit:tags')
|
125
|
+
pdfdoc.opendoc = pdfdoc.determineValidSetting(options[:opendoc], 'edit:opendoc')
|
126
|
+
pdfdoc.pdfviewer = pdfdoc.determineValidSetting(nil, 'edit:pdfviewer')
|
127
|
+
pdfdoc.set_tags tags
|
128
|
+
pdfdoc.update_tags
|
129
|
+
pdfdoc.write_tags current_file
|
94
130
|
|
95
|
-
|
96
|
-
|
131
|
+
# If the file shall be renamed at the same time, trigger the other task
|
132
|
+
if pdfdoc.determineValidSetting(options[:rename], 'edit:rename')
|
133
|
+
|
134
|
+
#rename filename
|
135
|
+
pdfdoc.log('info', 'Running rename command.')
|
136
|
+
rename current_file
|
137
|
+
|
138
|
+
end
|
97
139
|
|
98
|
-
#
|
99
|
-
pdfdoc
|
100
|
-
rename filename
|
140
|
+
# Unset the object
|
141
|
+
pdfdoc = ''
|
101
142
|
|
102
143
|
end
|
103
144
|
|
@@ -200,17 +241,27 @@ class DOC < Thor
|
|
200
241
|
method_option :nrkeywords, :type => :string, :aliases => '-k', :desc => 'Number of keywords to include (Default: 3)', :required => false
|
201
242
|
method_option :outputdir, :aliases => '-o', :type => :string, :desc => 'Specify output directory', :required => false
|
202
243
|
method_option :copy, :aliases => '-c', :type => :boolean, :desc => 'Copy instead of moving the file when renaming', :lazy_default => true
|
203
|
-
def rename(filename)
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
pdfdoc.
|
244
|
+
def rename(*filename)
|
245
|
+
|
246
|
+
filename.each do |current_file|
|
247
|
+
|
248
|
+
# Skip non-pdf documents
|
249
|
+
! File.extname(current_file).match(/\.pdf/) ? next : ''
|
250
|
+
|
251
|
+
pdfdoc = Pdfmdrename.new current_file
|
252
|
+
pdfdoc.dryrun = pdfdoc.determineValidSetting(options[:dryrun],'rename:dryrun')
|
253
|
+
pdfdoc.allkeywords = pdfdoc.determineValidSetting(options[:allkeywords],'rename:allkeywords')
|
254
|
+
pdfdoc.outputdir = pdfdoc.determineValidSetting(options[:outputdir], 'rename:outputdir')
|
255
|
+
if nrkeywords = pdfdoc.determineValidSetting(options[:nrkeywords], 'rename:nrkeywords' )
|
256
|
+
pdfdoc.nrkeywords = nrkeywords
|
257
|
+
end
|
258
|
+
pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'rename:copy')
|
259
|
+
pdfdoc.rename
|
260
|
+
|
261
|
+
# Unset
|
262
|
+
pdfdoc = ''
|
263
|
+
|
211
264
|
end
|
212
|
-
pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'rename:copy')
|
213
|
-
pdfdoc.rename
|
214
265
|
|
215
266
|
end
|
216
267
|
|
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: 2.
|
4
|
+
version: 2.1.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-07-
|
11
|
+
date: 2015-07-08 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
|
- TODO.mkd
|
109
109
|
- bin/pdfmd
|
110
110
|
- lib/pdfmd.rb
|
111
|
+
- lib/pdfmd/.pdfmd.log
|
111
112
|
- lib/pdfmd/explain.author.md
|
112
113
|
- lib/pdfmd/explain.createdate.md
|
113
114
|
- lib/pdfmd/explain.csv.md
|
@@ -118,6 +119,7 @@ files:
|
|
118
119
|
- lib/pdfmd/explain.rb
|
119
120
|
- lib/pdfmd/explain.subject.md
|
120
121
|
- lib/pdfmd/explain.title.md
|
122
|
+
- lib/pdfmd/long_desc.pdfmdclean.txt
|
121
123
|
- lib/pdfmd/long_desc.pdfmdconfig.txt
|
122
124
|
- lib/pdfmd/long_desc.pdfmdedit.txt
|
123
125
|
- lib/pdfmd/long_desc.pdfmdexplain.txt
|
@@ -126,6 +128,7 @@ files:
|
|
126
128
|
- lib/pdfmd/long_desc.pdfmdsort.txt
|
127
129
|
- lib/pdfmd/long_desc.pdfmdstat.txt
|
128
130
|
- lib/pdfmd/methods.rb
|
131
|
+
- lib/pdfmd/pdfmdclean.rb
|
129
132
|
- lib/pdfmd/pdfmdconfig.rb
|
130
133
|
- lib/pdfmd/pdfmdedit.rb
|
131
134
|
- lib/pdfmd/pdfmdmethods.rb
|
@@ -144,8 +147,8 @@ homepage: https://github.com/Micronarrativ/ruby-pmd
|
|
144
147
|
licenses:
|
145
148
|
- MIT
|
146
149
|
metadata:
|
147
|
-
created: '2015-07-
|
148
|
-
revision: '
|
150
|
+
created: '2015-07-08 17:21:15'
|
151
|
+
revision: '20150708172115'
|
149
152
|
post_install_message: ". Run `pdfmd` to see the command help."
|
150
153
|
rdoc_options: []
|
151
154
|
require_paths:
|