Class: PKGWizard::DownloadSources
- Defined in:
- lib/pkg-wizard/commands/download_sources.rb
Class Method Summary collapse
Methods inherited from Command
Class Method Details
.download_from_url(url, tmpdir = '.') ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pkg-wizard/commands/download_sources.rb', line 57 def self.download_from_url(url, tmpdir = '.') uri = URI.parse(url) remote_pkg = uri.path.split('/').last d = StreamingDownloader.new f = "#{tmpdir}/#{remote_pkg}" tmpfile = File.new(f, 'w') d.download!(url, tmpfile) tmpfile.close f end |
.perform ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/pkg-wizard/commands/download_sources.rb', line 31 def self.perform cmd = DownloadSources.new cmd. = "\nUsage: pkgwiz download-sources (options)\n\n" cmd. spec = nil if cmd.config[:spec] spec = PKGWizard::SpecFile.parse cmd.config[:spec] else files = Dir["*.spec"] if files.size > 1 $stderr.puts 'Multiple spec files found in current dir. Use --spec option.' exit 1 elsif files.empty? $stderr.puts 'No spec files found in current dir. Use --spec option.' exit 1 else spec = PKGWizard::SpecFile.parse files[0] end end define = cmd.config[:define] spec.download_source_files(define) do |s| puts "Downloading #{s}..." end end |