Module: Pulse::Downloader::FileDownloader
- Included in:
- Client
- Defined in:
- lib/pulse/downloader/file_downloader.rb
Instance Method Summary collapse
- #compute_hash_of(data) ⇒ Object
-
#download(file_path, progress_bar = nil) ⇒ Object
save_path and verify_ssl are defined in client.rb.
- #fetch_save_paths ⇒ Object
Instance Method Details
#compute_hash_of(data) ⇒ Object
39 40 41 |
# File 'lib/pulse/downloader/file_downloader.rb', line 39 def compute_hash_of(data) { data: data }.hash end |
#download(file_path, progress_bar = nil) ⇒ Object
save_path and verify_ssl are defined in client.rb
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/pulse/downloader/file_downloader.rb', line 5 def download(file_path, =nil) raise "save_path is undefined" if save_data && save_path == '' return if file_path_in_file_list?(file_path) # skip downloading the file @start_time = get_micro_second_time file_data = HTTParty.get( escape(compute_file_link(file_path)), verify: verify_ssl ) @end_time = get_micro_second_time if report_time print_time() end if save_data File.open(compute_save_path(file_path), 'wb') do |file| file.write(file_data.body) end return true if save_and_dont_return end file_data end |
#fetch_save_paths ⇒ Object
33 34 35 36 37 |
# File 'lib/pulse/downloader/file_downloader.rb', line 33 def fetch_save_paths fetch_file_paths.map do |file_path| "#{save_path}/#{compute_filename(file_path)}" end end |