hive-runner-ios 1.0.7 → 1.1.0
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 +4 -4
- data/lib/hive/controller/ios.rb +7 -109
- data/lib/hive/device/ios.rb +1 -38
- data/lib/hive/worker/ios.rb +25 -18
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7322752108ca0a24e22439273d2b832d65772393
|
4
|
+
data.tar.gz: b915a2528216af4bb9260f77f7e4dfe0f224379c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55436f90a7ae13ddd0477779b76d0cb9e1d9196d39dff1cbc65002931f434f2ab27015f240baee84b49913bd3ca326c6a568a854e9225e6941b69c4e27ff790d
|
7
|
+
data.tar.gz: 568c53aff2d74fa00c3f3c1f9b2aa6ba1e8d70753edabd3c9946cbdc518d8ed41461aa402bde70be9b740982c7a08c979c55c8636afae59fa2dc2ac9ae42c949
|
data/lib/hive/controller/ios.rb
CHANGED
@@ -6,70 +6,7 @@ module Hive
|
|
6
6
|
class Controller
|
7
7
|
class Ios < Controller
|
8
8
|
|
9
|
-
def
|
10
|
-
devices = DeviceAPI::IOS.devices
|
11
|
-
Hive.logger.debug('DDB: No devices attached') if devices.empty?
|
12
|
-
|
13
|
-
hive_details = Hive.devicedb('Hive').find(Hive.id)
|
14
|
-
|
15
|
-
attached_devices = []
|
16
|
-
|
17
|
-
if hive_details.key?('devices')
|
18
|
-
@hive_details = hive_details
|
19
|
-
else
|
20
|
-
hive_details = @hive_details
|
21
|
-
end
|
22
|
-
|
23
|
-
if hive_details.is_a? Hash
|
24
|
-
hive_details['devices'].select { |a| a['os'] == 'ios'}.each do |device|
|
25
|
-
registered_device = devices.select { |a| a.serial == device['serial'] && a.trusted? }
|
26
|
-
if registered_device.empty?
|
27
|
-
# A previously registered device isn't attached
|
28
|
-
Hive.devicedb('Device').hive_disconnect(device['id'])
|
29
|
-
else
|
30
|
-
Hive.devicedb('Device').poll(device['id'])
|
31
|
-
|
32
|
-
devices = devices - registered_device
|
33
|
-
|
34
|
-
begin
|
35
|
-
attached_devices <<
|
36
|
-
self.create_device(device.merge(
|
37
|
-
'os_version' => registered_device[0].version,
|
38
|
-
'model' => device['device_model'],
|
39
|
-
'device_range' => registered_device[0].device_class,
|
40
|
-
'queues' => device['device_queues'].map{ |d| d['name'] },
|
41
|
-
'queue_prefix' => @config['queue_prefix']
|
42
|
-
))
|
43
|
-
rescue => e
|
44
|
-
Hive.logger.warn("Error with connected device: #{e.message}")
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
devices.select {|a| a.trusted? }.each do |device|
|
49
|
-
register_new_device(device)
|
50
|
-
end
|
51
|
-
else
|
52
|
-
# DeviceDB isn't available, use DeviceAPI instead
|
53
|
-
device_info = devices.select { |a| a.trusted? }.map do |device|
|
54
|
-
{
|
55
|
-
'id' => device.serial,
|
56
|
-
'serial' => device.serial,
|
57
|
-
'status' => 'idle',
|
58
|
-
'model' => device.model,
|
59
|
-
'brand' => 'Apple',
|
60
|
-
'os_version' => device.version,
|
61
|
-
'queue_prefix' => @config['queue_prefix']
|
62
|
-
}
|
63
|
-
end
|
64
|
-
|
65
|
-
attached_devices = device_info.collect do |physical_device|
|
66
|
-
self.create_device(physical_device)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
attached_devices
|
70
|
-
end
|
71
|
-
|
72
|
-
def register_with_hivemind
|
9
|
+
def register
|
73
10
|
devices = DeviceAPI::IOS.devices
|
74
11
|
Hive.logger.debug('HM: No devices attached') if devices.empty?
|
75
12
|
|
@@ -138,7 +75,11 @@ module Hive
|
|
138
75
|
end
|
139
76
|
|
140
77
|
attached_devices = device_info.collect do |physical_device|
|
141
|
-
|
78
|
+
begin
|
79
|
+
self.create_device(physical_device)
|
80
|
+
rescue => e
|
81
|
+
Hive.logger.info("HM: Could not created device: #{physical_device}");
|
82
|
+
end
|
142
83
|
end
|
143
84
|
end
|
144
85
|
|
@@ -147,8 +88,7 @@ module Hive
|
|
147
88
|
end
|
148
89
|
|
149
90
|
def detect
|
150
|
-
|
151
|
-
register_with_devicedb
|
91
|
+
register
|
152
92
|
end
|
153
93
|
|
154
94
|
def display_untrusted
|
@@ -158,48 +98,6 @@ module Hive
|
|
158
98
|
return if untrusted_devices.empty?
|
159
99
|
puts Terminal::Table.new headings: ['Untrusted devices'], rows: [untrusted_devices]
|
160
100
|
end
|
161
|
-
|
162
|
-
def register_new_device(device)
|
163
|
-
Hive.logger.debug("Adding new iOS device: #{device.model}")
|
164
|
-
|
165
|
-
attributes = {
|
166
|
-
os: 'ios',
|
167
|
-
os_version: device.version,
|
168
|
-
serial: device.serial,
|
169
|
-
device_type: 'mobile',
|
170
|
-
device_model: device.model.to_s.gsub(',','_'),
|
171
|
-
device_range: device.device_class,
|
172
|
-
device_brand: 'Apple',
|
173
|
-
hive: Hive.id
|
174
|
-
}
|
175
|
-
|
176
|
-
registration = Hive.devicedb('Device').register(attributes)
|
177
|
-
Hive.devicedb('Device').hive_connect(registration['id'], Hive.id)
|
178
|
-
end
|
179
|
-
|
180
|
-
def populate_queues(device)
|
181
|
-
queues = calculate_queue_names(device)
|
182
|
-
|
183
|
-
devicedb_queues = device['device_queues'].map { |d| d['name'] }
|
184
|
-
# Check to see if the queues have already been registered with this device
|
185
|
-
missing_queues = (queues - devicedb_queues) + (devicedb_queues - queues)
|
186
|
-
return if missing_queues.empty?
|
187
|
-
|
188
|
-
queues << missing_queues
|
189
|
-
|
190
|
-
queue_ids = queues.flatten.uniq.map { |queue| find_or_create_queue(queue) }
|
191
|
-
|
192
|
-
values = {
|
193
|
-
name: device['name'],
|
194
|
-
hive_id: device['hive_id'],
|
195
|
-
feature_list: device['features'],
|
196
|
-
device_queue_ids: queue_ids
|
197
|
-
}
|
198
|
-
|
199
|
-
Hive.devicedb('Device').edit(device['id'], values)
|
200
|
-
end
|
201
|
-
|
202
|
-
|
203
101
|
end
|
204
102
|
end
|
205
103
|
end
|
data/lib/hive/device/ios.rb
CHANGED
@@ -12,45 +12,8 @@ module Hive
|
|
12
12
|
@device_range = config['device_range'].downcase
|
13
13
|
@os_version = config['os_version']
|
14
14
|
|
15
|
-
new_queues = calculate_queue_names
|
16
|
-
new_queues = new_queues | config['queues'] if config.has_key?('queues')
|
17
|
-
|
18
|
-
devicedb_ids = new_queues.map { |queue| find_or_create_queue(queue) }
|
19
|
-
Hive.devicedb('Device').edit(@identity, { device_queue_ids: devicedb_ids })
|
20
|
-
config['queues'] = new_queues
|
21
15
|
super
|
22
16
|
end
|
23
|
-
|
24
|
-
def calculate_queue_names
|
25
|
-
[
|
26
|
-
"#{@queue_prefix}#{self.model}",
|
27
|
-
"#{@queue_prefix}ios",
|
28
|
-
"#{@queue_prefix}ios-#{self.os_version}",
|
29
|
-
"#{@queue_prefix}ios-#{self.os_version}-#{self.model}",
|
30
|
-
"#{@queue_prefix}#{@device_range}",
|
31
|
-
"#{@queue_prefix}#{@device_range}-#{self.os_version}"
|
32
|
-
]
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def find_or_create_queue(name)
|
38
|
-
|
39
|
-
queue = Hive.devicedb('Queue').find_by_name(name)
|
40
|
-
return queue.first['id'] unless queue.empty? || queue.is_a?(Hash)
|
41
|
-
|
42
|
-
queue = create_queue(name, "#{name} queue created by Hive Runner")
|
43
|
-
queue['id'] unless queue.empty?
|
44
|
-
end
|
45
|
-
|
46
|
-
def create_queue(name, description)
|
47
|
-
queue_attributes = {
|
48
|
-
name: name,
|
49
|
-
description: description
|
50
|
-
}
|
51
|
-
|
52
|
-
Hive.devicedb('Queue').register(device_queue: queue_attributes )
|
53
|
-
end
|
54
17
|
end
|
55
18
|
end
|
56
|
-
end
|
19
|
+
end
|
data/lib/hive/worker/ios.rb
CHANGED
@@ -21,6 +21,10 @@ module Hive
|
|
21
21
|
attr_accessor :device
|
22
22
|
|
23
23
|
def initialize(device)
|
24
|
+
@queue_prefix = device['queue_prefix'].to_s == '' ? '' : "#{device['queue_prefix']}-"
|
25
|
+
@model = device['model'].downcase.gsub(/\s/, '_')
|
26
|
+
@device_range = device['device_range'].downcase
|
27
|
+
@os_version = device['os_version']
|
24
28
|
@worker_ports = PortReserver.new
|
25
29
|
self.device = device
|
26
30
|
super(device)
|
@@ -114,27 +118,30 @@ module Hive
|
|
114
118
|
end
|
115
119
|
|
116
120
|
def device_status
|
117
|
-
|
118
|
-
if details.key?('status')
|
119
|
-
@state = details['status']
|
120
|
-
else
|
121
|
-
@state
|
122
|
-
end
|
121
|
+
|
123
122
|
end
|
124
123
|
|
125
124
|
def set_device_status(status)
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
@
|
136
|
-
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
def autogenerated_queues
|
129
|
+
[
|
130
|
+
"#{@queue_prefix}#{@model}",
|
131
|
+
"#{@queue_prefix}ios",
|
132
|
+
"#{@queue_prefix}ios-#{@os_version}",
|
133
|
+
"#{@queue_prefix}ios-#{@os_version}-#{@model}",
|
134
|
+
"#{@queue_prefix}#{@device_range}",
|
135
|
+
"#{@queue_prefix}#{@device_range}-#{@os_version}"
|
136
|
+
]
|
137
|
+
end
|
138
|
+
|
139
|
+
def hive_mind_device_identifiers
|
140
|
+
{
|
141
|
+
serial: @device_id,
|
142
|
+
device_type: 'Mobile'
|
143
|
+
}
|
137
144
|
end
|
138
145
|
end
|
139
146
|
end
|
140
|
-
end
|
147
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hive-runner-ios
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Wilson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hive-runner
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: '2.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: '2.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: device_api-ios
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|