pdfmd 2.3.5 → 2.4.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: 813b0ecd46d44e57d65eb8b28de7805876b1df54
4
- data.tar.gz: a218ccc83880d0cf83469c8ed5fcc75dcdd0fda5
3
+ metadata.gz: 014584f51b2c90eed42cb65024504d2d9ebf1b81
4
+ data.tar.gz: 0618a7ea2c6e87cf750440979e306db7b99f07ae
5
5
  SHA512:
6
- metadata.gz: e5e3701be0348417b1e9b4ea5a33e2bec55147209c233b724707cee6437e276162a733dcd65e8a570b49ea9ae9631db29ab095cc7a5cc6a64bfae4b15c24611c
7
- data.tar.gz: 3c7538e7d397dd948f687c1933217552f4722c57a5b53d5e53dcada0a88e86ae2bb1a6914a7ba4c842794cae3dd430027ec9f6e26c3ff7c16d25d34460423d87
6
+ metadata.gz: 25308020f8ccaa6401d75ee8baae3c7c6acb0eb81ecd431d6ab917228db2993fc8cee1e070ae611c4796ab27484676ab0747458fc1934881537e4f8f7c396d96
7
+ data.tar.gz: 3a5168b63cea744d419e514f5d48296cbd2e7436fe2325ba7d888db572140a9d6ac98046ee8c27472971984f08fc117b19a14420dda92b3c8932e890c319ef78
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # pdfmd
2
- Pdf Meta data managing script.
2
+ Pdf metadata managing script.
3
3
 
4
4
  I use the script `pdfmd.rb`/pdfmetadata (with a slightly different name) to manage my PDF documents and keep the naming in line.
5
5
  Hidden deep in the directory structure of my disks I can quickly find the
@@ -128,6 +128,13 @@ __HINT__: Before you start using the script, make sure you have a backup of your
128
128
  _pdfmd_ recognises if a pdf file is password protected and will ask for the password.
129
129
  A password string can be defined in hiera that will be used per default.
130
130
 
131
+ # Bash completion
132
+
133
+ Pdfmd comes with bash completion. To setup bash completion run the command
134
+
135
+ $ pdfmd init bash_completion
136
+
137
+ This will install a bash completion file. A restart of/new console might be necessary to enable it.
131
138
 
132
139
  # Hiera
133
140
 
data/bin/pdfmd CHANGED
@@ -1,16 +1,16 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'pdfmd'
3
3
  require 'pdfmd/pdfmdstat'
4
+ require 'pdfmd/pdfmdinit'
4
5
  require "thor"
5
6
  require "highline/import"
6
7
  require "fileutils"
7
8
  require "i18n"
8
9
  require 'pathname'
9
10
 
10
- VERSION = '2.3.5'
11
+ VERSION = '2.4.0'
11
12
  NAME = 'pdfmd'
12
13
 
13
- #
14
14
  # Read the content of the long description from an external file
15
15
  #
16
16
  def readLongDesc(filename)
@@ -99,6 +99,24 @@ class DOC < Thor
99
99
  end
100
100
 
101
101
 
102
+ # Initialise something
103
+ #
104
+ #
105
+ desc 'init [COMMAND]', 'Initialise additonal functions'
106
+ long_desc readLongDesc 'pdfmd/long_desc.pdfmdinit.txt'
107
+ method_option :remove, :type => :boolean, :aliases => '-r', :required => false, :lazydefault => 'true'
108
+ def init(subcommand = '')
109
+
110
+ if subcommand == 'bash_completion'
111
+ init_bashcompletion(NAME,VERSION,options[:remove])
112
+ else
113
+ puts 'No command provided. Abort.'
114
+ puts 'Run `$ pdfmd help init` for details.'
115
+ exit 1
116
+ end
117
+
118
+ end
119
+
102
120
  # Show current settings
103
121
  #
104
122
  desc 'config', 'Show config defaults'
@@ -298,30 +316,3 @@ end
298
316
 
299
317
  DOC.start
300
318
 
