class Passifier::Archive
Represents the .pkpass archive file for the pass. Despite the extension, a .pkpass file is actually a zip archive.
Attributes
assets[R]
id[R]
path[R]
Public Class Methods
new(path, id, assets)
click to toggle source
@param [String] path The archive path @param [String] id An ID to represent the Archive
# File lib/passifier/archive.rb, line 15 def initialize(path, id, assets) @assets = assets @path = path @id = id end
Public Instance Methods
data()
click to toggle source
The raw data of this archive file @return [String] The raw data of this archive file
# File lib/passifier/archive.rb, line 23 def data File.open(@path, 'rb') {|file| file.read } unless @path.nil? end
destroy()
click to toggle source
# File lib/passifier/archive.rb, line 27 def destroy unless @storage.nil? @storage.cleanup @storage.remove_zip(@path) end end
store(options = {})
click to toggle source
Write the zip archive to disk @param [Hash] options The options to store an Archive
with. @option opts [String] :scratch_directory The directory to use for temp files while creating the archive.
(not to be confused with the archive path)
# File lib/passifier/archive.rb, line 38 def store(options = {}) scratch_dir = options[:scratch_directory] || "/tmp/passkit/#{@id}" @storage = Storage.new(scratch_dir, @assets) @storage.store @storage.zip(@path) @storage.cleanup end
Also aliased as: save