class DOC
Thor class
Public Instance Methods
__print_createdate()
click to toggle source
# File lib/run.rb, line 279 def __print_createdate metadata = YAML.load(`gem specification pdfmd metadata`) puts metadata['revision'] end
__print_version()
click to toggle source
# File lib/run.rb, line 273 def __print_version puts VERSION end
clean(*filename)
click to toggle source
# 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 = options[:tags] pdfdoc.run # Unset pdfdoc = '' end end
config(subcommand = '')
click to toggle source
# File lib/run.rb, line 101 def config(subcommand = '') pdfdoc = Pdfmdconfig.new '' puts pdfdoc.show_config subcommand end
edit(*filename)
click to toggle source
# 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 tags = pdfdoc.determineValidSetting(options[:tag],'edit:tags') pdfdoc.opendoc = pdfdoc.determineValidSetting(options[:opendoc], 'edit:opendoc') pdfdoc.pdfviewer = pdfdoc.determineValidSetting(nil, 'edit:pdfviewer') pdfdoc.set_tags tags pdfdoc.update_tags pdfdoc.write_tags current_file # If the file shall be renamed at the same time, trigger the other task if pdfdoc.determineValidSetting(options[:rename], 'edit:rename') #rename filename pdfdoc.log('info', 'Running rename command.') rename current_file end # Unset the object pdfdoc = '' end end
rename(*filename)
click to toggle source
# 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(options[:dryrun],'rename:dryrun') pdfdoc.allkeywords = pdfdoc.determineValidSetting(options[:allkeywords],'rename:allkeywords') pdfdoc.outputdir = pdfdoc.determineValidSetting(options[:outputdir], 'rename:outputdir') if nrkeywords = pdfdoc.determineValidSetting(options[:nrkeywords], 'rename:nrkeywords' ) pdfdoc.nrkeywords = nrkeywords end pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'rename:copy') pdfdoc.rename # Unset pdfdoc = '' end end
show(*filename)
click to toggle source
# 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(options[:format], 'show:format') show_filename = pdfdoc.determineValidSetting(options[:includepdf], 'show:includepdf') show_tags = pdfdoc.determineValidSetting(options[:tag], 'show:tags') pdfdoc.set_outputformat format pdfdoc.show_filename show_filename pdfdoc.set_tags show_tags puts pdfdoc.show_metatags pdfdoc = '' end end
sort(input)
click to toggle source
# File lib/run.rb, line 205 def sort(input) if File.file?(input) pdfdoc = Pdfmdsort.new input pdfdoc.copy = pdfdoc.determineValidSetting(options[:copy], 'sort:copy') pdfdoc.interactive = pdfdoc.determineValidSetting(options[:interactive], 'sort:interactive') pdfdoc.destination = pdfdoc.determineValidSetting(options[:destination], 'sort:destination') pdfdoc.overwrite = pdfdoc.determineValidSetting(options[:overwrite], 'sort:overwrite') pdfdoc.dryrun = pdfdoc.determineValidSetting(options[: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(options[:copy], 'sort:copy') pdfdoc.interactive = pdfdoc.determineValidSetting(options[:interactive], 'sort:interactive') pdfdoc.destination = pdfdoc.determineValidSetting(options[:destination], 'sort:destination') pdfdoc.overwrite = pdfdoc.determineValidSetting(options[:overwrite], 'sort:overwrite') pdfdoc.dryrun = pdfdoc.determineValidSetting(options[:dryrun], 'sort:dryrun') pdfdoc.sort end end end
stat(input)
click to toggle source
# File lib/run.rb, line 154 def stat(input) filemetadata = 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 = options[: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 filemetadata = {} currentOutput[File.basename(filename)] = pdfdoc.metadata.to_s pdfdoc = nil end puts '' puts '' pdfstat = Pdfmdstat.new(currentOutput) pdfstat.tags options[:tags] pdfstat.analyse_metadata end end