pliney 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2df1c1b96c6a116c3342aee0df16f2264c0fec62
4
+ data.tar.gz: d740e3dee3c294cd92e7825b8736cba925e76579
5
+ SHA512:
6
+ metadata.gz: 4b23f2907b25e5bde13515ef6daec6458bb8e62e59e4bc543e3e44a3a873bbc3327487a808db1f54183f2d9c2fe9d5e8eb9149c18dff35e5b046ac3cf000e97e
7
+ data.tar.gz: 8c597a83dc006e93678ae11d2e3c819219b801254746bf3e6b91ae1b344bc249dc20daa65a66c579c35372406766e9e304676017375095c9d45a3db252934a34
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ ref/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format doc
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache: bundle
4
+ rvm:
5
+ - 2.0.0
6
+ - 2.1.5
7
+ - 2.2.0
8
+ - ruby-head
9
+ - rbx-2
10
+ before_install:
11
+ - gem update --system
12
+ - gem --version
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pliney.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Eric Monti
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.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Pliney
2
+ [![Gem Version](https://badge.fury.io/rb/rubyzip.svg)](http://badge.fury.io/rb/pliney)
3
+ [![Build Status](https://secure.travis-ci.org/emonti/pliney.svg)](https://travis-ci.org/emonti/pliney)
4
+ [![Code Climate](https://codeclimate.com/github/emonti/pliney.svg)](https://codeclimate.com/github/emonti/pliney)
5
+ [![Coverage Status](https://img.shields.io/coveralls/emonti/rpliney.svg)](https://coveralls.io/r/emonti/pliney?branch=master)
6
+
7
+ Pliney is for working with Apple IPAs.
8
+
9
+ Includes various helpers and interfaces for working with IPA files,
10
+ mobileprovisioning, and other file formats related Apple iOS apps.
11
+
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ gem 'pliney'
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install pliney
26
+
27
+ ## Usage
28
+
29
+ TODO: Write usage instructions here
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/pliney/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => [:spec]
@@ -0,0 +1,13 @@
1
+
2
+ module Pliney
3
+ class Entitlements
4
+ def self.from_data(data)
5
+ new(Pliney.parse_plist(data))
6
+ end
7
+
8
+ attr_reader :ents
9
+ def initialize(ents)
10
+ @ents = ents
11
+ end
12
+ end
13
+ end
data/lib/pliney/ipa.rb ADDED
@@ -0,0 +1,86 @@
1
+ require 'rubygems'
2
+ require 'zip'
3
+ require 'pliney/util'
4
+ require 'pliney/entitlements'
5
+
6
+ module Pliney
7
+ class IPA
8
+ def self.from_path(path)
9
+ ipa = new(Zip::File.open(path))
10
+ if block_given?
11
+ ret = yield(ipa)
12
+ ipa.close
13
+ return ret
14
+ else
15
+ return ipa
16
+ end
17
+ end
18
+
19
+ # TODO - creating an ipa from scratch?
20
+ # def self.create(path)
21
+ # new(Zip::File.open(path, Zip::File::CREATE))
22
+ # end
23
+
24
+ attr_reader :zipfile
25
+
26
+ def initialize(zipfile)
27
+ @zipfile = zipfile
28
+ end
29
+
30
+ def appdir
31
+ @appdir ||= find_appdir
32
+ end
33
+
34
+ def parse_plist_entry(path)
35
+ Pliney.parse_plist(read_path(path))
36
+ end
37
+
38
+ def find_appdir
39
+ if e = @zipfile.find{|ent| ent.directory? and ent.name =~ /^Payload\/[^\/]*\.app\/$/ }
40
+ return Pathname(e.name)
41
+ end
42
+ end
43
+
44
+ def read_path(path, *args)
45
+ return @zipfile.get_input_stream(path.to_s){|sio| sio.read(*args)}
46
+ end
47
+
48
+ def info_plist
49
+ return parse_plist_entry(appdir.join("Info.plist"))
50
+ end
51
+
52
+ def bundle_identifier
53
+ return info_plist["CFBundleIdentifier"]
54
+ end
55
+
56
+ def executable_path
57
+ return appdir.join(info_plist["CFBundleExecutable"])
58
+ end
59
+
60
+ def executable_entry
61
+ return get_entry(executable_path)
62
+ end
63
+
64
+ def ls
65
+ return @zipfile.entries.map{|e| e.name}
66
+ end
67
+
68
+ def close
69
+ @zipfile.close
70
+ end
71
+
72
+ def get_entry(path)
73
+ return @zipfile.find_entry(path.to_s)
74
+ end
75
+
76
+ def provisioning_profile
77
+ begin
78
+ profile_data = read_path(appdir.join("embedded.mobileprovision"))
79
+ rescue Errno::ENOENT
80
+ return nil
81
+ end
82
+
83
+ ProvisioningProfile.from_asn1(profile_data)
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,87 @@
1
+ require 'pliney/util'
2
+ require 'pliney/entitlements'
3
+ require 'openssl'
4
+
5
+ module Pliney
6
+ class EntitlementsMask < Entitlements
7
+ end
8
+
9
+ class ProvisioningProfile
10
+ def self.plist_from_asn1(rawdat)
11
+ asn1 = OpenSSL::ASN1.decode(rawdat)
12
+ plist_data = asn1.value[1].value[0].value[2].value[1].value[0].value
13
+ return Pliney.parse_plist(plist_data)
14
+ end
15
+
16
+ def self.from_asn1(rawdat)
17
+ new(plist_from_asn1(rawdat))
18
+ end
19
+
20
+ def self.from_file(path)
21
+ from_asn1(File.binread(path))
22
+ end
23
+
24
+ attr_reader :plist
25
+
26
+ def initialize(plist)
27
+ raise ArgumentError.new("invalid plist") unless plist.is_a?(Hash)
28
+ @plist = plist
29
+ end
30
+
31
+ def creation_date
32
+ plist["CreationDate"]
33
+ end
34
+
35
+ def expiration_date
36
+ plist["ExpirationDate"]
37
+ end
38
+
39
+ def expired?
40
+ not (creation_date.to_i .. expiration_date.to_i).include?(Time.now.to_i)
41
+ end
42
+
43
+ def entitlements
44
+ @ents ||= EntitlementsMask.new(plist["Entitlements"])
45
+ end
46
+
47
+ def developer_certificates
48
+ @developer_certs ||= plist["DeveloperCertificates"].map{|cer| OpenSSL::X509::Certificate.new(cer)}
49
+ end
50
+
51
+ def appid_name
52
+ plist["AppIDName"]
53
+ end
54
+
55
+ def appid_prefix
56
+ plist["ApplicationIdentifierPrefix"]
57
+ end
58
+
59
+ def name
60
+ plist["Name"]
61
+ end
62
+
63
+ def team_identifier
64
+ plist["TeamIDentifier"]
65
+ end
66
+
67
+ def team_name
68
+ plist["TeamName"]
69
+ end
70
+
71
+ def ttl
72
+ plist["TimeToLive"]
73
+ end
74
+
75
+ def uuid
76
+ plist["UUID"]
77
+ end
78
+
79
+ def version
80
+ plist["Version"]
81
+ end
82
+
83
+ def provisioned_devices
84
+ plist["ProvisionedDevices"]
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,10 @@
1
+ require 'cfpropertylist'
2
+ require 'pathname'
3
+ require 'openssl'
4
+
5
+ module Pliney
6
+ def self.parse_plist(rawdat)
7
+ plist = CFPropertyList::List.new(data: rawdat)
8
+ return CFPropertyList.native_types(plist.value)
9
+ end
10
+ end
@@ -0,0 +1,3 @@
1
+ module Pliney
2
+ VERSION = "0.0.1"
3
+ end
data/lib/pliney.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "pliney/version"
2
+ require 'pliney/ipa'
3
+ require 'pliney/provisioning_profile'
4
+
5
+ module Pliney
6
+ end
data/pliney.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pliney/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "pliney"
8
+ spec.version = Pliney::VERSION
9
+ spec.authors = ["Eric Monti"]
10
+ spec.email = ["esmonti@gmail.com"]
11
+ spec.summary = %q{Pliney is for working with Apple IPA files}
12
+ spec.description = %q{Includes various helpers and interfaces for working with IPA files, mobileprovisioning, and other formats related Apple iOS apps.}
13
+ spec.homepage = ""
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_dependency "rubyzip"
22
+ spec.add_dependency "CFPropertyList"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "pry"
28
+ end
data/spec/ipa_spec.rb ADDED
@@ -0,0 +1,64 @@
1
+ require_relative 'spec_helper'
2
+ require 'pliney'
3
+
4
+ describe Pliney::IPA do
5
+ before :each do
6
+ @ipa = Pliney::IPA.from_path(sample_file("pliney-test.ipa"))
7
+ end
8
+
9
+ after :each do
10
+ @ipa.close
11
+ end
12
+
13
+ it "loads an ipa" do
14
+ @ipa.should be_a Pliney::IPA
15
+ end
16
+
17
+ it "gets the bundle identifier" do
18
+ @ipa.bundle_identifier.should == "computer.versus.pliney-test"
19
+ end
20
+
21
+ it "gets the executable path" do
22
+ @ipa.executable_path.should == Pathname("Payload/pliney-test.app/pliney-test")
23
+ end
24
+
25
+ it "reads the executable magic value" do
26
+ @ipa.read_path(@ipa.executable_path, 4).unpack("N").first.should == 0xcafebabe
27
+ end
28
+
29
+ it "reads the info_plist" do
30
+ @ipa.info_plist.should be_a Hash
31
+ @ipa.info_plist["CFBundleExecutable"].should == "pliney-test"
32
+ @ipa.info_plist["CFBundleShortVersionString"].should == "1.0"
33
+ end
34
+
35
+ it "lists the ipa contents" do
36
+ @ipa.ls.sort.should == %w[
37
+ Payload/
38
+ Payload/pliney-test.app/
39
+ Payload/pliney-test.app/Base.lproj/
40
+ Payload/pliney-test.app/Base.lproj/LaunchScreen.nib
41
+ Payload/pliney-test.app/Base.lproj/Main.storyboardc/
42
+ Payload/pliney-test.app/Base.lproj/Main.storyboardc/Info.plist
43
+ Payload/pliney-test.app/Base.lproj/Main.storyboardc/UIViewController-vXZ-lx-hvc.nib
44
+ Payload/pliney-test.app/Base.lproj/Main.storyboardc/vXZ-lx-hvc-view-kh9-bI-dsS.nib
45
+ Payload/pliney-test.app/Info.plist
46
+ Payload/pliney-test.app/PkgInfo
47
+ Payload/pliney-test.app/_CodeSignature/
48
+ Payload/pliney-test.app/_CodeSignature/CodeResources
49
+ Payload/pliney-test.app/embedded.mobileprovision
50
+ Payload/pliney-test.app/pliney-test
51
+ ]
52
+ end
53
+
54
+ it "reads the provisioning profile" do
55
+ @ipa.provisioning_profile.should be_a Pliney::ProvisioningProfile
56
+ @ipa.provisioning_profile.name.should == "Pliney Test Profile"
57
+ end
58
+
59
+ it "reads the executable object"
60
+
61
+ it "reads the entitlements"
62
+
63
+ end
64
+
Binary file
@@ -0,0 +1,50 @@
1
+ require 'pathname'
2
+ require 'open3'
3
+ $SPECROOT = Pathname(__FILE__).dirname
4
+ require 'tmpdir'
5
+ require 'tempfile'
6
+ require 'rubygems'
7
+ require 'rspec'
8
+ require 'pry'
9
+
10
+ $LOAD_PATH << $SPECROOT.join("..", "lib").expand_path
11
+ require 'pliney'
12
+
13
+
14
+ RSpec.configure do |config|
15
+ config.expect_with :rspec do |c|
16
+ c.syntax = [:should, :expect]
17
+ end
18
+
19
+ def sample_file(filename)
20
+ $SPECROOT.join("samples", filename)
21
+ end
22
+
23
+ def relative_paths(paths, reldir)
24
+ paths.map{|p| Pathname(p).relative_path_from(Pathname(reldir)).to_s}
25
+ end
26
+
27
+ def spec_logger
28
+ $logger ||=
29
+ if ENV["SPEC_LOGGING"]
30
+ logger = Logger.new($stdout)
31
+ #logger.level = Logger::INFO
32
+ logger
33
+ end
34
+ end
35
+
36
+ def shell_pipe(data, cmd)
37
+ ret=nil
38
+ Open3.popen3(cmd) do |w,r,e|
39
+ w.write data
40
+ w.close
41
+ ret = r.read
42
+ r.close
43
+ end
44
+ return ret
45
+ end
46
+ end
47
+
48
+ if ENV["GC_STRESS"]
49
+ GC.stress = true
50
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pliney
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eric Monti
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rubyzip
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: CFPropertyList
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
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: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
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: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Includes various helpers and interfaces for working with IPA files, mobileprovisioning,
98
+ and other formats related Apple iOS apps.
99
+ email:
100
+ - esmonti@gmail.com
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - .rspec
107
+ - .travis.yml
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/pliney.rb
113
+ - lib/pliney/entitlements.rb
114
+ - lib/pliney/ipa.rb
115
+ - lib/pliney/provisioning_profile.rb
116
+ - lib/pliney/util.rb
117
+ - lib/pliney/version.rb
118
+ - pliney.gemspec
119
+ - spec/ipa_spec.rb
120
+ - spec/samples/pliney-test.ipa
121
+ - spec/spec_helper.rb
122
+ homepage: ''
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>='
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - '>='
138
+ - !ruby/object:Gem::Version
139
+ version: '0'
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.4.1
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: Pliney is for working with Apple IPA files
146
+ test_files:
147
+ - spec/ipa_spec.rb
148
+ - spec/samples/pliney-test.ipa
149
+ - spec/spec_helper.rb