class RXCode::Archive

Processes an NSKeyedArchive file into a set of Ruby objects

Attributes

archive_hash[R]
archive_path[R]
ARCHIVE PATH ===============================================================================================
object_mapper[RW]

Public Class Methods

archive_at_path(archive_path) click to toggle source
# File lib/rxcode/models/archive.rb, line 65
def self.archive_at_path(archive_path)
  self.new(archive_path)
end
new(archive_path_or_hash, &object_mapper) click to toggle source
# File lib/rxcode/models/archive.rb, line 8
def initialize(archive_path_or_hash, &object_mapper)
  if archive_path_or_hash.is_a?(String)
    
    if File.exist?(archive_path_or_hash)
      @archive_path = archive_path_or_hash
      @archive_hash = Plist::parse_xml(`plutil -convert xml1 -o - '#{archive_path_or_hash}'`)
    else
      @archive_hash = Plist::parse_xml(archive_path_or_hash)
    end
    
  elsif archive_path_or_hash.is_a?(Hash)
    
    @archive_hash = archive_path_or_hash
    
  end
  
  @objects = {}
  @object_mapper = object_mapper
end
object_at_path(archive_path) click to toggle source

Returns the object archived in the file identified by archive_path.

# File lib/rxcode/models/archive.rb, line 72
def self.object_at_path(archive_path)
  archive_at_path(archive_path).root_object
end

Public Instance Methods

model_object_with_id(object_id) click to toggle source
# File lib/rxcode/models/archive.rb, line 55
def model_object_with_id(object_id)
  if o = object_with_id(object_id)
    o.model_object
  end
end
object_hashes() click to toggle source
# File lib/rxcode/models/archive.rb, line 61
def object_hashes
  archive_hash['objects']
end
object_with_id(object_id) click to toggle source
OBJECTS ====================================================================================================
# File lib/rxcode/models/archive.rb, line 48
def object_with_id(object_id)
  @objects[object_id] ||=
    if object_hashes[object_id]
      ArchivedObject.new(self, object_id)
    end
end
root_object() click to toggle source
# File lib/rxcode/models/archive.rb, line 42
def root_object
  object_with_id(root_object_archive_id)
end
root_object_archive_id() click to toggle source
ROOT OBJECT ================================================================================================
# File lib/rxcode/models/archive.rb, line 38
def root_object_archive_id
  @archive_hash['rootObject']
end