Sha256: 0ee46ec7ba861127aaf8f3d3b539fa8530e9861a7cfb9c06745c176a10b4236c

Contents?: true

Size: 875 Bytes

Versions: 2

Compression:

Stored size: 875 Bytes

Contents

module Abrizer
  class Cleaner

    include FilepathHelpers

    def initialize(output_dir)
      @output_directory = output_dir
      @adaptations = Abrizer::AdaptationFinder.new(output_directory: @output_directory).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(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

2 entries across 2 versions & 1 rubygems

Version Path
abrizer-0.6.0 lib/abrizer/cleaner.rb
abrizer-0.5.0 lib/abrizer/cleaner.rb