apk 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,8 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
+ gem 'rubyzip'
5
+
4
6
  group :test do
5
7
  gem 'rspec'
6
8
  gem 'autotest'
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- apk (0.1)
4
+ apk (0.1.1)
5
+ rubyzip
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
@@ -19,6 +20,7 @@ GEM
19
20
  rspec-expectations (2.11.2)
20
21
  diff-lcs (~> 1.1.3)
21
22
  rspec-mocks (2.11.1)
23
+ rubyzip (0.9.9)
22
24
 
23
25
  PLATFORMS
24
26
  ruby
@@ -28,3 +30,4 @@ DEPENDENCIES
28
30
  autotest
29
31
  rake
30
32
  rspec
33
+ rubyzip
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
 
18
+ s.add_runtime_dependency "rubyzip"
18
19
  s.add_development_dependency "rake"
19
20
  s.add_development_dependency "rspec"
20
21
  s.add_development_dependency "autotest"
data/bin/apk CHANGED
@@ -4,3 +4,5 @@ require 'apk'
4
4
 
5
5
  apk = APK.new ARGV[0]
6
6
  puts apk.name
7
+
8
+ puts apk.drawable('ic_launcher.png')
@@ -1,4 +1,4 @@
1
- class APK
1
+ module Android
2
2
  class AAPT
3
3
  @@aapt = File.dirname(__FILE__) + "/../binaries/aapt"
4
4
  attr_reader :apk
@@ -0,0 +1,26 @@
1
+ require 'zip/zipfilesystem'
2
+
3
+ module Android
4
+ class Resource
5
+
6
+ attr_reader :apk
7
+
8
+ def initialize(apk_path)
9
+ @apk = apk_path
10
+ end
11
+
12
+ def extract(res, dst)
13
+ Zip::ZipFile.open(@apk) do |zipfile|
14
+ %w[xxhdpi xhdpi hdpi mdpi ldpi].each do |s|
15
+ break unless zipfile.each do |file|
16
+ if "res/drawable-#{s}/#{res}" == file.name
17
+ zipfile.extract(file, dst)
18
+ break
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
data/lib/apk.rb CHANGED
@@ -1,14 +1,22 @@
1
- require 'apk/aapt'
1
+ require 'android/aapt'
2
+ require 'android/resource'
2
3
 
3
4
  class APK
5
+ include Android
4
6
 
5
- attr_reader :apk, :aapt
7
+ attr_reader :apk, :aapt, :resource
6
8
 
7
9
  def initialize(apk_path)
8
10
  @apk = apk_path
9
11
  @aapt = AAPT.new(@apk)
12
+ @resource = Resource.new(@apk)
10
13
  end
11
14
 
15
+ def drawable(name = "icon.png")
16
+ dst = "/tmp/ruby-apk-#{Time.now.to_i}"
17
+ @resource.extract(name, dst)
18
+ dst
19
+ end
12
20
 
13
21
  def method_missing(method, *args, &block)
14
22
  @aapt.dump[method]
@@ -1,3 +1,3 @@
1
1
  class APK
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,6 +11,22 @@ bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-08-03 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rubyzip
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -76,8 +92,9 @@ files:
76
92
  - Rakefile
77
93
  - apk.gemspec
78
94
  - bin/apk
95
+ - lib/android/aapt.rb
96
+ - lib/android/resource.rb
79
97
  - lib/apk.rb
80
- - lib/apk/aapt.rb
81
98
  - lib/apk/version.rb
82
99
  - lib/binaries/aapt
83
100
  - spec/spec_helper.rb