calabash-android 0.4.11 → 0.4.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ae8b62c4272f7b9020684225f343bb896f354a8
4
- data.tar.gz: f596a210e3ad40656783d0174482ac17fafd2b09
3
+ metadata.gz: ea33bf7b6030fbe284b0767a1c2ccde479b6e205
4
+ data.tar.gz: c791819581eb688c720d9e2bfb9435ff7bc8b4ed
5
5
  SHA512:
6
- metadata.gz: 66430400d7d116d285aa533536920b2dab21defe398ee90a739ef700de8c04e6620a629395aff05f92fab022b330ee3de062761f2df2c9b6ac21fada5318f5fd
7
- data.tar.gz: d6401fdd17e1b785f9febc9b3c4afc319dd1e81d34b7f63767e22bef99a2898530bdc17ab60dc945d2da8ef2763ee44d1a70d0f3e85a72e0e55bc14488ff8a63
6
+ metadata.gz: 35b79d51f4e4402a2979df09eec441aa7edabaa8a5be505d75e7f8bbdd1a126aab888334730876d47075d86e36ce86a6afedc11f64edf8265308511a7b0fb826
7
+ data.tar.gz: c4c75abf90229fbe0f2cbc084a34ff75d8938fa656a13a59ac4b5e9e9469103cfcaf98d2c1266ccbf5ed01456fc3e6e3ec0762a054fe989bd1ffcb2bdb33e104
data/Gemfile.lock CHANGED
@@ -1,13 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- calabash-android (0.4.10.pre4)
4
+ calabash-android (0.4.12)
5
5
  awesome_print
6
6
  cucumber
7
7
  escape (~> 0.0.4)
8
8
  httpclient (~> 2.3.2)
9
9
  json
10
- retriable
10
+ retriable (~> 1.3.3.1)
11
11
  rubyzip (~> 0.9.9)
12
12
  slowhandcuke
13
13
  xamarin-test-cloud (>= 0.9.23)
@@ -15,7 +15,7 @@ PATH
15
15
  GEM
16
16
  remote: http://rubygems.org/
17
17
  specs:
18
- awesome_print (1.1.0)
18
+ awesome_print (1.2.0)
19
19
  builder (3.2.2)
20
20
  cucumber (1.3.8)
21
21
  builder (>= 2.1.2)
@@ -40,7 +40,7 @@ GEM
40
40
  slowhandcuke (0.0.3)
41
41
  cucumber
42
42
  thor (0.18.1)
43
- xamarin-test-cloud (0.9.23)
43
+ xamarin-test-cloud (0.9.25)
44
44
  bundler (>= 1.3.0, < 2.0)
45
45
  json
46
46
  rest-client (~> 1.6.7)
data/bin/calabash-android CHANGED
@@ -51,13 +51,6 @@ def relative_to_full_path(file_path)
51
51
  File.expand_path(file_path)
52
52
  end
53
53
 
54
- def exit_if_android_sdk_not_found
55
- unless File.exists?(Env.android_home_path || "")
56
- puts "Please set ANDROID_HOME to point to the Android SDK"
57
- exit 1
58
- end
59
- end
60
-
61
54
  if (ARGV.length == 0)
62
55
  print_usage
63
56
  end
@@ -65,13 +58,13 @@ cmd = ARGV.shift
65
58
  if cmd == 'help'
66
59
  print_help
67
60
  elsif cmd == 'build'
68
- exit_if_android_sdk_not_found
61
+ Env.exit_if_env_not_set_up
69
62
  puts "Please specify the app you want to build a test server for" if (ARGV.empty? or not is_apk_file?(ARGV.first))
70
63
  while not ARGV.empty? and is_apk_file?(ARGV.first)
71
64
  calabash_build(relative_to_full_path(ARGV.shift))
72
65
  end
73
66
  elsif cmd == 'run'
