class SparkleAppcast::Archive
Attributes
path[R]
Public Class Methods
new(path)
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 7 def initialize(path) @path = File.expand_path(path) end
Public Instance Methods
bundle_info()
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 23 def bundle_info @bundle_info ||= Dir.mktmpdir do |tmpdir_path| unarchive!(tmpdir_path) app_paths = Dir.glob(File.join(tmpdir_path, "*.app"), File::FNM_CASEFOLD) if app_paths.size == 0 raise RuntimeError.new("No application bundle found: #{path}") elsif app_paths.size > 1 raise RuntimeError.new("Found multiple application bundles: #{app_paths.map{|path| File.basename(path)}}") else app_path = app_paths.first Bundle.new(app_path).info end end end
created_at()
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 11 def created_at File.birthtime(path) end
data()
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 19 def data File.binread(path) end
size()
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 15 def size File.size(path) end
Private Instance Methods
unarchive!(destination_path)
click to toggle source
# File lib/sparkle_appcast/archive.rb, line 41 def unarchive!(destination_path) case File.basename(path) when /\.zip\z/i Kernel.system("/usr/bin/ditto", "-x", "-k", path, destination_path) when /\.tar\z/i Kernel.system("/usr/bin/tar", "-x", "-f", path, "-C", destination_path) when /\.tar\.gz\z/i, /\.tgz\z/i, /\.tar\.xz\z/i, /\.txz\z/i, /\.tar\.lzma\z/i Kernel.system("/usr/bin/tar", "-x", "-z", "-f", path, "-C", destination_path) when /\.tar\.bz2\z/i, /\.tbz\z/i Kernel.system("/usr/bin/tar", "-x", "-j", "-f", path, "-C", destination_path) else raise NotImplementedError.new("Disk image support is not implemented yet.") end unless $?.success? raise RuntimeError.new("Failed to expand archive: #{path}") end end