301
- # #
302
- # # Explain fields and Metatags
303
- # # Show information about how they are used.
304
- # #
305
- # desc 'explain','Show more information about usuable Meta-Tags'
306
- # long_desc <<-LONGDESC
307
- # == General
308
- #
309
- # Explain some terms used with the script.
310
- #
311
- # == Example
312
- #
313
- # # Show the available subjects
314
- # \x5>CLI explain
315
- #
316
- # # Show information about the subject 'author'
317
- # \x5>CLI explain author
318
- #
319
- # LONGDESC
320
- # def explain(term='')
321
- #
322
- # ENV['PDFMD_EXPLAIN'] = term
323
- # ENV['PDFMD'] = File.basename(__FILE__)
324
- # require_relative('./pdfmd/explain.rb')
325
- #
326
- # end
327
- #
@@ -0,0 +1,30 @@
1
+ == General
2
+
3
+ Command will setup the environment for pdfmd if executed.
4
+ At this moment only the installation of bash completion file is integrated.
5
+
6
+
7
+
8
+ == Command
9
+
10
+ bash_completion
11
+
12
+ Installs or removes the bash completion file for pdfmd. Existing files will be
13
+ overwritten after a file with the extension '.backup' has been created in the
14
+ same directory.
15
+
16
+ == Parameter
17
+
18
+ --remove, -r
19
+
20
+ Removes the bash completion file. Does not remove any existing backup file.
21
+
22
+ == General example
23
+
24
+ # Install the bash completion file
25
+
26
+ $ pdfmd init bash_completion
27
+
28
+ # Remove the bash completion file
29
+
30
+ $ pdfmd init -r bash_completion
@@ -0,0 +1,194 @@
1
+ # Bash completion file for pdfmd
2
+ # copy to /etc/bash_completion.d to use it
3
+ _pdfmd()
4
+ {
5
+ local cur prev opts tags chapter
6
+ COMPREPLY=()
7
+ cur="${COMP_WORDS[COMP_CWORD]}"
8
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
9
+ chapter="${COMP_WORDS[1]}"
10
+ tags='all author keywords title subject createdate'
11
+
12
+ # The basic options
13
+ opts="edit clean config init rename show sort stat --version --revision"
14
+
15
+ #
16
+ # complete the arguments to some of the basic commands
17
+ #
18
+ case "${chapter}" in
19
+ init)
20
+ case "${prev}" in
21
+ -r|--remove) # Remove
22
+ local parameter='bash_completion'
23
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
24
+ return 0
25
+ ;;
26
+ *)
27
+ local parameter='--remove bash_completion'
28
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
29
+ return 0
30
+ ;;
31
+ esac
32
+ ;;
33
+ edit)
34
+ case "${prev}" in
35
+ -t|--tags) # Define the tags
36
+ local tags='all author keywords title subject createdate'
37
+ COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
38
+ return 0
39
+ ;;
40
+ -r|--rename) # Rename files
41
+ local files=$(ls *.pdf)
42
+ COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
43
+ return 0
44
+ ;;
45
+ -o|--opendoc) # Open the document
46
+ local files=$(ls *.pdf)
47
+ COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
48
+ return 0
49
+ ;;
50
+ 'all') # all tags
51
+ local files="$(find . -maxdepth 1 -type f -iname '*.pdf')"
52
+ COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
53
+ return 0
54
+ ;;
55
+ *)
56
+ local tags="--tags --rename --opendoc $(find . -maxdepth 1 -type f -iname '*.pdf')"
57
+ COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
58
+ return 0
59
+ ;;
60
+ esac
61
+
62
+ ;;
63
+ clean) # Clean some stuff
64
+ case "${prev}" in
65
+ -t|--tags)
66
+ local tags='all author keywords title subject createdate'
67
+ COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
68
+ return 0
69
+ ;;
70
+ all|author|keywords|title|subject|createdate)
71
+ local parameter="$(ls *.pdf)"
72
+ COMPREPLY=( $(compgen -W "${parameter}") )
73
+ return 0
74
+ ;;
75
+
76
+ *)
77
+ local parameter="--tags $(find . -maxdepth 1 -type f -iname '*.pdf')"
78
+ COMPREPLY=( $(compgen -W "${parameter}") )
79
+ return 0
80
+ ;;
81
+ esac
82
+ ;;
83
+ config) # Config pdfmd
84
+ case "${prev}" in
85
+ edit|clean|rename|sort|stat)
86
+ local parameter=''
87
+ COMPREPLY=( $(compgen -W "${parameter}") )
88
+ return 0
89
+ ;;
90
+ *)
91
+ local parameter="clean edit rename sort stat"
92
+ COMPREPLY=( $(compgen -W "${parameter}") )
93
+ return 0
94
+ ;;
95
+ esac
96
+ ;;
97
+ rename) # Rename files
98
+ case "${prev}" in
99
+ -k|--nrkeywords)
100
+ local parameter="3"
101
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
102
+ return 0
103
+ ;;
104
+ -o|--outputdir)
105
+ return 0
106
+ ;;
107
+ *)
108
+ local parameter="--dryrun --allkeywords --nrkeywords --outputdir --copy $(ls *.pdf)"
109
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
110
+ return 0
111
+ ;;
112
+ esac
113
+ ;;
114
+ show) # Show status of files
115
+
116
+ case "${prev}" in
117
+ -t|--tags)
118
+ COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
119
+ return 0
120
+ ;;
121
+ -i|--includepdf)
122
+ local files=$(find . -maxdepth 1 -type f -iname '*.pdf')
123
+ COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
124
+ return 0
125
+ ;;
126
+ -f|--format)
127
+ local format='hash json yaml csv'
128
+ COMPREPLY=( $(compgen -W "${format}" -- ${cur}) )
129
+ return 0
130
+ ;;
131
+ all|author|keywords|title|subject|createdate)
132
+ local files=$(ls *.pdf)
133
+ COMPREPLY=( $(compgen -W "${files}" -- ${cur}) )
134
+ return 0
135
+ ;;
136
+ *)
137
+ local parameter="--tags --format $(find . -maxdepth 1 -type f -iname '*.pdf')"
138
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
139
+ return 0
140
+ ;;
141
+ esac
142
+ ;;
143
+ sort) # Sorting files
144
+ case "$prev" in
145
+ -d|--destination)
146
+ local directories="$(find . -maxdepth 1 -type d)"
147
+ COMPREPLY=( $(compgen -W "${directories}" -- ${cur} ) )
148
+ return 0
149
+ ;;
150
+ *)
151
+ local parameter="--destination --copy --overwrite --dryrun --interactive --typo $(find . -maxdepth 1 -type f -iname '*.pdf')"
152
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
153
+ return 0
154
+ ;;
155
+ esac
156
+
157
+ # Default output
158
+ local parameter="--destination --copy --overwrite --dryrun --typo $(find . -maxdepth 1 -type f -iname '*.pdf')"
159
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
160
+ return 0
161
+
162
+ ;;
163
+ stat)
164
+
165
+ case "${prev}" in
166
+ -r|--recursive)
167
+ local parameter="$(find . -maxdepth 1 -type d)"
168
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
169
+ return 0
170
+ ;;
171
+ -t|--tags)
172
+ local tags='all author keywords title subject createdate'
173
+ COMPREPLY=( $(compgen -W "${tags}" -- ${cur}) )
174
+ return 0
175
+ ;;
176
+ *)
177
+ local parameter="--recursive --tags $(find . -maxdepth 1 -type d)"
178
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
179
+ return 0
180
+ ;;
181
+ esac
182
+
183
+ # Default output
184
+ local parameter="-t -ri $(find . -maxdepth 1 -type d)"
185
+ COMPREPLY=( $(compgen -W "${parameter}" -- ${cur}) )
186
+ return 0
187
+ ;;
188
+ *)
189
+ ;;
190
+ esac
191
+
192
+ COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
193
+ }
194
+ complete -o default -F _pdfmd pdfmd
@@ -0,0 +1,8 @@
1
+ # file: pdfmdinit.rb
2
+ # Logik to setup environment
3
+ require_relative './pdfmdmethods.rb'
4
+
5
+ #class Pdfmdinit
6
+ # puts Dir.pwd()
7
+ #end
8
+
@@ -127,3 +127,48 @@ module Pdfmdmethods
127
127
  end # End of queryHiera