74
- exit_if_android_sdk_not_found
67
+ Env.exit_if_env_not_set_up
75
68
  if ARGV.empty? or not is_apk_file?(ARGV.first)
76
69
  exit calabash_run()
77
70
  else
@@ -80,6 +73,7 @@ elsif cmd == 'run'
80
73
  elsif cmd == 'gen'
81
74
  calabash_scaffold
82
75
  elsif cmd == 'console'
76
+ Env.exit_if_env_not_set_up
83
77
  if ARGV.empty?
84
78
  puts "Please specify an app"
85
79
  exit 1
@@ -90,9 +84,10 @@ elsif cmd == 'console'
90
84
  end
91
85
  calabash_console(relative_to_full_path(ARGV.shift))
92
86
  elsif cmd == 'setup'
93
- exit_if_android_sdk_not_found
87
+ Env.exit_if_env_not_set_up
94
88
  calabash_setup
95
89
  elsif cmd == 'extract-manifest'
90
+ Env.exit_if_env_not_set_up
96
91
  if ARGV.empty?
97
92
  puts "Please specify an app"
98
93
  exit 1
@@ -1,21 +1,89 @@
1
+
1
2
  class Env
3
+ require 'win32/registry' if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
4
+
5
+ def self.exit_if_env_not_set_up
6
+ exit_unless_jdk_is_available
7
+ exit_unless_android_sdk_is_available
8
+ end
9
+
10
+ def self.exit_unless_android_sdk_is_available
11
+ if android_home_path
12
+ log "Android SDK found at: #{android_home_path}"
13
+ return
14
+ end
15
+ puts "Could not find an Android SDK please make sure it is installed."
16
+ puts "You can read about how Calabash-Android is searching for an Android SDK and how you can help here:"
17
+ puts "https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites"
18
+ exit 1
19
+ end
2
20
 
3
21
  def self.keytool_path
22
+ find_executable_on_path(keytool_executable) ||
23
+ "\"#{jdk_path}/bin/#{keytool_executable}\""
24
+ end
25
+
26
+ def self.exit_unless_jdk_is_available
27
+ jdk = jdk_path
28
+ if find_executable_on_path(keytool_executable) || jdk
29
+ log "JDK found on PATH." if find_executable_on_path(keytool_executable)
30
+ log "JDK found at: #{jdk}" if jdk
31
+ return
32
+ end
33
+ puts "Could not find Java Development Kit please make sure it is installed."
34
+ puts "You can read about how Calabash-Android is searching for a JDK and how you can help here:"
35
+ puts "https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites"
36
+ exit 1
37
+ end
38
+
39
+ def self.jarsigner_path
40
+ find_executable_on_path(jarsigner_executable) ||
41
+ "\"#{jdk_path}/bin/#{jarsigner_executable}\""
42
+ end
43
+
44
+ def self.jdk_path
45
+ path_if_jdk(ENV['JAVA_HOME']) ||
4
46
  if is_windows?
5
- "\"#{ENV["JAVA_HOME"]}/bin/keytool.exe\""
47
+ path_if_jdk(read_registry(::Win32::Registry::HKEY_LOCAL_MACHINE, 'SOFTWARE\\JavaSoft\\Java Development Kit\\1.7', 'JavaHome')) ||
48
+ path_if_jdk(read_registry(::Win32::Registry::HKEY_LOCAL_MACHINE, 'SOFTWARE\\JavaSoft\\Java Development Kit\\1.6', 'JavaHome'))
6
49
  else
7
- "keytool"
50
+ path_if_android_home(read_attribute_from_monodroid_config('java-sdk', 'path'))
8
51
  end
9
52
  end
10
53
 
11
- def self.jarsigner_path
54
+ def self.android_home_path
55
+ path_if_android_home(ENV["ANDROID_HOME"]) ||
12
56
  if is_windows?
