pdfmd 1.6.0 → 1.6.1
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 +13 -5
- data/CHANGELOG.md +8 -0
- data/README.md +29 -0
- data/lib/pdfmd/explain.hiera.md +1 -1
- data/lib/pdfmd/explain.rb +2 -1
- data/lib/pdfmd/sort.rb +47 -16
- data/lib/pdfmd.rb +5 -12
- metadata +27 -27
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MGVjOGZmZTlhYjIzMGMzM2NjYzFhZDExM2RkMjNkNjJlYzk3ZGEyZg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGRmODdhOGJkZTI4YTQ0NThkZmRkMmEzZGU4OTUyZDZiZjc0ZjMyNA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MTMzZmE2ZDE4MTZkNjA2ODM0ZmYzMDMwYjA5MGI3ZTg3YzZmMDc4ZTBhMjMx
|
10
|
+
ZTY4ZTU1YTIxMjQwOGNhMjA3MzQ5MDc1MTY1OGE1ZTcwMzczOTZkMDVhODAw
|
11
|
+
ODI0Yjc1OTViNDkzOWMxOTI0MTcyZTAzZTBmZjkzYTg0ZGMyZDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NGNkMmEyODYyMDRkNzBkNWI2NDNkYmJjMzJiNmQzMDIyNTE4Yzg3ZTg5MjVh
|
14
|
+
MjkzMjFiMTdmY2I0NjQzZjc4YmE5NjE0ZTEyNGI4NzkyZWY0NzRkYWMyNzBi
|
15
|
+
Nzc4YmZhNjE3YmQxZTFjMTc2NThkY2EwZTY3ZTRiNzE2MjQ3ODc=
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# Version 1.6.1
|
2
|
+
- Bugfix with the sorting command and the logging
|
3
|
+
- Added additional log messages for sorting.
|
4
|
+
- Removed ampersand from target directory when sorting
|
5
|
+
- Changed the parameter 'logfilepath' to 'logfile' for the command 'sort'. Now it should be identical in all commands.
|
6
|
+
- Fixed command 'explain'. That was only working from inside the git repository, but not elsewhere.
|
7
|
+
- Added installation instructions for Fedora/Ubuntu/CentOS to README.md
|
8
|
+
|
1
9
|
# Version 1.6.0
|
2
10
|
- Added command 'config'
|
3
11
|
- Added dependency 'yaml'
|
data/README.md
CHANGED
@@ -30,6 +30,35 @@ $ gem install pathname
|
|
30
30
|
$ gem install logger
|
31
31
|
```
|
32
32
|
|
33
|
+
## Platforms
|
34
|
+
### Fedora 21/CentOS 7
|
35
|
+
* Install the depencies (required to install the rmagick gem)
|
36
|
+
|
37
|
+
```
|
38
|
+
$ sudo yum install -y rubygems rubygems-devel gcc ImageMagick ruby-devel ImageMagick-devel
|
39
|
+
```
|
40
|
+
|
41
|
+
* Install Gem
|
42
|
+
|
43
|
+
```
|
44
|
+
$ gem install pdfmd
|
45
|
+
```
|
46
|
+
|
47
|
+
### Ubuntu 14.04 LTS
|
48
|
+
|
49
|
+
* Install the dependencies
|
50
|
+
|
51
|
+
```
|
52
|
+
$ sudo apt-get install -y rubygems-integration imagemagick libmagickwand-dev ruby-dev
|
53
|
+
```
|
54
|
+
|
55
|
+
* Install gem
|
56
|
+
|
57
|
+
```
|
58
|
+
$ sudo gem install pdfmd
|
59
|
+
```
|
60
|
+
|
61
|
+
|
33
62
|
## Applications
|
34
63
|
|
35
64
|
1. [exiftools](http://www.sno.phy.queensu.ca/~phil/exiftool/)
|
data/lib/pdfmd/explain.hiera.md
CHANGED
data/lib/pdfmd/explain.rb
CHANGED
@@ -13,5 +13,6 @@ when ''
|
|
13
13
|
puts ' '
|
14
14
|
puts "Run `$ #{pdfmd} explain <subject>` to get more details."
|
15
15
|
else
|
16
|
-
|
16
|
+
# This reads the explain.x.md file relatively to the installed script file
|
17
|
+
puts File.read(File.join(File.dirname(__FILE__),"explain.#{term.downcase}.md"))
|
17
18
|
end
|
data/lib/pdfmd/sort.rb
CHANGED
@@ -62,8 +62,8 @@ end
|
|
62
62
|
if logenable
|
63
63
|
|
64
64
|
if opt_logfilepath.blank? and
|
65
|
-
( hieraDefaults['sort']['
|
66
|
-
hieraDefaults['sort']['
|
65
|
+
( hieraDefaults['sort']['logfile'].nil? or
|
66
|
+
hieraDefaults['sort']['logfile'].blank? or
|
67
67
|
hieraDefaults['sort'].nil? )
|
68
68
|
|
69
69
|
logfile = Dir.pwd.chomp('/') + '/' + File.basename(ENV['PDFMD'], '.*') + '.log'
|
@@ -78,9 +78,9 @@ if logenable
|
|
78
78
|
logfile = opt_logfilepath
|
79
79
|
|
80
80
|
elsif opt_logfilepath.blank? and
|
81
|
-
not hieraDefaults['sort']['
|
81
|
+
not hieraDefaults['sort']['logfile'].blank?
|
82
82
|
|
83
|
-
logfile = hieraDefaults['sort']['
|
83
|
+
logfile = hieraDefaults['sort']['logfile']
|
84
84
|
|
85
85
|
else
|
86
86
|
|
@@ -95,9 +95,17 @@ end
|
|
95
95
|
!File.exist?(inputDir) ? abort('Input directory does not exist. Abort.'): ''
|
96
96
|
File.directory?(inputDir) ? '' : abort('Input is a single file. Not implemented yet. Abort.')
|
97
97
|
File.file?(destination) ? abort("Output '#{destination}' is an existing file. Cannot create directory with the same name. Abort") : ''
|
98
|
-
|
99
|
-
|
100
|
-
|
98
|
+
|
99
|
+
if not File.directory?(destination)
|
100
|
+
|
101
|
+
# Do nothing on a dry-run
|
102
|
+
if opt_dryrun
|
103
|
+
logenable ? $logger.info("Dryrun: Destination '#{destination}' has been created.") : ''
|
104
|
+
else
|
105
|
+
FileUtils.mkdir_p(destination)
|
106
|
+
logenable ? $logger.info("Destination '#{destination}' has been created.") : ''
|
107
|
+
end
|
108
|
+
|
101
109
|
end
|
102
110
|
|
103
111
|
# Iterate through all files
|
@@ -111,18 +119,28 @@ Dir[inputDir.chomp('/') + '/*.pdf'].sort.each do |file|
|
|
111
119
|
end
|
112
120
|
|
113
121
|
metadata = readMetadata(file)
|
122
|
+
|
123
|
+
# The author information is used to create a subdirectory
|
124
|
+
# where all the files will end up in.
|
114
125
|
if metadata['author'] and not metadata['author'].empty?
|
115
|
-
author = metadata['author'].gsub(' ','_').gsub('.','_')
|
126
|
+
author = metadata['author'].gsub(' ','_').gsub('.','_').gsub('&','').gsub('__','_')
|
116
127
|
I18n.enforce_available_locales = false # Serialize special characters
|
117
128
|
author = I18n.transliterate(author).downcase
|
118
129
|
folderdestination = destination.chomp('/') + '/' + author
|
119
130
|
|
120
|
-
|
121
|
-
|
122
|
-
|
131
|
+
if not File.directory?(folderdestination)
|
132
|
+
|
133
|
+
# Do nothing when it's a dry-run
|
134
|
+
if opt_dryrun
|
135
|
+
logenable ? $logger.info("Dryrun: Folder '#{folderdestination}' has been created."): ''
|
136
|
+
else
|
137
|
+
FileUtils.mkdir_p(folderdestination)
|
138
|
+
logenable ? $logger.info("Folder '#{folderdestination}' has been created."): ''
|
139
|
+
end
|
140
|
+
|
123
141
|
end
|
124
142
|
|
125
|
-
filedestination
|
143
|
+
filedestination = destination.chomp('/') + '/' + author + '/' + Pathname.new(file).basename.to_s
|
126
144
|
|
127
145
|
|
128
146
|
# Final check before touching the filesystem
|
@@ -130,15 +148,28 @@ Dir[inputDir.chomp('/') + '/*.pdf'].sort.each do |file|
|
|
130
148
|
|
131
149
|
# Move/Copy the file
|
132
150
|
if copyAction
|
133
|
-
opt_dryrun
|
134
|
-
|
151
|
+
if opt_dryrun
|
152
|
+
logenable ? $logger.info("Dryrun: File copied '#{file}' => '#{filedestination}'") : ''
|
153
|
+
else
|
154
|
+
FileUtils.cp(file, filedestination)
|
155
|
+
logenable ? $logger.info("File copied '#{file}' => '#{filedestination}'") : ''
|
156
|
+
end
|
157
|
+
|
135
158
|
else
|
136
|
-
|
137
|
-
|
159
|
+
|
160
|
+
if opt_dryrun
|
161
|
+
logenable ? $logger.info("Dryrun: File moved '#{file}' => '#{filedestination}'") : ''
|
162
|
+
else
|
163
|
+
FileUtils.mv(file,filedestination)
|
164
|
+
logenable ? $logger.info("File moved '#{file}' => '#{filedestination}'") : ''
|
165
|
+
end
|
166
|
+
|
138
167
|
end
|
139
168
|
|
140
169
|
else
|
170
|
+
|
141
171
|
logenable ? $logger.warn("File '#{filedestination}' already exists. Ignoring.") : ''
|
172
|
+
|
142
173
|
end
|
143
174
|
else
|
144
175
|
logenable ? $logger.warn("Missing tag 'Author' for file '#{file}'. Skipping.") : (puts "Missing tag 'Author' for file '#{file}'. Skipping")
|
data/lib/pdfmd.rb
CHANGED
@@ -59,7 +59,7 @@ require "i18n"
|
|
59
59
|
require 'pathname'
|
60
60
|
require 'logger'
|
61
61
|
|
62
|
-
VERSION = '1.6.
|
62
|
+
VERSION = '1.6.1'
|
63
63
|
|
64
64
|
# Include general usage methods
|
65
65
|
require_relative('pdfmd/methods.rb')
|
@@ -346,10 +346,7 @@ class DOC < Thor
|
|
346
346
|
|
347
347
|
Default: enabled.
|
348
348
|
|
349
|
-
[*
|
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`.
|
351
|
-
|
352
|
-
[*logfilepath|p*]
|
349
|
+
[*logfile|p*]
|
353
350
|
\x5 Set an alternate path for the logfile. If not path is chosen, the logfile
|
354
351
|
is being created in the current working directory as `pdfmd.log`.
|
355
352
|
|
@@ -395,13 +392,9 @@ class DOC < Thor
|
|
395
392
|
[*log*]
|
396
393
|
\x5 Enables (true) or disables (false) logging.
|
397
394
|
|
398
|
-
[*
|
395
|
+
[*logfile*]
|
399
396
|
\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.
|
400
397
|
|
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
|
-
|
405
398
|
Default is the current working directory with the filename `pdfmd.log`
|
406
399
|
|
407
400
|
[*interactive*]
|
@@ -420,7 +413,7 @@ class DOC < Thor
|
|
420
413
|
method_option :destination, :aliases => '-d', :required => false, :type => :string, :desc => 'Defines the output directory'
|
421
414
|
method_option :copy, :aliases => '-c', :required => false, :type => :boolean, :desc => 'Copy files instead of moving them'
|
422
415
|
method_option :log, :aliases => '-l', :required => false, :type => :boolean, :desc => 'Enable/Disable creation of log files'
|
423
|
-
method_option :
|
416
|
+
method_option :logfile, :aliases => '-p', :required => false, :type => :string, :desc => 'Change the default logfile path'
|
424
417
|
method_option :interactive, :aliases => '-i', :required => false, :type => :boolean, :desc => 'Enable/Disable interactive sorting'
|
425
418
|
method_option :dryrun, :aliases => '-n', :required => false, :type => :boolean, :desc => 'Run without changing something'
|
426
419
|
def sort(inputDir)
|
@@ -429,7 +422,7 @@ class DOC < Thor
|
|
429
422
|
ENV['PDFMD_DESTINATION'] = options[:destination].to_s
|
430
423
|
ENV['PDFMD_COPY'] = options[:copy].to_s
|
431
424
|
ENV['PDFMD_LOG'] = options[:log].to_s
|
432
|
-
ENV['PDFMD_LOGFILEPATH'] = options[:
|
425
|
+
ENV['PDFMD_LOGFILEPATH'] = options[:logfile].to_s
|
433
426
|
ENV['PDFMD_INTERACTIVE'] = options[:interactive].to_s
|
434
427
|
ENV['PDFMD_DRYRUN'] = options['dryrun'].to_s
|
435
428
|
ENV['PDFMD'] = __FILE__
|
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.6.
|
4
|
+
version: 1.6.1
|
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-04-
|
11
|
+
date: 2015-04-12 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: ! " Managing the common pdf metadata values and renaming the pdf file
|
94
|
+
accordingly.\n Sets common tags like 'author', 'createdate', 'title', 'subject'
|
95
|
+
and 'keywords'\n and re-uses them for renaming the file with to a human-readable
|
96
|
+
identifier.\n"
|
97
97
|
email: pdfmd@micronarrativ.org
|
98
98
|
executables:
|
99
99
|
- pdfmd
|
100
100
|
extensions: []
|
101
101
|
extra_rdoc_files: []
|
102
102
|
files:
|
103
|
-
-
|
103
|
+
- .gitignore
|
104
104
|
- CHANGELOG.md
|
105
105
|
- LICENSE
|
106
106
|
- README.md
|
@@ -137,18 +137,18 @@ require_paths:
|
|
137
137
|
- lib
|
138
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
139
139
|
requirements:
|
140
|
-
- -
|
140
|
+
- - ! '>='
|
141
141
|
- !ruby/object:Gem::Version
|
142
142
|
version: '0'
|
143
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
144
|
requirements:
|
145
|
-
- -
|
145
|
+
- - ! '>='
|
146
146
|
- !ruby/object:Gem::Version
|
147
147
|
version: '0'
|
148
148
|
requirements:
|
149
|
-
-
|
149
|
+
- ! '[exiftools](http://www.sno.phy.queensu.ca/~phil/exiftool/)'
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
151
|
+
rubygems_version: 2.4.6
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: pdfmd - pdf-meta-data management
|