module Pulse::Downloader::FileChecker
Public Instance Methods
file_path_in_file_list?(file_path)
click to toggle source
# File lib/pulse/downloader/file_checker.rb, line 4 def file_path_in_file_list?(file_path) return false unless drop_exitsing_files_in_path && save_data list_files_in(save_path).include?(compute_save_path(file_path)) end
Private Instance Methods
compute_filename(file_path)
click to toggle source
# File lib/pulse/downloader/file_checker.rb, line 16 def compute_filename(file_path) file_path.scan(/[\/]\S+/).last.split('/').last end
compute_save_path(url)
click to toggle source
# File lib/pulse/downloader/file_checker.rb, line 12 def compute_save_path(url) "#{save_path}/#{compute_filename(url)}".gsub('//', '/').gsub(' ', '') end
list_files_in(path)
click to toggle source
# File lib/pulse/downloader/file_checker.rb, line 20 def list_files_in(path) `ls #{path}`.split("\n").map do |filename| "#{path}/#{filename}".gsub('//', '/') end end