13
- "\"#{ENV["JAVA_HOME"]}/bin/jarsigner.exe\""
57
+ path_if_android_home(read_registry(::Win32::Registry::HKEY_LOCAL_MACHINE, 'SOFTWARE\\Android SDK Tools', 'Path')) ||
58
+ path_if_android_home("C:\\Android\\android-sdk")
14
59
  else
15
- "jarsigner"
60
+ path_if_android_home(read_attribute_from_monodroid_config('android-sdk', 'path'))
16
61
  end
17
62
  end
18
63
 
64
+ def self.find_executable_on_path(executable)
65
+ path = path_elements.each do |x|
66
+ f = File.join(x, executable)
67
+ return "\"#{f}\"" if File.exists?(f)
68
+ end
69
+ end
70
+
71
+ def self.path_if_jdk(path)
72
+ path if path && File.exists?(File.join(path, 'bin', jarsigner_executable))
73
+ end
74
+
75
+ def self.jarsigner_executable
76
+ is_windows? ? 'jarsigner.exe' : 'jarsigner'
77
+ end
78
+
79
+ def self.keytool_executable
80
+ is_windows? ? 'keytool.exe' : 'keytool'
81
+ end
82
+
83
+ def self.adb_executable
84
+ is_windows? ? 'adb.exe' : 'adb'
85
+ end
86
+
19
87
  def self.ant_path
20
88
  is_windows? ? "ant.bat" : "ant"
21
89
  end
@@ -32,21 +100,28 @@ class Env
32
100
  end
33
101
  end
34
102
 
35
- def self.adb
36
- %Q("#{android_home_path}/platform-tools/adb")
103
+ def self.adb_path
104
+ %Q("#{android_home_path}/platform-tools/#{adb_executable}")
105
+ end
106
+
107
+ def self.path_if_android_home(path)
108
+ path if path && File.exists?(File.join(path, 'platform-tools', adb_executable))
37
109
  end
38
110
 
39
- def self.android_home_path
40
- return ENV["ANDROID_HOME"] if ENV["ANDROID_HOME"]
111
+ def self.path_elements
112
+ return [] unless ENV['PATH']
113
+ ENV['PATH'].split (/[:;]/)
114
+ end
115
+
116
+ def self.read_attribute_from_monodroid_config(element, attribute)
41
117
  monodroid_config_file = File.expand_path("~/.config/xbuild/monodroid-config.xml")
42
118
  if File.exists?(monodroid_config_file)
43
119
  require 'rexml/document'
44
120
  begin
45
- return REXML::Document.new(IO.read(monodroid_config_file)).elements["//android-sdk"].attributes["path"]
121
+ return REXML::Document.new(IO.read(monodroid_config_file)).elements["//#{element}"].attributes[attribute]
46
122
  rescue
47
123
  end
48
124
  end
49
- nil
50
125
  end
51
126
 
52
127
  def self.android_platform_path
@@ -57,4 +132,12 @@ class Env
57
132
  end
58
133
  end
59
134
 
135
+ def self.read_registry(root_key, key, value)
136
+ begin
137
+ root_key.open(key)[value]
138
+ rescue
139
+ nil
140
+ end
141
+ end
142
+
60
143
  end
@@ -402,7 +402,7 @@ module Operations
402
402
  end
403
403
 
404
404
  def adb_command
405
- "#{Env.adb} -s #{serial}"
405
+ "#{Env.adb_path} -s #{serial}"
406
406
  end
407
407
 
408
408
  def default_serial
@@ -439,7 +439,7 @@ module Operations
439
439
  end
440
440
 
441
441
  def connected_devices
442
- lines = `#{Env.adb} devices`.split("\n")
442
+ lines = `#{Env.adb_path} devices`.split("\n")
443
443
  lines.shift
444
444
  lines.collect { |l| l.split("\t").first}
445
445
  end
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.4.11"
3
+ VERSION = "0.4.12"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.11
4
+ version: 0.4.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonas Maturana Larsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-20 00:00:00.000000000 Z
11
+ date: 2013-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber