module Adri
Constants
- DEFAULT_PATH_FORMAT
- EXTENSIONS
- GEOCODER_LANGUAGE
- GEOCODER_TIMEOUT
- GEOCODE_MAX_DELAY
- LOCATION_ADDRESS_TYPES
- LOCATION_CACHE_SCALE
- VERSION
Public Class Methods
expand_paths(paths, verbose)
click to toggle source
This is necessary to support both files and directories as paths. It also performs some basic sanity checks.
# File bin/adri, line 287 def self.expand_paths(paths, verbose) glob_pattern = File.join('**', "*.{#{EXTENSIONS.join(',')}}") Enumerator.new do |y| paths.each do |path| file_paths = if FileTest.directory?(path) Dir.glob(File.join(path, glob_pattern)).sort elsif !File.exist?(path) puts "Missing #{path}" if verbose elsif !FileTest.file?(path) || FileTest.symlink?(path) puts "Not a file #{path}" if verbose elsif !EXTENSIONS.include?(File.extname(path).delete('.')) if verbose puts "File extension not one of: #{EXTENSIONS.join(', ')}" end else [path] end || [] file_paths.each do |file_path| y << file_path end end end end
parse_args()
click to toggle source
# File bin/adri, line 245 def self.parse_args Slop.parse do |o| o.banner = "usage: #{$PROGRAM_NAME} [options] <path>..." o.string( '-p', '--prefix', 'Place everything under this path (default: photo parent directory)' ) o.string( '-f', '--path-format', 'Format path with strftime and %{location} (default: ' \ "#{DEFAULT_PATH_FORMAT})", default: DEFAULT_PATH_FORMAT ) o.string( '--api-key', 'Google Maps API key (default: $GOOGLE_API_KEY)', default: ENV['GOOGLE_API_KEY'] ) o.bool('--run', 'Perform changes instead of a dry run') o.bool('-q', '--quiet', 'Do not print operations') o.on('--version', 'Print program version') do puts [$PROGRAM_NAME, VERSION].join(' ') exit end o.on('-h', '--help', 'Print help text') do puts o exit end end end