128
128
 
129
129
  end
130
+
131
+ #
132
+ # Initializing or removing the bash_completion file
133
+ def init_bashcompletion(name, version, remove = false)
134
+
135
+ # Find the current local path where the original bash completion file might be hiding.
136
+ paths = [
137
+ "#{File.dirname(File.expand_path($0))}../lib",
138
+ "#{Gem.dir}/gems/#{name}-#{version}/lib",
139
+ ]
140
+ bash_completion_destination = '/etc/bash_completion.d/pdfmd.bash'
141
+ bash_completion_destination_backup = bash_completion_destination + '.backup'
142
+
143
+ paths.each do |value|
144
+ bash_completion_source = value + '/' + name + '/pdfmd.bash'
145
+ if File.exists?(bash_completion_source)
146
+
147
+ if !remove
148
+
149
+ # Create a backup file when a file is found
150
+ if File.exists?(bash_completion_destination)
151
+ puts 'Existing file found.Taking backup.'
152
+ `sudo cp #{bash_completion_destination} #{bash_completion_destination_backup}`
153
+ end
154
+ puts 'Installing ' + bash_completion_destination
155
+ `sudo cp #{bash_completion_source} #{bash_completion_destination}`
156
+ else
157
+
158
+ if File.exists?(bash_completion_destination)
159
+ puts 'Removing ' + bash_completion_destination
160
+ `sudo rm #{bash_completion_destination}`
161
+ if $?.exitstatus == 0
162
+ puts 'File successfully removed.'
163
+ end
164
+ else
165
+ puts bash_completion_destination + ' not found.'
166
+ end
167
+
168
+ end
169
+
170
+ end
171
+ end
172
+
173
+ end
174
+
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.3.5
4
+ version: 2.4.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: 2016-06-07 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -147,14 +147,17 @@ files:
147
147
  - lib/pdfmd/long_desc.pdfmdconfig.txt
