Sha256: 23a3f521067af33a9911c62663776042c51448ced9f64bbab41ca83d1ff61d2a

Contents?: true

Size: 901 Bytes

Versions: 4

Compression:

Stored size: 901 Bytes

Contents

module Abrizer
  class Cleaner

    include FilepathHelpers

    def initialize(filename, output_dir=nil)
      @filename = filename
      @output_directory = output_dir
      @adaptations = Abrizer::AdaptationFinder.new(@filename).adaptations
    end

    def clean
      delete_adaptations(@adaptations)
      clean_audio_file
      remove_pass1_log_files
    end

    def delete_adaptations(adapts)
      adapts.map do |adaptation|
        filepath = adaptation.filepath_fragmented(@filename, output_directory)
        FileUtils.rm filepath if File.exist? filepath
      end
    end

    def clean_audio_file
      FileUtils.rm audio_filepath_fragmented if File.exist? audio_filepath_fragmented
    end

    def remove_pass1_log_files
      glob = File.join output_directory, "ffmpeg2pass*"
      Dir.glob(glob).each do |log_filepath|
        FileUtils.rm log_filepath
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
abrizer-0.4.0 lib/abrizer/cleaner.rb
abrizer-0.3.0 lib/abrizer/cleaner.rb
abrizer-0.2.0 lib/abrizer/cleaner.rb
abrizer-0.1.0 lib/abrizer/cleaner.rb