class Bundler::Downloadfile
Constants
- HELP
- PLATFORM_OS
- SUBCOMMANDS
- SUPPORTED_OPERATING_SYSTEMS
Attributes
file[R]
file_content[R]
gem_path[R]
keep_existing[R]
Public Class Methods
new(file, gem_path:, keep_existing: nil, all_operating_systems: nil)
click to toggle source
# File lib/bundler/downloadfile.rb, line 44 def initialize(file, gem_path:, keep_existing: nil, all_operating_systems: nil) @file = file @file_content = File.read(@file) @gem_path = gem_path @keep_existing = keep_existing @all_operating_systems = all_operating_systems @downloads = [] interpret end
Public Instance Methods
clear()
click to toggle source
# File lib/bundler/downloadfile.rb, line 76 def clear puts "Clearing #{file}" @downloads.each(&:delete) end
Also aliased as: clean
download(uri, to:'', os: nil)
click to toggle source
# File lib/bundler/downloadfile.rb, line 54 def download(uri, to:'', os: nil) directory = File.join(@gem_path, to) FileUtils.mkdir_p(directory) os = SUPPORTED_OPERATING_SYSTEMS.detect {|system| os.to_s.downcase == system} options = {os: os} options['--keep_existing'] = nil if @keep_existing @downloads << ::Download::Object.new( url: uri, path: directory, options: options ) end
help()
click to toggle source
# File lib/bundler/downloadfile.rb, line 82 def help puts HELP end
Also aliased as: usage
interpret()
click to toggle source
# File lib/bundler/downloadfile.rb, line 67 def interpret instance_eval(@file_content) end
list()
click to toggle source
# File lib/bundler/downloadfile.rb, line 87 def list puts "Listing #{file}" puts @file_content end
show()
click to toggle source
# File lib/bundler/downloadfile.rb, line 92 def show puts "Showing downloaded files for #{file}" puts '- - -' missing_downloads = false missing_downloads_for_current_platform_os = false @downloads.each do |download| download_file_entry = download.file_path if File.exist?(download_file_entry) puts "Downloaded: #{File.size(download_file_entry)} #{download_file_entry}" else missing_downloads = true missing_downloads_for_current_platform_os = true if download.os == PLATFORM_OS puts "Not downloaded: #{download_file_entry}" end end message = '' if missing_downloads_for_current_platform_os message += "Downloads are missing for the current operating system (#{PLATFORM_OS}). \nRun `bundle download` to download missing files for current operating system (#{PLATFORM_OS}).\n" else message += "All downloads are present for current operating system (#{PLATFORM_OS})." message += " Optionally, run `bundle download --all-operating-systems` to download files for all operating systems.\n" if missing_downloads end puts message puts end
start()
click to toggle source
# File lib/bundler/downloadfile.rb, line 71 def start puts "Downloading #{file}" @downloads.select {|download| @all_operating_systems || download.os.nil? || download.os == PLATFORM_OS }.each(&:start) end