Class: Wod::Command::Devices
- Inherits:
-
Base
- Object
- Base
- Wod::Command::Devices
show all
- Defined in:
- lib/wod/commands/devices.rb
Instance Attribute Summary
Attributes inherited from Base
#args
Instance Method Summary
collapse
Methods inherited from Base
#initialize, #wod
Methods included from Helpers
#ask, #display_formatted, #error, #home_directory, #last_page_file, #wod_directory
Instance Method Details
#add ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/wod/commands/devices.rb', line 19
def add
name = args.shift
udid = args.shift
page = wod.get "https://developer.apple.com/ios/manage/devices/add.action"
form = page.form "add"
form["deviceNameList[0]"] = name
form["deviceNumberList[0]"] = udid
form.submit
end
|
#index ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/wod/commands/devices.rb', line 4
def index
page = wod.get "https://developer.apple.com/ios/manage/devices/index.action"
names = page.search("td.name span").map(&:text)
udids = page.search("td.id").map(&:text)
devices_left = page.search(".devicesannounce strong").first.text
devices = []
names.each_with_index{|name, i| devices << {:name => name, :udid => udids[i] } }
display_formatted devices, [:name, :udid]
puts
puts "#{devices.size} devices registered. #{devices_left}"
end
|
#remove ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/wod/commands/devices.rb', line 32
def remove
name = args.shift
page = wod.get "http://developer.apple.com/ios/manage/devices/index.action"
device_span = page.search("span:contains('#{name}')")
if device_span.empty?
error "Device not found"
end
tr = device_span.first.parent.parent
row_identifier = tr.search("input[name='__checkbox_selectedValues']").first[:value]
form = page.form "removeDevice"
checkbox = form.checkboxes.find {|c| c[:value] == row_identifier}
checkbox.check
form.submit
end
|