148
148
  - lib/pdfmd/long_desc.pdfmdedit.txt
149
149
  - lib/pdfmd/long_desc.pdfmdexplain.txt
150
+ - lib/pdfmd/long_desc.pdfmdinit.txt
150
151
  - lib/pdfmd/long_desc.pdfmdrename.txt
151
152
  - lib/pdfmd/long_desc.pdfmdshow.txt
152
153
  - lib/pdfmd/long_desc.pdfmdsort.txt
153
154
  - lib/pdfmd/long_desc.pdfmdstat.txt
154
155
  - lib/pdfmd/methods.rb
156
+ - lib/pdfmd/pdfmd.bash
155
157
  - lib/pdfmd/pdfmdclean.rb
156
158
  - lib/pdfmd/pdfmdconfig.rb
157
159
  - lib/pdfmd/pdfmdedit.rb
160
+ - lib/pdfmd/pdfmdinit.rb
158
161
  - lib/pdfmd/pdfmdmethods.rb
159
162
  - lib/pdfmd/pdfmdrename.rb
160
163
  - lib/pdfmd/pdfmdshow.rb
@@ -171,8 +174,8 @@ homepage: https://github.com/Micronarrativ/ruby-pmd
171
174
  licenses:
172
175
  - MIT
173
176
  metadata:
174
- created: '2016-06-07 20:15:26'
175
- revision: '20160607201526'
177
+ created: '2016-08-20 18:26:13'
178
+ revision: '20160820182613'
176
179
  post_install_message: ". Run `pdfmd` to see the command help."
177
180
  rdoc_options: []
178
181
  require_paths:
@@ -190,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
193
  requirements:
191
194
  - "[exiftools](http://www.sno.phy.queensu.ca/~phil/exiftool/)"
192
195
  rubyforge_project:
193
- rubygems_version: 2.4.6
196
+ rubygems_version: 2.4.8
194
197
  signing_key:
195
198
  specification_version: 4
196
199
  summary: pdfmd - pdf-meta-data management