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

#after_conjure!Object



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

def after_conjure!
  FileUtils.mv File.join(work_dir, 'content'), work_dir+'.content'
  Dir.rmdir work_dir
  FileUtils.mv work_dir+'.content', work_dir
end

#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 'content', 'w' do |outf|
    outf.write( open(url).read )
  end
  @conjured_checksum = Digest::SHA256.file('content').hexdigest
  @conjured_filesize = File.size('content')
  
end

#conjure_commit_messageObject



37
38
39
40
41
# File 'lib/vendorificator/vendor/download.rb', line 37

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



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

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