xcarchive 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 39971e522ac0a2d5a196a189a7fa9b182919d161
4
- data.tar.gz: a274286e04d773deca4434d717f1bd93d1318efb
3
+ metadata.gz: 89ab454e94804d616ea9a3ddc739935d791a7ecf
4
+ data.tar.gz: 0022f1dc8b6f5f664d3928a4c129fc01e3e1861d
5
5
  SHA512:
6
- metadata.gz: e649080eab876d93674456fe137b378191d6cc33a2da8543e9292e4c65932971cab63535855d7454c0689ad00721330bfd446096d4bb82c0eb2a181fead0de9f
7
- data.tar.gz: 3ab6dd20593e59c1182c897fb1535a70941533542171af0b44eb5cd24c1f49a3f8ba25b41930548c1c8804704fbfe8674298e1feb366c9f8e762a36e0e240676
6
+ metadata.gz: 565e6661c5038f1ea6896c6c12d90dd0d7de5af2847e28bb010df93316dd966e80ff2ac99defd3cdabbbf5b0ff107f41bb8a8909348794fb4188e19cc7c934a5
7
+ data.tar.gz: 8de53aac433467eb599cb04a92153527da03da7c8970fdaa8a932446d75d91a920717d4c1ae4c5207f4e4ecd534a8fb2cce53d69228a58bc122ed724af1c2e70
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ *.swp
@@ -1,5 +1,104 @@
1
1
  require "xcarchive/version"
2
+ require "xcarchive/archive"
3
+
4
+ require 'optparse'
5
+ require 'ostruct'
2
6
 
3
7
  module Xcarchive
4
- # Your code goes here...
8
+ def run
9
+ options = OpenStruct.new
10
+ OptionParser.new do |opts|
11
+ opts.banner = "Usage: xcarchive [options]"
12
+
13
+ opts.separator ""
14
+ opts.separator "Specific options:"
15
+
16
+ options.path = false
17
+ opts.on("-p", "--path", "Print archive paths only") do
18
+ options.path = true
19
+ end
20
+
21
+ options.list = false
22
+ opts.on("-l", "--list", "List all builds in a human readable format") do
23
+ options.list = true
24
+ end
25
+
26
+ options.export = nil
27
+ opts.on("-e", "--export PATH", "Export an archive into the given path") do |path|
28
+ options.export = path
29
+ end
30
+
31
+ options.id = nil
32
+ opts.on("--id IDENTIFIER", "Limits the output to archives for the app with the specified bundle identifier") do |id|
33
+ options.id = id
34
+ end
35
+
36
+ options.version = nil
37
+ opts.on("--version VERSION", "Limits the output to archives matching the specified version") do |version|
38
+ options.version = version
39
+ end
40
+
41
+ options.build = nil
42
+ opts.on("--build BUILD", "Limits the output to archives matching the specified build number") do |build|
43
+ options.build = build
44
+ end
45
+
46
+ options.options = nil
47
+ opts.on("--options OPTIONS", "Specifies the export options file to be used when exporting builds") do |opt|
48
+ options.options = opt
49
+ end
50
+
51
+ opts.on_tail("-h", "--help", "Show this message") do
52
+ puts opts
53
+ puts
54
+ exit 1
55
+ end
56
+ end.parse!
57
+
58
+ if !options.path && !options.list && !options.export then
59
+ puts "You must specify at least one of the following options:"
60
+ puts " --path, --list, --export"
61
+ puts
62
+ puts "Type xcarchive --help for more information"
63
+ puts
64
+ exit 1
65
+ end
66
+
67
+ archives = Archive::filtered_archives(options.id, options.version, options.build)
68
+ if archives.count <= 0 then
69
+ puts "No archives found."
70
+ exit 1
71
+ end
72
+
73
+ if options.path && !options.list && !options.export then
74
+ archives.each do |archive|
75
+ puts archive.path
76
+ end
77
+ elsif options.list && !options.path && !options.export then
78
+ archives.each do |archive|
79
+ puts archive.description
80
+ end
81
+ puts "================================================="
82
+ puts "Total #{archives.count} archives found."
83
+ puts "================================================="
84
+ elsif options.export && !options.path && !options.list then
85
+ if options.options == nil then
86
+ puts "You must specify the xcode export options file to use:"
87
+ puts " --options OPTIONS_FILE"
88
+ puts
89
+ exit 1
90
+ end
91
+
92
+ archives.each do |archive|
93
+ puts archive.export(options.export, options.options)
94
+ end
95
+ else
96
+ puts "You must not specify more than one of the following options:"
97
+ puts " --path, --list, --export"
98
+ puts
99
+ exit 1
100
+ end
101
+
102
+ exit 0
103
+ end
5
104
  end
