Class: Abrizer::Cleaner

Inherits:
Object
  • Object
show all
Includes:
FilepathHelpers
Defined in:
lib/abrizer/cleaner.rb

Instance Method Summary collapse

Methods included from FilepathHelpers

#adaptations_filepath, #all_media_paths, #audio_filepath, #audio_filepath_fragmented, #basename, #canvas_filepath, #canvas_partial_filepath, #captions_filepath, #data_filepath, #data_partial_filepath, #ffprobe_filepath, #filename_directory, #first_image_filepath, #hlsts_aac_filepath, #hlsts_aac_partial_filepath, #hlsts_filepath, #hlsts_partial_filepath, #mp3_filepath, #mp3_partial_filepath, #mp4_filepath, #mp4_partial_filepath, #mpd_filepath, #mpd_partial_filepath, #output_directory, #output_directory_basename, #poster_filepath, #poster_image_filepath, #poster_partial_filepath, #sprites_filepath, #sprites_partial_filepath, #vp9_filepath, #vp9_partial_filepath, #webvtt_input_filepath

Constructor Details

#initialize(output_dir) ⇒ Cleaner

Returns a new instance of Cleaner.



6
7
8
9
# File 'lib/abrizer/cleaner.rb', line 6

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

Instance Method Details

#cleanObject



11
12
13
14
15
# File 'lib/abrizer/cleaner.rb', line 11

def clean
  delete_adaptations(@adaptations)
  clean_audio_file
  remove_pass1_log_files
end

#clean_audio_fileObject



24
25
26
# File 'lib/abrizer/cleaner.rb', line 24

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

#delete_adaptations(adapts) ⇒ Object



17
18
19
20
21
22
# File 'lib/abrizer/cleaner.rb', line 17

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

#remove_pass1_log_filesObject



28
29
30
31
32
33
# File 'lib/abrizer/cleaner.rb', line 28

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