lib/vendorificator/vendor/download.rb in vendorificator-0.2.0 vs lib/vendorificator/vendor/download.rb in vendorificator-0.3.0
- old
+ new
@@ -3,42 +3,46 @@
require 'tempfile'
require 'uri'
require 'vendorificator/vendor'
-class Vendorificator::Vendor::Download < Vendorificator::Vendor
- arg_reader :url
- attr_reader :conjured_checksum
+module Vendorificator
+ class Vendor::Download < Vendor
+ arg_reader :url
+ attr_reader :conjured_checksum
- def initialize(environment, name, args={}, &block)
- no_url_given = !args[:url]
+ def initialize(environment, name, args={}, &block)
+ no_url_given = !args[:url]
- args[:url] ||= name
- name = URI::parse(args[:url]).path.split('/').last if no_url_given
+ args[:url] ||= name
+ name = URI::parse(args[:url]).path.split('/').last if no_url_given
- super(environment, name, args, &block)
- end
+ super(environment, name, args, &block)
+ end
- def path
- args[:path] || category
- end
+ def path
+ args[:path] || category
+ end
- def conjure!
- shell.say_status :download, url
- File.open name, 'w' do |outf|
- outf.write( open(url).read )
+ def conjure!
+ shell.say_status :download, url
+ File.open name, 'w' do |outf|
+ outf.write( open(url).read )
+ end
+ @conjured_checksum = Digest::SHA256.file(name).hexdigest
end
- @conjured_checksum = Digest::SHA256.file(name).hexdigest
- end
- def upstream_version
- conjured_checksum || Digest::SHA256.hexdigest( open(url).read )
- end
+ def upstream_version
+ conjured_checksum || Digest::SHA256.hexdigest( open(url).read )
+ end
- def conjure_commit_message
- rv = "Conjured #{name} from #{url}\nChecksum: #{conjured_checksum}"
- rv << "Version: #{args[:version]}" if args[:version]
- rv
+ def conjure_commit_message
+ rv = "Conjured #{name} from #{url}\nChecksum: #{conjured_checksum}"
+ rv << "Version: #{args[:version]}" if args[:version]
+ rv
+ end
end
- install!
+ class Config
+ register_module :download, Vendor::Download
+ end
end