Module: Dexter

Defined in:
lib/dexter.rb,
lib/dexter/version.rb

Defined Under Namespace

Modules: Matchers

Constant Summary collapse

VERSION =
"0.1.0"

Class Method Summary collapse

Class Method Details

.list_all_files_within_directory(path) ⇒ Object



41
42
43
44
# File 'lib/dexter.rb', line 41

def self.list_all_files_within_directory(path)
  expression = "#{path}/**/*.{#{Dexter.matchers.collect{|m| m::EXTENSIONS}.flatten.join(',')}}"
  Dir.glob(expression)
end

.load_files(files) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/dexter.rb', line 27

def self.load_files(files)
  result = []
  files.each do |file|
    matchers.each do |matcher|
       result << matcher.new(file) if matcher.allowed?(file)
    end
  end
  return result.compact
end

.load_from_directory(path) ⇒ Object



23
24
25
# File 'lib/dexter.rb', line 23

def self.load_from_directory(path)
  self.load_files self.list_all_files_within_directory(path)
end

.matchersObject



37
38
39
# File 'lib/dexter.rb', line 37

def self.matchers
  [Matchers::Video, Matchers::Subtitle]
end

.organize!(input_path, output_path) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dexter.rb', line 8

def self.organize!(input_path, output_path)

  if File.file?(input_path)
    files = self.load_files([input_path])
  else
    files = self.load_from_directory(input_path)
  end

  files.each do |file|
    output_file = file.organize!(output_path)
    puts "Organizing: \"#{file.filename}\" ~> \"#{output_file}\"" if Dexter.verbose
  end

end

.verboseObject



5
# File 'lib/dexter.rb', line 5

def self.verbose; @verbose; end

.verbose=(level) ⇒ Object



6
# File 'lib/dexter.rb', line 6

def self.verbose=(level);@verbose=level;end