Class: DOC
- Inherits:
-
Thor
- Object
- Thor
- DOC
- Defined in:
- lib/run.rb
Overview
Thor class
Instance Method Summary collapse
- #__print_createdate ⇒ Object
- #__print_version ⇒ Object
- #clean(*filename) ⇒ Object
- #config(subcommand = '') ⇒ Object
- #edit(*filename) ⇒ Object
- #rename(*filename) ⇒ Object
- #show(*filename) ⇒ Object
- #sort(input) ⇒ Object
- #stat(input) ⇒ Object
Instance Method Details
#__print_createdate ⇒ Object
279 280 281 282 |
# File 'lib/run.rb', line 279 def __print_createdate = YAML.load(`gem specification pdfmd metadata`) puts ['revision'] end |
#__print_version ⇒ Object
273 274 275 |
# File 'lib/run.rb', line 273 def __print_version puts VERSION end |
#clean(*filename) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/run.rb', line 78 def clean(*filename) filename.each do |current_file| # Skip non-pdf documents ! File.extname(current_file).match(/\.pdf/) ? next : '' pdfdoc = Pdfmdclean.new current_file pdfdoc. = [:tags] pdfdoc.run # Unset pdfdoc = '' end end |
#config(subcommand = '') ⇒ Object
101 102 103 104 105 106 |
# File 'lib/run.rb', line 101 def config(subcommand = '') pdfdoc = Pdfmdconfig.new '' puts pdfdoc.show_config subcommand end |
#edit(*filename) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/run.rb', line 116 def edit(*filename) filename.each do |current_file| # Skip non-pdf documents ! File.extname(current_file).match(/\.pdf/) ? next : '' pdfdoc = Pdfmdedit.new current_file = pdfdoc.determineValidSetting([:tag],'edit:tags') pdfdoc.opendoc = pdfdoc.determineValidSetting([:opendoc], 'edit:opendoc') pdfdoc.pdfviewer = pdfdoc.determineValidSetting(nil, 'edit:pdfviewer') pdfdoc. pdfdoc. pdfdoc. current_file # If the file shall be renamed at the same time, trigger the other task if pdfdoc.determineValidSetting([:rename], 'edit:rename') #rename filename pdfdoc.log('info', 'Running rename command.') rename current_file end # Unset the object pdfdoc = '' end end |
#rename(*filename) ⇒ Object
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 |
# File 'lib/run.rb', line 244 def rename(*filename) filename.each do |current_file| # Skip non-pdf documents ! File.extname(current_file).match(/\.pdf/) ? next : '' pdfdoc = Pdfmdrename.new current_file pdfdoc.dryrun = pdfdoc.determineValidSetting([:dryrun],'rename:dryrun') pdfdoc.allkeywords = pdfdoc.determineValidSetting([:allkeywords],'rename:allkeywords') pdfdoc.outputdir = pdfdoc.determineValidSetting([:outputdir], 'rename:outputdir') if nrkeywords = pdfdoc.determineValidSetting([:nrkeywords], 'rename:nrkeywords' ) pdfdoc.nrkeywords = nrkeywords end pdfdoc.copy = pdfdoc.determineValidSetting([:copy], 'rename:copy') pdfdoc.rename # Unset pdfdoc = '' end end |
#show(*filename) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/run.rb', line 52 def show(*filename) filename.each do |current_file| # Skip non-pdf documents ! File.extname(current_file).match(/\.pdf/) ? next : '' pdfdoc = Pdfmdshow.new current_file format = pdfdoc.determineValidSetting([:format], 'show:format') show_filename = pdfdoc.determineValidSetting([:includepdf], 'show:includepdf') = pdfdoc.determineValidSetting([:tag], 'show:tags') pdfdoc.set_outputformat format pdfdoc.show_filename show_filename pdfdoc. puts pdfdoc. pdfdoc = '' end end |
#sort(input) ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/run.rb', line 205 def sort(input) if File.file?(input) pdfdoc = Pdfmdsort.new input pdfdoc.copy = pdfdoc.determineValidSetting([:copy], 'sort:copy') pdfdoc.interactive = pdfdoc.determineValidSetting([:interactive], 'sort:interactive') pdfdoc.destination = pdfdoc.determineValidSetting([:destination], 'sort:destination') pdfdoc.overwrite = pdfdoc.determineValidSetting([:overwrite], 'sort:overwrite') pdfdoc.dryrun = pdfdoc.determineValidSetting([:dryrun], 'sort:dryrun') pdfdoc.sort else # Run the actions for all files Dir.glob(input.chomp + '/*.pdf').each do |filename| pdfdoc = Pdfmdsort.new filename pdfdoc.copy = pdfdoc.determineValidSetting([:copy], 'sort:copy') pdfdoc.interactive = pdfdoc.determineValidSetting([:interactive], 'sort:interactive') pdfdoc.destination = pdfdoc.determineValidSetting([:destination], 'sort:destination') pdfdoc.overwrite = pdfdoc.determineValidSetting([:overwrite], 'sort:overwrite') pdfdoc.dryrun = pdfdoc.determineValidSetting([:dryrun], 'sort:dryrun') pdfdoc.sort end end end |
#stat(input) ⇒ Object
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/run.rb', line 154 def stat(input) = Hash.new currentOutput = Hash.new if File.file?(input) puts 'Input is a single file.' puts 'n.a.y.' else # Iterate through all Files an collect the metadata recursive = [:recursive] ? '/**' : '' # Count the number of files quickly to show an overview # nooFiles = numberOfFiles nooFiles = Dir[File.join(input.chomp, recursive, '*.pdf')].count { |file| File.file?(file) } currentNooFiles = 0 Dir.glob("#{input.chomp}#{recursive}/*.pdf").each do |filename| # Print percentage currentNooFiles = currentNooFiles + 1 percentage = 100 / nooFiles * currentNooFiles print "\r Status: #{percentage} % of #{nooFiles} files processed. " pdfdoc = Pdfmd.new filename = {} currentOutput[File.basename(filename)] = pdfdoc..to_s pdfdoc = nil end puts '' puts '' pdfstat = Pdfmdstat.new(currentOutput) pdfstat. [:tags] pdfstat. end end |