Class: Archive

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

Constant Summary collapse

ARCHIVES_ROOT =
File.join(File.expand_path('~'), "Library/Developer/Xcode/Archives")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Archive

Returns a new instance of Archive.



33
34
35
36
# File 'lib/xcarchive/archive.rb', line 33

def initialize(path)
	@path = path
	@info = nil
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



31
32
33
# File 'lib/xcarchive/archive.rb', line 31

def path
  @path
end

Class Method Details

.all_archivesObject



6
7
8
9
10
11
12
13
14
15
# File 'lib/xcarchive/archive.rb', line 6

def self.all_archives()
	all_archives = Array.new
	Dir[File.join(Archive::ARCHIVES_ROOT, '*')].each do |archives|
		Dir[File.join(archives, '*.xcarchive')].each do |file|
			archive = Archive.new(file)
			all_archives.push(archive)
		end
	end
	return all_archives
end

.filtered_archives(bundle = nil, version = nil, build = nil) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/xcarchive/archive.rb', line 17

def self.filtered_archives(bundle = nil, version = nil, build = nil)
	archives = Archive::all_archives
	if bundle != nil then
		archives = archives.select { |x| x.bundle_id == bundle }
	end
	if version != nil then
		archives = archives.select { |x| x.version == version }
	end
	if build != nil then
		archives = archives.select { |x| x.build == build }
	end
	return archives
end

Instance Method Details

#archived_onObject



61
62
63
# File 'lib/xcarchive/archive.rb', line 61

def archived_on
	return self.info['CreationDate']
end

#buildObject



53
54
55
# File 'lib/xcarchive/archive.rb', line 53

def build
	return self.info['ApplicationProperties']['CFBundleVersion']
end

#bundle_idObject



49
50
51
# File 'lib/xcarchive/archive.rb', line 49

def bundle_id
	return self.info['ApplicationProperties']['CFBundleIdentifier']
end

#descriptionObject



69
70
71
72
73
74
75
76
77
78
# File 'lib/xcarchive/archive.rb', line 69

def description
	str = "=================================================\n"
	str << "Name: #{self.name}\n"
	str << "Bundle ID: #{self.bundle_id}\n"
	str << "Version: #{self.version}\n"
	str << "Build: #{self.build}\n"
	str << "Archived On: #{self.archived_on}\n"
	str << "Path: #{self.path}\n"
	return str
end

#export(path, options) ⇒ Object



80
81
82
83
84
85
86
# File 'lib/xcarchive/archive.rb', line 80

def export(path, options)
	if system("xcodebuild -exportArchive -exportOptionsPlist \"#{options}\" -archivePath \"#{self.path}\" -exportPath \"#{path}\" &> /dev/null")
		return File.join(path, "#{self.name}.ipa")
	else
		return nil
	end
end

#infoObject



42
43
44
45
46
47
# File 'lib/xcarchive/archive.rb', line 42

def info
	if @info == nil then
		@info = Plist::parse_xml(self.info_file)
	end
	return @info
end

#info_fileObject



38
39
40
# File 'lib/xcarchive/archive.rb', line 38

def info_file
	return File.join(self.path, "Info.plist")
end

#nameObject



65
66
67
# File 'lib/xcarchive/archive.rb', line 65

def name
	return self.info['Name']
end

#versionObject



57
58
59
# File 'lib/xcarchive/archive.rb', line 57

def version
	return self.info['ApplicationProperties']['CFBundleShortVersionString']
end