apophis 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5328908f29d5a0aee3ae2c839f319d8b624c31d4
4
- data.tar.gz: 02b4adda6130ae5e245851b94d4857094f32ff00
3
+ metadata.gz: 50f56e95831b8061ce7ae629bc4af6ce64202fd9
4
+ data.tar.gz: 73ccf637b6adb5ea926e3f7663f5e010935d4caf
5
5
  SHA512:
6
- metadata.gz: be62a539b8bf2d0ce6f9022ba51324c0d5ca8e2dad47877172a0709e31774c9eb39735e84a14e7ed700df06c8a333fe1f00a8aec9da004761760b9fde85b4e0e
7
- data.tar.gz: 180616985cebf8e883cbace2b936ea8848efb0b8f1e5930bbea7d3ff6aa3f36805b76b623d3e542a9b6e387cca51aabc3423ea959f66e74947ec35a2eba9e0e5
6
+ metadata.gz: 464d5cb83823c08880ac0e66570e4c4ec55d0a303426f060cf55500a6895aae5bc94c41bef55e838bfd23b239a9b0308d9da8744d01a3059faa5a0e1e6027c1a
7
+ data.tar.gz: c787e49d56d4fe0c89cce2215deca4c0c7b017b325c8bc40b3179a6fdc482723b7339793e673ea4a543c5da9a44c15beb8954b5f070d19e49e343f0ebe7b33e1
@@ -1,71 +1,73 @@
1
1
  require 'open-uri'
2
2
 
3
- class AppiumRunner
3
+ module Apophis
4
+ class AppiumRunner
4
5
 
5
- def doctor!
6
- errors = []
7
- errors << "No valid appium install, or not available to this environment." unless system('appium -v > /dev/null')
8
- errors << "No valid unix tooling: lsof" unless system('lsof -v > /dev/null 2>&1')
6
+ def doctor!
7
+ errors = []
8
+ errors << "No valid appium install, or not available to this environment." unless system('appium -v > /dev/null')
9
+ errors << "No valid unix tooling: lsof" unless system('lsof -v > /dev/null 2>&1')
9
10
 
10
- raise errors.join("\n") unless errors.empty?
11
- end
11
+ raise errors.join("\n") unless errors.empty?
12
+ end
12
13
 
13
- def any?
14
- appiums.size > 0
15
- end
14
+ def any?
15
+ appiums.size > 0
16
+ end
16
17
 
17
- def available?(port)
18
- return false unless port
19
- !!find(port)
20
- end
18
+ def available?(port)
19
+ return false unless port
20
+ !!find(port)
21
+ end
21
22
 
22
- def kill_and_wait(port, timeout=10)
23
- DottyTimeout.timeout(timeout) do
24
- kill(port)
25
- !available?(port)
23
+ def kill_and_wait(port, timeout=10)
24
+ DottyTimeout.timeout(timeout) do
25
+ kill(port)
26
+ !available?(port)
27
+ end
26
28
  end
27
- end
28
29
 
29
- def kill(port)
30
- app = find(port)
31
- return unless app
32
- Process.kill('KILL', app[:pid])
33
- end
30
+ def kill(port)
31
+ app = find(port)
32
+ return unless app
33
+ Process.kill('KILL', app[:pid])
34
+ end
34
35
 
35
- def find(port)
36
- appiums.find{|app| app[:url] =~ /:#{port}/}
37
- end
36
+ def find(port)
37
+ appiums.find{|app| app[:url] =~ /:#{port}/}
38
+ end
38
39
 
39
- def launch_and_wait(port=nil, timeout=20)
40
- port = port || find_available_port(4500)
40
+ def launch_and_wait(port=nil, timeout=20)
41
+ port = port || find_available_port(4500)
41
42
 
42
- #we'll use the env variable later to locate this process (`ps -p <PID> -wwwE`)
43
- Process.spawn("APOPHIS_TAG=#{port} appium -p #{port} -bp #{port+1} > /dev/null 2>&1")
44
- DottyTimeout.timeout(timeout){ available?(port) }
43
+ #we'll use the env variable later to locate this process (`ps -p <PID> -wwwE`)
44
+ Process.spawn("APOPHIS_TAG=#{port} appium -p #{port} -bp #{port+1} > /dev/null 2>&1")
45
+ DottyTimeout.timeout(timeout){ available?(port) }
45
46
 
46
- { port: port }
47
- end
47
+ { port: port }
48
+ end
48
49
 
49
- def probe(candidate)
50
- begin
51
- Timeout.timeout(0.5) do
52
- res = JSON.parse(open("#{ candidate }/status").read)
53
- !!res["value"]
50
+ def probe(candidate)
51
+ begin
52
+ Timeout.timeout(0.5) do
53
+ res = JSON.parse(open("#{ candidate }/status").read)
54
+ !!res["value"]
55
+ end
56
+ rescue Exception => _
57
+ false
54
58
  end
55
- rescue Exception => _
56
- false
57
59
  end
58
- end
59
60
 
60
- def find_available_port(above)
61
- Selenium::WebDriver::PortProber.above(above)
62
- end
61
+ def find_available_port(above)
62
+ Selenium::WebDriver::PortProber.above(above)
63
+ end
63
64
 
64
- def appiums
65
- `lsof -P -n -i -sTCP:LISTEN`.lines.map(&:chomp) \
66
- .map{|ln| ln =~ /\D+\s(\d+)\s.*TCP\s+(.*):(\d+)\s+\(LISTEN\)/; { pid: $1.to_i, url: "http://#{$2}:#{$3}/wd/hub".sub('*', 'localhost')} }
67
- .select{|app| app[:pid] > 0}
68
- .select{|app| probe(app[:url])}
65
+ def appiums
66
+ `lsof -P -n -i -sTCP:LISTEN`.lines.map(&:chomp) \
67
+ .map{|ln| ln =~ /\D+\s(\d+)\s.*TCP\s+(.*):(\d+)\s+\(LISTEN\)/; { pid: $1.to_i, url: "http://#{$2}:#{$3}/wd/hub".sub('*', 'localhost')} }
68
+ .select{|app| app[:pid] > 0}
69
+ .select{|app| probe(app[:url])}
70
+ end
69
71
  end
70
72
  end
71
73
 
@@ -1,3 +1,3 @@
1
1
  module Apophis
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apophis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dotan Nahum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: appium_lib