Module: PhTools

Defined in:
lib/phtools/error.rb,
lib/phls.rb,
lib/phmove.rb,
lib/phevent.rb,
lib/phtools.rb,
lib/phbackup.rb,
lib/phfixdto.rb,
lib/phfixfmd.rb,
lib/phrename.rb,
lib/phtagset.rb,
lib/phgettags.rb,
lib/phtools/runner.rb,
lib/phtools/ph_file.rb,
lib/phtools/version.rb

Overview

© ANB Andrew Bizyaev

Defined Under Namespace

Classes: Error, ExiftoolTagger, PhFile, Phbackup, Phevent, Phfixdto, Phfixfmd, Phgettags, Phls, Phmove, Phrename, Phtagset, Runner

Constant Summary collapse

FILE_TYPE_IMAGE_NORMAL =

media type constants

%w[jpg jpeg tif tiff png].freeze
FILE_TYPE_IMAGE_RAW =
%w[orf arw dng].freeze
FILE_TYPE_IMAGE =
FILE_TYPE_IMAGE_NORMAL + FILE_TYPE_IMAGE_RAW
FILE_TYPE_VIDEO =
%w[avi mp4 mpg mts dv mov mkv m2t m2ts 3gp].freeze
FILE_TYPE_AUDIO =
%w[wav].freeze
VERSION =
'0.14.0'

Class Method Summary collapse

Class Method Details

.aboutObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/phtools.rb', line 17

def self.about
  about = <<TEXT
phtools v#{VERSION} is a bundle of small CLI tools for arranging, renaming, tagging
of the photo and video files. Helps to keep your photo-video assets in order.
Please run phtools in a terminal via CLI commands:
  phls\t(#{Phls.about}),
  phmove\t(#{Phmove.about}),
  phbackup\t(#{Phbackup.about}),
  phrename\t(#{Phrename.about}),
  phevent\t(#{Phevent.about}),
  phfixdto\t(#{Phfixdto.about}),
  phfixfmd\t(#{Phfixfmd.about}),
  phgettags\t(#{Phgettags.about}),
  phtagset\t(#{Phtagset.about}).
For more information run these commands with -h option.
General info about phtools usage see at https://github.com/AndrewBiz/phtools.git
TEXT
  about
end

.debugObject



12
13
14
# File 'lib/phtools/error.rb', line 12

def self.debug
  @debug
end

.debug=(val) ⇒ Object



8
9
10
# File 'lib/phtools/error.rb', line 8

def self.debug=(val)
  @debug = val
end

.drill_down_error(e, level, prefix) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/phtools/error.rb', line 16

def self.drill_down_error(e, level, prefix)
  return if e.nil?
  STDERR.puts "#{prefix}: CAUSE#{level}: #{e.class} - #{e.message}"
  e.backtrace.each do |b|
    STDERR.puts "#{prefix}: CAUSE#{level} BACKTRACE: #{b}"
  end
  drill_down_error(e.cause, level + 1, prefix)
end

.puts_error(msg, e = nil) ⇒ Object



25
26
27
28
29
# File 'lib/phtools/error.rb', line 25

def self.puts_error(msg, e = nil)
  prefix = File.basename($PROGRAM_NAME, '.rb')
  STDERR.puts "#{prefix}: #{msg}"
  drill_down_error(e, 0, prefix) if @debug
end