Class: Sprout::RemoteFileTarget

Inherits:
FileTarget show all
Defined in:
lib/sprout/remote_file_target.rb

Instance Attribute Summary (collapse)

Attributes inherited from FileTarget

#executables, #libraries, #load_path, #pkg_name, #pkg_version, #platform

Instance Method Summary (collapse)

Methods inherited from FileTarget

#add_executable, #add_library, #initialize, #to_s

Constructor Details

This class inherits a constructor from Sprout::FileTarget

Instance Attribute Details

- (Object) archive_type

Returns the value of attribute archive_type



7
8
9
# File 'lib/sprout/remote_file_target.rb', line 7

def archive_type
  @archive_type
end

- (Object) md5

Returns the value of attribute md5



9
10
11
# File 'lib/sprout/remote_file_target.rb', line 9

def md5
  @md5
end

- (Object) url

Returns the value of attribute url



8
9
10
# File 'lib/sprout/remote_file_target.rb', line 8

def url
  @url
end

Instance Method Details

- (Object) downloaded_file

Do not cache this value…

This response can change over time IF:


 * The downloaded bytes do not match the expected MD5
 * AND the user confirms the prompt that they are OK with this


30
31
32
# File 'lib/sprout/remote_file_target.rb', line 30

def downloaded_file
  File.join(Sprout.cache, pkg_name, "#{md5}.#{archive_type}")
end

- (Object) expand_local_path(path) (protected)



50
51
52
# File 'lib/sprout/remote_file_target.rb', line 50

def expand_local_path path
  File.join unpacked_file, path
end

- (Object) logger (protected)



46
47
48
# File 'lib/sprout/remote_file_target.rb', line 46

def logger
  Sprout.stdout
end

- (Object) resolve



18
19
20
21
22
# File 'lib/sprout/remote_file_target.rb', line 18

def resolve
  validate
  load_unpack_or_ignore_archive
  self
end

- (Object) unpacked_file



34
35
36
37
38
39
40
41
42
# File 'lib/sprout/remote_file_target.rb', line 34

def unpacked_file
  upcased_pkg = pkg_name.upcase
  upcased_version = pkg_version.upcase.gsub /\./, '_'
    ENV["SPROUT_#{upcased_pkg}_#{upcased_version}"] ||
    ENV["SPROUT_#{upcased_pkg}"] ||
    ENV["#{upcased_pkg}_#{upcased_version}"] ||
    ENV[upcased_pkg] ||
    File.join(Sprout.cache, pkg_name, pkg_version)
end

- (Object) validate



11
12
13
14
15
16
# File 'lib/sprout/remote_file_target.rb', line 11

def validate
  super
  raise Sprout::Errors::ValidationError.new "RemoteFileTarget.url is a required field" if url.nil?
  raise Sprout::Errors::ValidationError.new "RemoteFileTarget.md5 is a required field" if md5.nil?
  raise Sprout::Errors::ValidationError.new "RemoteFileTarget.archive_type is a required field" if archive_type.nil?
end