Class: Vendorificator::Vendor::Download
- Inherits:
-
Vendorificator::Vendor
- Object
- Vendorificator::Vendor
- Vendorificator::Vendor::Download
- Defined in:
- lib/vendorificator/vendor/download.rb
Instance Attribute Summary collapse
-
#conjured_checksum ⇒ Object
readonly
Returns the value of attribute conjured_checksum.
Attributes inherited from Vendorificator::Vendor
#args, #block, #environment, #name
Instance Method Summary collapse
- #conjure! ⇒ Object
- #conjure_commit_message ⇒ Object
-
#initialize(environment, name, args = {}, &block) ⇒ Download
constructor
A new instance of Download.
- #path ⇒ Object
- #upstream_version ⇒ Object
Methods inherited from Vendorificator::Vendor
#===, [], arg_reader, #branch_name, #category, #compute_dependencies!, compute_dependencies!, each, #head, #in_branch, #inspect, install!, instances, #merged, #merged_tag, #merged_version, #needed?, #run!, #shell, #status, #tag_message, #tag_name, #tag_name_base, #tagged_sha1, #to_s, #updatable?, #version, #work_dir, #work_subdir
Constructor Details
#initialize(environment, name, args = {}, &block) ⇒ Download
Returns a new instance of Download.
12 13 14 15 16 17 18 19 |
# File 'lib/vendorificator/vendor/download.rb', line 12 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 super(environment, name, args, &block) end |
Instance Attribute Details
#conjured_checksum ⇒ Object (readonly)
Returns the value of attribute conjured_checksum.
10 11 12 |
# File 'lib/vendorificator/vendor/download.rb', line 10 def conjured_checksum @conjured_checksum end |
Instance Method Details
#conjure! ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/vendorificator/vendor/download.rb', line 25 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 |
#conjure_commit_message ⇒ Object
37 38 39 40 41 |
# File 'lib/vendorificator/vendor/download.rb', line 37 def rv = "Conjured #{name} from #{url}\nChecksum: #{conjured_checksum}" rv << "Version: #{args[:version]}" if args[:version] rv end |
#path ⇒ Object
21 22 23 |
# File 'lib/vendorificator/vendor/download.rb', line 21 def path args[:path] || category end |
#upstream_version ⇒ Object
33 34 35 |
# File 'lib/vendorificator/vendor/download.rb', line 33 def upstream_version conjured_checksum || Digest::SHA256.hexdigest( open(url).read ) end |