Class: SparkleAppcast::Archive

Inherits:
Object
  • Object
show all
Defined in:
lib/sparkle_appcast/archive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Archive

Returns a new instance of Archive.



7
8
9
# File 'lib/sparkle_appcast/archive.rb', line 7

def initialize(path)
  @path = File.expand_path(path)
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



5
6
7
# File 'lib/sparkle_appcast/archive.rb', line 5

def path
  @path
end

Instance Method Details

#bundle_infoObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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_atObject



11
12
13
# File 'lib/sparkle_appcast/archive.rb', line 11

def created_at
  File.birthtime(path)
end

#dataObject



19
20
21
# File 'lib/sparkle_appcast/archive.rb', line 19

def data
  File.binread(path)
end

#sizeObject



15
16
17
# File 'lib/sparkle_appcast/archive.rb', line 15

def size
  File.size(path)
end