Module: Photein

Defined in:
lib/photein.rb,
lib/photein/image.rb,
lib/photein/video.rb,
lib/photein/config.rb,
lib/photein/logger.rb,
lib/photein/version.rb,
lib/photein/media_file.rb

Defined Under Namespace

Classes: Config, Image, Logger, MediaFile, Video

Constant Summary collapse

VERSION =
'0.1.5'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject



10
11
12
# File 'lib/photein/logger.rb', line 10

def logger
  @logger ||= Photein::Logger
end

Class Method Details

.runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/photein.rb', line 12

def run
  [Photein::Image, Photein::Video].each do |media_type|
    # Why not use Dir.glob? It refuses to do case-insensitive matching on Linux
    ftype_regex = /(#{media_type::SUPPORTED_FORMATS.join('|').gsub('.', '\.')})$/i

    Pathname(Photein::Config.source)
      .join(Photein::Config.recursive ? '**' : '', '*')
      .then(&Dir.method(:glob)).sort
      .select { |file| file.match?(ftype_regex) }
      .map(&media_type.method(:new))
      .each(&:import)
  end
end