acouchi 0.0.8 → 0.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/acouchi.gemspec CHANGED
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
19
19
  gem.add_runtime_dependency "httparty"
20
20
  gem.add_runtime_dependency "childprocess"
21
21
  gem.add_runtime_dependency "nokogiri"
22
+ gem.add_runtime_dependency "ptools"
22
23
  end
@@ -6,11 +6,6 @@ module Acouchi
6
6
  def initialize apk
7
7
  @apk = apk
8
8
  @output_path = "#{Dir.tmpdir}/#{SecureRandom.uuid}/"
9
-
10
- unless apktool
11
- puts "Couldn't find a valid apktool. Please install apktool from http://code.google.com/p/android-apktool/"
12
- exit
13
- end
14
9
  end
15
10
 
16
11
  def modify_manifest
@@ -28,21 +23,17 @@ module Acouchi
28
23
  end
29
24
 
30
25
  private
31
- def apktool
32
- @apktool ||= Which.find_executable("apktool.bat", "apktool")
33
- end
34
-
35
26
  def decompile_apk
36
- ProcessLauncher.new(apktool, "d", @apk, @output_path).with_inherited_io.start_and_crash_if_process_fails
27
+ ProcessLauncher.new(Executables.apktool, "d", @apk, @output_path).with_inherited_io.start_and_crash_if_process_fails
37
28
  end
38
29
 
39
30
  def compile_apk
40
- ProcessLauncher.new(apktool, "b", @output_path).with_inherited_io.start_and_crash_if_process_fails
31
+ ProcessLauncher.new(Executables.apktool, "b", @output_path).with_inherited_io.start_and_crash_if_process_fails
41
32
  end
42
33
 
43
34
  def sign_apk_in_debug_mode
44
35
  @new_apk = File.join(@output_path, "dist", File.basename(@apk))
45
- jarsigner = Which.which?("jarsigner.exe") || Which.which?("jarsigner")
36
+ jarsigner = Executables.jarsigner
46
37
  debug_keystore = File.join(ENV["HOME"], ".android", "debug.keystore")
47
38
  ProcessLauncher.new(
48
39
  jarsigner,
@@ -1,7 +1,19 @@
1
1
  module Acouchi
2
2
  class Executables
3
3
  def self.adb
4
- @adb ||= Which.find_executable("adb.exe", "adb")
4
+ @adb ||= Which.find_executable("adb")
5
+ end
6
+
7
+ def self.jarsigner
8
+ @jarsigner ||= Which.find_executable("jarsigner")
9
+ end
10
+
11
+ def self.apktool
12
+ @apktool ||= Which.find_executable("apktool")
13
+ end
14
+
15
+ def self.ant
16
+ @ant ||= Which.find_executable("ant")
5
17
  end
6
18
  end
7
19
  end
@@ -75,13 +75,9 @@ module Acouchi
75
75
  end
76
76
  end
77
77
 
78
- def ant
79
- Which.find_executable("ant.bat", "ant")
80
- end
81
-
82
78
  def build_apk
83
79
  Dir.chdir configuration.project_path do
84
- ProcessLauncher.new(ant, "clean", "debug").with_inherited_io.start_and_crash_if_process_fails
80
+ ProcessLauncher.new(Executables.ant, "clean", "debug").with_inherited_io.start_and_crash_if_process_fails
85
81
  end
86
82
  end
87
83
  end
@@ -13,9 +13,7 @@ module Acouchi
13
13
  @test_runner_process = ProcessLauncher.new(Executables.adb, "shell", "am", "instrument", "-w", "#{@configuration.target_package}/android.test.InstrumentationTestRunner")
14
14
  @test_runner_process.start_in_background
15
15
 
16
- while ready? == false
17
- sleep 0.1
18
- end
16
+ sleep 0.1 until ready?
19
17
  end
20
18
 
21
19
  def stop
@@ -1,3 +1,3 @@
1
1
  module Acouchi
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/acouchi/which.rb CHANGED
@@ -1,29 +1,12 @@
1
1
  module Acouchi
2
2
  class Which
3
- def self.find_executable *aliases
4
- if executable = aliases.find {|a| which? a}
3
+ def self.find_executable name
4
+ require "ptools"
5
+ if executable = File.which(name)
5
6
  executable
6
7
  else
7
8
  raise %{Couldn't find any matches for the aliases "#{aliases.join(", ")}"}
8
9
  end
9
10
  end
10
-
11
- private
12
- def self.which? command
13
- ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
14
- exe = File.join(path, "#{command}")
15
- return exe if executable? exe
16
- end
17
- return nil
18
- end
19
-
20
- def self.executable? file
21
- return true if File.executable?(file)
22
- extensions = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : []
23
- File.exist?(file) &&
24
- File.file?(file) &&
25
- extensions.any? &&
26
- extensions.any? {|e| file.downcase.end_with?(e.downcase)}
27
- end
28
11
  end
29
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acouchi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -59,6 +59,22 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: ptools
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
62
78
  description: ''
63
79
  email:
64
80
  - andrew.vos@gmail.com