@@ -0,0 +1,88 @@
1
+ require 'plist'
2
+
3
+ class Archive
4
+ ARCHIVES_ROOT = File.join(File.expand_path('~'), "Library/Developer/Xcode/Archives")
5
+
6
+ def self.all_archives()
7
+ all_archives = Array.new
8
+ Dir[File.join(Archive::ARCHIVES_ROOT, '*')].each do |archives|
9
+ Dir[File.join(archives, '*.xcarchive')].each do |file|
10
+ archive = Archive.new(file)
11
+ all_archives.push(archive)
12
+ end
13
+ end
14
+ return all_archives
15
+ end
16
+
17
+ def self.filtered_archives(bundle = nil, version = nil, build = nil)
18
+ archives = Archive::all_archives
19
+ if bundle != nil then
20
+ archives = archives.select { |x| x.bundle_id == bundle }
21
+ end
22
+ if version != nil then
23
+ archives = archives.select { |x| x.version == version }
24
+ end
25
+ if build != nil then
26
+ archives = archives.select { |x| x.build == build }
27
+ end
28
+ return archives
29
+ end
30
+
31
+ attr_reader :path
32
+
33
+ def initialize(path)
34
+ @path = path
35
+ @info = nil
36
+ end
37
+
38
+ def info_file
39
+ return File.join(self.path, "Info.plist")
40
+ end
41
+
42
+ def info
43
+ if @info == nil then
44
+ @info = Plist::parse_xml(self.info_file)
45
+ end
46
+ return @info
47
+ end
48
+
49
+ def bundle_id
50
+ return self.info['ApplicationProperties']['CFBundleIdentifier']
51
+ end
52
+
53
+ def build
54
+ return self.info['ApplicationProperties']['CFBundleVersion']
55
+ end
56
+
57
+ def version
58
+ return self.info['ApplicationProperties']['CFBundleShortVersionString']
59
+ end
60
+
61
+ def archived_on
62
+ return self.info['CreationDate']
63
+ end
64
+
65
+ def name
66
+ return self.info['Name']
67
+ end
68
+
69
+ def description
70
+ str = "=================================================\n"
71
+ str << "Name: #{self.name}\n"
72
+ str << "Bundle ID: #{self.bundle_id}\n"
73
+ str << "Version: #{self.version}\n"
74
+ str << "Build: #{self.build}\n"
75
+ str << "Archived On: #{self.archived_on}\n"
76
+ str << "Path: #{self.path}\n"
77
+ return str
78
+ end
79
+
80
+ def export(path, options)
81
+ if system("xcodebuild -exportArchive -exportOptionsPlist \"#{options}\" -archivePath \"#{self.path}\" -exportPath \"#{path}\" &> /dev/null")
82
+ return File.join(path, "#{self.name}.ipa")
83
+ else
84
+ return nil
85
+ end
86
+ end
87
+ end
88
+
@@ -1,3 +1,3 @@
1
1
  module Xcarchive
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -21,4 +21,6 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.11"
22
22
  spec.add_development_dependency "rake", "~> 10.0"
23
23
  spec.add_development_dependency "rspec", "~> 3.0"
24
+
25
+ spec.add_runtime_dependency "plist", "~> 3.2.0"
24
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcarchive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jaderfeijo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-31 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: plist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.0
55
69
  description: A command line utility for managing Xcode archives
56
70
  email:
57
71
  - jader.feijo@gmail.com
@@ -68,6 +82,7 @@ files:
68
82
  - bin/console
69
83
  - bin/setup
70
84
  - lib/xcarchive.rb
85
+ - lib/xcarchive/archive.rb
71
86
  - lib/xcarchive/version.rb
72
87
  - xcarchive.gemspec
73
88
  homepage: https://github.com/jaderfeijo/xcarchive