lagunitas 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: 6c35cf7cdf9ef1343a43710c6dab81afa91263a3
4
+ data.tar.gz: adfd3a81d4ee4de86d1ecc15c8f861b95f00df8f
5
+ SHA512:
6
+ metadata.gz: a905e0768b5b2803786ec9ebf752cdf68f7667ae95afe3c8ded92e169a5bd40fc5fea77d3a231b20bd091a8859c4be70ac037649d671a45136a80ca130820a7c
7
+ data.tar.gz: 93a078e24a3bc2eb45b53f2b3129b3985eb9ab83d9701e440a8e06c0b1fcd463fae70c9b7ecf8cb25bbd9894855199a62062b25a80c0af6456f142288246a177
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rake'
6
+ gem 'minitest'
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sam Soffes, http://soff.es
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/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << 'test'
7
+ t.pattern = 'test/**/*_test.rb'
8
+ end
9
+ task default: :test
data/Readme.markdown ADDED
@@ -0,0 +1,29 @@
1
+ # Lagunitas
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'lagunitas'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install lagunitas
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/lagunitas.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 'lagunitas/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'lagunitas'
8
+ spec.version = Lagunitas::VERSION
9
+ spec.authors = ['Sam Soffes']
10
+ spec.email = ['sam@soff.es']
11
+ spec.description = 'Easy iOS IPAs inspection.'
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/soffes/lagunitas'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
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.3'
22
+
23
+ spec.add_dependency 'zip'
24
+ spec.add_dependency 'CFPropertyList'
25
+ spec.add_dependency 'pngdefry', '>= 0.1.0'
26
+
27
+ spec.add_development_dependency 'rake'
28
+ end
@@ -0,0 +1,64 @@
1
+ require 'cfpropertylist'
2
+ require 'pngdefry'
3
+
4
+ module Lagunitas
5
+ class App
6
+ def initialize(path)
7
+ @path = path
8
+ end
9
+
10
+ def info
11
+ @info ||= CFPropertyList.native_types(CFPropertyList::List.new(file: File.join(@path, 'Info.plist')).value)
12
+ end
13
+
14
+ def identifier
15
+ info['CFBundleIdentifier']
16
+ end
17
+
18
+ def display_name
19
+ info['CFBundleDisplayName']
20
+ end
21
+
22
+ def version
23
+ info['CFBundleVersion']
24
+ end
25
+
26
+ def short_version
27
+ info['CFBundleShortVersionString']
28
+ end
29
+
30
+ def icon(size)
31
+ icons.each do |icon|
32
+ return icon[:path] if icon[:width] >= size
33
+ end
34
+ nil
35
+ end
36
+
37
+ def icons
38
+ @icons ||= begin
39
+ icons = []
40
+ info['CFBundleIcons']['CFBundlePrimaryIcon']['CFBundleIconFiles'].each do |name|
41
+ icons << get_image(name)
42
+ icons << get_image("#{name}@2x")
43
+ end
44
+ icons.delete_if { |i| !i }
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def get_image(name)
51
+ path = File.join(@path, "#{name}.png")
52
+ return nil unless File.exist?(path)
53
+
54
+ dimensions = Pngdefry.dimensions(path)
55
+ {
56
+ path: path,
57
+ width: dimensions.first,
58
+ height: dimensions.last
59
+ }
60
+ rescue Errno::ENOENT
61
+ nil
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,41 @@
1
+ require 'zip'
2
+ require 'fileutils'
3
+
4
+ module Lagunitas
5
+ class IPA
6
+ def initialize(path)
7
+ @path = path
8
+ end
9
+
10
+ def app
11
+ @app ||= App.new(app_path)
12
+ end
13
+
14
+ def app_path
15
+ @app_path ||= Dir.glob(File.join(contents, 'Payload', '*.app')).first
16
+ end
17
+
18
+ def cleanup
19
+ return unless @contents
20
+ FileUtils.rm_rf(@contents)
21
+ @contents = nil
22
+ end
23
+
24
+ private
25
+
26
+ def contents
27
+ return if @contents
28
+ @contents = "tmp/lagunitas-#{SecureRandom.hex}"
29
+
30
+ Zip::ZipFile.open(@path) do |zip_file|
31
+ zip_file.each do |f|
32
+ f_path = File.join(@contents, f.name)
33
+ FileUtils.mkdir_p(File.dirname(f_path))
34
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
35
+ end
36
+ end
37
+
38
+ @contents
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,3 @@
1
+ module Lagunitas
2
+ VERSION = '0.0.1'
3
+ end
data/lib/lagunitas.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'lagunitas/version'
2
+
3
+ module Lagunitas
4
+ end
5
+
6
+ require 'lagunitas/ipa'
7
+ require 'lagunitas/app'
Binary file
@@ -0,0 +1,35 @@
1
+ require 'test_helper'
2
+
3
+ module Lagunitas
4
+ class AppTest < TestCase
5
+ def setup
6
+ @ipa = Lagunitas::IPA.new('test/data/Sample.ipa')
7
+ @app = @ipa.app
8
+ end
9
+
10
+ def test_identifier
11
+ assert_equal 'com.samsoffes.Sample', @app.identifier
12
+ end
13
+
14
+ def test_display_name
15
+ assert_equal 'Sample', @app.display_name
16
+ end
17
+
18
+ def test_version
19
+ assert_equal '13', @app.version
20
+ end
21
+
22
+ def test_short_version
23
+ assert_equal '2.2', @app.short_version
24
+ end
25
+
26
+ def test_icons
27
+ assert_includes @app.icon(120), 'AppIcon60x60@2x.png'
28
+ assert_nil @app.icon(1024)
29
+ end
30
+
31
+ def teardown
32
+ @ipa.cleanup if @ipa
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,17 @@
1
+ require 'test_helper'
2
+
3
+ module Lagunitas
4
+ class IPATest < TestCase
5
+ def setup
6
+ @ipa = Lagunitas::IPA.new('test/data/Sample.ipa')
7
+ end
8
+
9
+ def test_app_path
10
+ assert_includes @ipa.app_path, 'Sample.app'
11
+ end
12
+
13
+ def teardown
14
+ @ipa.cleanup if @ipa
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module Lagunitas
4
+ class LagunitasTest < TestCase
5
+ def test_that_it_has_a_version_number
6
+ refute_nil VERSION
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.require :test
4
+
5
+ require 'minitest/autorun'
6
+ require 'lagunitas'
7
+
8
+ # Support files
9
+ Dir["#{File.expand_path(File.dirname(__FILE__))}/support/*.rb"].each do |file|
10
+ require file
11
+ end
12
+
13
+ class Lagunitas::TestCase < MiniTest::Test
14
+ include Lagunitas
15
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lagunitas
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sam Soffes
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-02 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: zip
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: CFPropertyList
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: pngdefry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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
+ description: Easy iOS IPAs inspection.
84
+ email:
85
+ - sam@soff.es
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - .gitignore
91
+ - Gemfile
92
+ - LICENSE
93
+ - Rakefile
94
+ - Readme.markdown
95
+ - lagunitas.gemspec
96
+ - lib/lagunitas.rb
97
+ - lib/lagunitas/app.rb
98
+ - lib/lagunitas/ipa.rb
99
+ - lib/lagunitas/version.rb
100
+ - test/data/Sample.ipa
101
+ - test/lagunitas/app_test.rb
102
+ - test/lagunitas/ipa_test.rb
103
+ - test/lagunitas_test.rb
104
+ - test/test_helper.rb
105
+ homepage: https://github.com/soffes/lagunitas
106
+ licenses:
107
+ - MIT
108
+ metadata: {}
109
+ post_install_message:
110
+ rdoc_options: []
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ requirements: []
124
+ rubyforge_project:
125
+ rubygems_version: 2.0.3
126
+ signing_key:
127
+ specification_version: 4
128
+ summary: Easy iOS IPAs inspection.
129
+ test_files:
130
+ - test/data/Sample.ipa
131
+ - test/lagunitas/app_test.rb
132
+ - test/lagunitas/ipa_test.rb
133
+ - test/lagunitas_test.rb
134
+ - test/test_helper.rb