Class: Sprout::RemoteFileTarget

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#archive_typeObject

Returns the value of attribute archive_type.



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

def archive_type
  @archive_type
end

#md5Object

Returns the value of attribute md5.



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

def md5
  @md5
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#downloaded_fileObject

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


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

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

#move_player_libObject



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

def move_player_lib
  path = File.join(File.dirname(__FILE__), "..", "..", "assets", "playerglobal.swc")
  player_path = File.join(unpacked_file, "frameworks", "libs", "player")
  to_path = File.join(player_path, "10.2")
  
  if File.exist?(player_path)
    FileUtils.mkdir(to_path)
    FileUtils.cp(path, to_path)
  end
end

#resolveObject



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

def resolve
  validate
  load_unpack_or_ignore_archive
  self
end

#unpacked_fileObject



46
47
48
49
50
51
52
53
54
# File 'lib/sprout/remote_file_target.rb', line 46

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

#validateObject



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

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