profiles 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 57e54647d2ea5b2f2a02fb1da2573ad2cb822cee
4
+ data.tar.gz: f936b85054124889848097f7ab487d352a305630
5
+ SHA512:
6
+ metadata.gz: 6185e61b2d9b1aad969de79f6cbc31e9bca968128c6a26b31d65c780bb89dae959c1fa3c62c770cb3c0bcb9ead1254a9e1d1250f208fa8b0a01fb52162cfd017
7
+ data.tar.gz: 912e101108c2eceec54965e8181687b104bddae0823de38ded33b85535bafa37b638e342e424d435924583759f6f179692c4d65d80bfcd43b3864a4ed12dab91
@@ -0,0 +1,102 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+
16
+ # Created by https://www.gitignore.io
17
+
18
+ ### RubyMine ###
19
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
20
+
21
+ *.iml
22
+
23
+ ## Directory-based project format:
24
+ .idea/
25
+ # if you remove the above rule, at least ignore the following:
26
+
27
+ # User-specific stuff:
28
+ # .idea/workspace.xml
29
+ # .idea/tasks.xml
30
+ # .idea/dictionaries
31
+
32
+ # Sensitive or high-churn files:
33
+ # .idea/dataSources.ids
34
+ # .idea/dataSources.xml
35
+ # .idea/sqlDataSources.xml
36
+ # .idea/dynamic.xml
37
+ # .idea/uiDesigner.xml
38
+
39
+ # Gradle:
40
+ # .idea/gradle.xml
41
+ # .idea/libraries
42
+
43
+ # Mongo Explorer plugin:
44
+ # .idea/mongoSettings.xml
45
+
46
+ ## File-based project format:
47
+ *.ipr
48
+ *.iws
49
+
50
+ ## Plugin-specific files:
51
+
52
+ # IntelliJ
53
+ out/
54
+
55
+ # mpeltonen/sbt-idea plugin
56
+ .idea_modules/
57
+
58
+ # JIRA plugin
59
+ atlassian-ide-plugin.xml
60
+
61
+ # Crashlytics plugin (for Android Studio and IntelliJ)
62
+ com_crashlytics_export_strings.xml
63
+ crashlytics.properties
64
+ crashlytics-build.properties
65
+
66
+
67
+ ### Ruby ###
68
+ *.gem
69
+ *.rbc
70
+ /.config
71
+ /coverage/
72
+ /InstalledFiles
73
+ /pkg/
74
+ /spec/reports/
75
+ /test/tmp/
76
+ /test/version_tmp/
77
+ /tmp/
78
+
79
+ ## Specific to RubyMotion:
80
+ .dat*
81
+ .repl_history
82
+ build/
83
+
84
+ ## Documentation cache and generated files:
85
+ /.yardoc/
86
+ /_yardoc/
87
+ /doc/
88
+ /rdoc/
89
+
90
+ ## Environment normalisation:
91
+ /.bundle/
92
+ /lib/bundler/man/
93
+
94
+ # for a library or gem, you might want to ignore these files since the code is
95
+ # intended to run in multiple environments; otherwise, check them in:
96
+ # Gemfile.lock
97
+ # .ruby-version
98
+ # .ruby-gemset
99
+
100
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
101
+ .rvmrc
102
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in profiles.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Omar Abdelhafith
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,35 @@
1
+ # Profiles
2
+
3
+ Profiles is a command line tool that helps you inspect your local list of provision profiles for a give UDID, and it also can search an ipa’s embedded provision profile for it.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'profiles'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install profiles
20
+
21
+ ## Usage
22
+
23
+ Search the local list of provision profiles managed by Xcode
24
+ prov local -u <UDID>
25
+
26
+ Checks if an ipa contains a UDID
27
+ prov ipa -p <IPA_PATH> -u <UDID>
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it ( https://github.com/[my-github-username]/profiles/fork )
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'profiles/cli'
4
+ Profiles::CLI.start
@@ -0,0 +1,4 @@
1
+ require 'profiles/version'
2
+ require 'profiles/profiles_utils'
3
+ require 'profiles/ipa_reader'
4
+ require 'profiles/profiles_udid_fetcher'
@@ -0,0 +1,48 @@
1
+ require 'thor'
2
+ require 'plist'
3
+ require 'CFPropertyList'
4
+ require 'nokogiri'
5
+ require 'profiles'
6
+
7
+ class Profiles::CLI < Thor
8
+ package_name :prov
9
+
10
+ option :t, :aliases => ["--team"], :type => :boolean, desc: "Include 'iOSTeam Provisioning Profile' profiles"
11
+ option :u, :aliases => ["--udid"], required: true, desc: "The UDID to search"
12
+ desc "local", "Search the local provision profiles managed by Xcode for the given UDID"
13
+
14
+ def local
15
+ say "Parsing local provision profiles\n\n"
16
+ udid = options[:u]
17
+
18
+ profiles = ProfilesUtils.search_local_provisions(udid, options[:t])
19
+
20
+ if (profiles.count == 0)
21
+ say "No profile containing #{udid} UDID found", :red
22
+ else
23
+ say "Found #{profiles.count} profiles containing #{options[:u]}", :green
24
+ profiles.sort.each { |item| say item}
25
+ end
26
+
27
+ end
28
+
29
+ option :p, :aliases => ["--path"], required: true, desc: "Path of the IPA"
30
+ option :u, :aliases => ["--udid"], required: true, desc: "The UDID to search"
31
+ desc "ipa", "Checks if the passed ipa contains the UDID"
32
+
33
+ def ipa
34
+ udid = options[:u]
35
+ reader = IpaReader.new(options[:p])
36
+
37
+ reader.on_unzip { puts "Unzipping ipa file"}
38
+
39
+ parser = reader.provision_parser
40
+
41
+ if parser.provisioned_devices.include?(udid)
42
+ say "#{udid} UDID found", :green
43
+ else
44
+ say "#{udid} UDID not found", :red
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,52 @@
1
+ require 'pathname'
2
+ require 'base64'
3
+
4
+ UNZIP_DIR = "/tmp/unzip_temp"
5
+
6
+ class IpaReader
7
+
8
+ def initialize(ipa_path)
9
+ pn = Pathname.new(ipa_path)
10
+ @ipa_path = pn.dirname
11
+ @ipa_name = pn.basename
12
+ @full_path = ipa_path
13
+
14
+ at_exit { clean_up }
15
+ end
16
+
17
+ def provision_parser
18
+ return @provision_parser if @provision_parser
19
+
20
+ unzip_and_parse
21
+ @provision_parser
22
+ end
23
+
24
+ def on_unzip(&block)
25
+ @on_unzip = block
26
+ end
27
+
28
+ private
29
+
30
+ def unzip_and_parse
31
+ unzip
32
+ parse
33
+ end
34
+
35
+ def unzip
36
+ @on_unzip.call if @on_unzip
37
+ system "unzip #{@full_path} -d #{UNZIP_DIR} > /tmp/log.txt"
38
+ end
39
+
40
+ def parse
41
+ provision_path = "#{UNZIP_DIR}/Payload/#{bundle_name}/embedded.mobileprovision"
42
+ @provision_parser = ProvisionProfileParser.new provision_path
43
+ end
44
+
45
+ def bundle_name
46
+ Dir.entries("#{UNZIP_DIR}/Payload").last
47
+ end
48
+
49
+ def clean_up
50
+ system "rm -rf #{UNZIP_DIR}"
51
+ end
52
+ end
@@ -0,0 +1,35 @@
1
+ require "profiles/provision_profile_parser"
2
+
3
+ class ProfilesUDIDFetcher
4
+
5
+ def initialize(profiles:profiles, udid:udid, include_team_profiles:include_team_profiles)
6
+ @udid = udid
7
+ @include_team_profiles = include_team_profiles
8
+ @provision_profiles = profiles
9
+ end
10
+
11
+ def provision_profiles
12
+ profiles_containing_udid
13
+ end
14
+
15
+ private
16
+
17
+ def profiles_containing_udid
18
+ profiles = []
19
+
20
+ @provision_profiles.each do |file|
21
+ provision_profile = ProvisionProfileParser.new(file)
22
+
23
+ devices = provision_profile.provisioned_devices
24
+
25
+ next unless devices && devices.include?(@udid)
26
+
27
+ profile_name = provision_profile.name
28
+ next if profile_name =~ /iOSTeam Provisioning Profile.*/ && !@include_team_profiles
29
+
30
+ profiles << profile_name
31
+ end
32
+
33
+ profiles
34
+ end
35
+ end
@@ -0,0 +1,24 @@
1
+ require "profiles/version"
2
+ require "profiles/profiles_udid_fetcher"
3
+
4
+ class ProfilesUtils
5
+
6
+ def self.search_local_provisions(udid, include_team_profiles)
7
+ fetcher = ProfilesUDIDFetcher.new(profiles:self.local_provision_files,
8
+ udid:udid,
9
+ include_team_profiles:include_team_profiles)
10
+ fetcher.provision_profiles
11
+ end
12
+
13
+ def self.local_provision_files
14
+ Dir["#{provision_directory_path}/*"].grep (/.*.mobileprovision/)
15
+ end
16
+
17
+ private
18
+
19
+ def self.provision_directory_path
20
+ "#{ENV["HOME"]}/Library/MobileDevice/Provisioning Profiles"
21
+ end
22
+
23
+ end
24
+
@@ -0,0 +1,48 @@
1
+ require 'cfpropertylist'
2
+
3
+ TEMP_PLIST = "/tmp/tmp.plist"
4
+
5
+ class ProvisionProfileParser
6
+
7
+ def initialize provision_path
8
+ @provision_path = provision_path
9
+ at_exit { clean_up }
10
+ end
11
+
12
+ def certificates
13
+ parse
14
+ @data["DeveloperCertificates"]
15
+ end
16
+
17
+ def name
18
+ @data["Name"]
19
+ end
20
+
21
+ def provisioned_devices
22
+ parse
23
+ @data["ProvisionedDevices"]
24
+ end
25
+
26
+ def team_name
27
+ parse
28
+ @data["TeamName"]
29
+ end
30
+
31
+ private
32
+
33
+ def parse
34
+ return @data if @data
35
+
36
+ `security cms -D -i "#{@provision_path}" > #{TEMP_PLIST}`
37
+
38
+ # Get info from plist
39
+ plist = CFPropertyList::List.new
40
+ plist = CFPropertyList::List.new(:file => TEMP_PLIST)
41
+ @data = CFPropertyList.native_types(plist.value)
42
+ end
43
+
44
+ def clean_up
45
+ system "rm -rf #{TEMP_PLIST}"
46
+ end
47
+
48
+ end
@@ -0,0 +1,3 @@
1
+ module Profiles
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'profiles/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "profiles"
8
+ spec.version = Profiles::VERSION
9
+ spec.authors = ["Omar Abdelhafith"]
10
+ spec.email = ["omar.abdelhafith@mttnow.com"]
11
+ spec.summary = %q{Search local provision profiles and ipa for a UDID}
12
+ spec.description = %q{prov is a command line tool that helps you inspect your local list of provision profiles for a give UDID, and it also can search an ipa’s embedded provision profile for it.}
13
+ spec.homepage = "https://github.com/oarrabi/profiles"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "minitest"
24
+ spec.add_development_dependency "minitest-reporters"
25
+
26
+ spec.add_dependency "thor"
27
+ spec.add_dependency "plist"
28
+ spec.add_dependency "CFPropertyList", '~> 2.2'
29
+ spec.add_dependency "nokogiri"
30
+ end
@@ -0,0 +1,10 @@
1
+ require 'minitest/autorun'
2
+ require 'profiles'
3
+
4
+ class LopTests < Minitest::Unit::TestCase
5
+
6
+ def test_can_list_profiles
7
+
8
+ # puts `lop device 93dc72871a3fb2a88a80408d2130e0909b17f62e`
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,175 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: profiles
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Omar Abdelhafith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: plist
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: CFPropertyList
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.2'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.2'
111
+ - !ruby/object:Gem::Dependency
112
+ name: nokogiri
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: prov is a command line tool that helps you inspect your local list of
126
+ provision profiles for a give UDID, and it also can search an ipa’s embedded provision
127
+ profile for it.
128
+ email:
129
+ - omar.abdelhafith@mttnow.com
130
+ executables:
131
+ - prov
132
+ extensions: []
133
+ extra_rdoc_files: []
134
+ files:
135
+ - ".gitignore"
136
+ - Gemfile
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/prov
141
+ - lib/profiles.rb
142
+ - lib/profiles/cli.rb
143
+ - lib/profiles/ipa_reader.rb
144
+ - lib/profiles/profiles_udid_fetcher.rb
145
+ - lib/profiles/profiles_utils.rb
146
+ - lib/profiles/provision_profile_parser.rb
147
+ - lib/profiles/version.rb
148
+ - profiles.gemspec
149
+ - test/lop_tests.rb
150
+ homepage: https://github.com/oarrabi/profiles
151
+ licenses:
152
+ - MIT
153
+ metadata: {}
154
+ post_install_message:
155
+ rdoc_options: []
156
+ require_paths:
157
+ - lib
158
+ required_ruby_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubyforge_project:
170
+ rubygems_version: 2.3.0
171
+ signing_key:
172
+ specification_version: 4
173
+ summary: Search local provision profiles and ipa for a UDID
174
+ test_files:
175
+ - test/lop_tests.rb