Class: Vendorificator::Vendor::Download

Inherits:
Vendorificator::Vendor show all
Defined in:
lib/vendorificator/vendor/download.rb

Instance Attribute Summary collapse

Attributes inherited from Vendorificator::Vendor

#args, #block, #environment, #name, #segment

Instance Method Summary collapse

Methods inherited from Vendorificator::Vendor

#===, arg_reader, #before_conjure!, #compute_dependencies!, #git_add_extra_paths, #group, #initialize, #inspect, #metadata, #version

Constructor Details

This class inherits a constructor from Vendorificator::Vendor

Instance Attribute Details

#conjured_checksumObject (readonly)

Returns the value of attribute conjured_checksum.



11
12
13
# File 'lib/vendorificator/vendor/download.rb', line 11

def conjured_checksum
  @conjured_checksum
end

#conjured_filesizeObject (readonly)

Returns the value of attribute conjured_filesize.



11
12
13
# File 'lib/vendorificator/vendor/download.rb', line 11

def conjured_filesize
  @conjured_filesize
end

Instance Method Details

#conjure!Object



17
18
19
20
21
22
23
24
25
# File 'lib/vendorificator/vendor/download.rb', line 17

def conjure!
  say_status :default, :download, url
  File.open name, 'w' do |outf|
    outf.write( open(url).read )
  end
  @conjured_checksum = Digest::SHA256.file(name).hexdigest
  @conjured_filesize = File.size(name)
  
end

#conjure_commit_messageObject



31
32
33
34
35
# File 'lib/vendorificator/vendor/download.rb', line 31

def conjure_commit_message
  rv = "Conjured #{name} from #{url}\nChecksum: #{conjured_checksum}"
  rv << "Version: #{args[:version]}" if args[:version]
  rv
end

#pathObject



13
14
15
# File 'lib/vendorificator/vendor/download.rb', line 13

def path
  args[:path] || group
end

#upstream_versionObject



27
28
29
# File 'lib/vendorificator/vendor/download.rb', line 27

def upstream_version
  conjured_checksum || Digest::SHA256.hexdigest( open(url).read )
end