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 +2 -0
- data/Gemfile.lock +4 -1
- data/apk.gemspec +1 -0
- data/bin/apk +2 -0
- data/lib/{apk → android}/aapt.rb +1 -1
- data/lib/android/resource.rb +26 -0
- data/lib/apk.rb +10 -2
- data/lib/apk/version.rb +1 -1
- metadata +19 -2
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -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
|
data/apk.gemspec
CHANGED
@@ -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
data/lib/{apk → android}/aapt.rb
RENAMED
@@ -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 '
|
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]
|
data/lib/apk/version.rb
CHANGED
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.
|
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
|