lib/sprout/remote_file_target.rb in sprout-1.0.32.pre vs lib/sprout/remote_file_target.rb in sprout-1.0.35.pre
- old
+ new
@@ -19,18 +19,10 @@
validate
load_unpack_or_ignore_archive
self
end
- protected
-
- def expand_local_path path
- File.join unpacked_file, path
- end
-
- private
-
##
# Do not cache this value...
#
# This response can change over time IF:
# - The downloaded bytes do not match the expected MD5
@@ -38,13 +30,31 @@
def downloaded_file
File.join(Sprout.cache, pkg_name, "#{md5}.#{archive_type}")
end
def unpacked_file
- @unpacked_file ||= File.join(Sprout.cache, pkg_name, pkg_version)
+ 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
+ protected
+
+ def logger
+ Sprout::Log
+ end
+
+ def expand_local_path path
+ File.join unpacked_file, path
+ end
+
+ private
+
def load_unpack_or_ignore_archive
if(!unpacked_files_exist?)
if(!File.exists?(downloaded_file))
bytes = download_archive
write_archive bytes
@@ -99,9 +109,10 @@
raise Sprout::Errors::RemoteFileLoaderError.new('MD5 Checksum failed')
end
end
def unpack_archive
+ logger.puts "Unpacking archive at #{downloaded_file} now. This can take anywhere from a few seconds to many minutes depending on your OS and the size of the archive.\n\nIf you're on windows, consider using this ample time to look into improving the zip utils in Ruby..."
FileUtils.mkdir_p unpacked_file
unpacker = Sprout::ArchiveUnpacker.new
unpacker.unpack downloaded_file, unpacked_file, archive_type
end