appsendr 0.0.6 → 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.
data/portal.rb DELETED
@@ -1,197 +0,0 @@
1
-
2
- require 'rubygems'
3
- require 'mechanize'
4
- require 'highline'
5
- @@agent = Mechanize.new
6
- @@agent.user_agent_alias = 'Mac FireFox'
7
- @@agent.follow_meta_refresh = true
8
-
9
- @@available_devices = []
10
- @@available_profiles = []
11
- BASE_URL = "https://developer.apple.com"
12
- LOGIN_URL = BASE_URL + "/ios/manage/overview/index.action"
13
- DEVICES_URL = BASE_URL + "/ios/manage/devices/index.action"
14
- DEVICE_BULK_UPLOAD_URL = "/ios/manage/devices/saveupload.action"
15
- SAVE_TEAM_URL = BASE_URL + "/membercenter/saveTeamSelection.action"
16
-
17
- DEV_PROVISIONING_PROFILE_URL = BASE_URL + "/ios/manage/provisioningprofiles/index.action"
18
- DIST_PROVISIONING_PROFILE_URL = BASE_URL + "/ios/manage/provisioningprofiles/viewDistributionProfiles.action"
19
-
20
- CREATE_ADHOC_PROFILE_URL = BASE_URL + "/ios/manage/provisioningprofiles/create.action?type=2"
21
- DOWNLOAD_PROFILE_URL_WO_ID = BASE_URL + "/ios/manage/provisioningprofiles/download.action?blobId="
22
- EDIT_PROFILE_URL_WO_ID = BASE_URL + "/ios/manage/provisioningprofiles/edit.action?provDisplayId="
23
-
24
- SAVE_PROFILE_URL = BASE_URL + "/ios/manage/provisioningprofiles/save.action"
25
-
26
- def login(username, password)
27
-
28
- # Get login page
29
- #puts "- fetching login page"
30
- #page = agent.get('https://phobos.apple.com/WebObjects/MZLabel.woa/wa/default')
31
- page = @@agent.get(LOGIN_URL)
32
-
33
-
34
- # Submit form to login
35
- login_form = page.forms.first
36
- login_form['theAccountName']=username
37
- login_form['theAccountPW']=password
38
- page = @@agent.submit(login_form)
39
-
40
- # Fail if it looks like we ended up back at a login page
41
- if page.form('appleConnectForm')
42
- #puts "Error: Login failed"
43
- return nil
44
- #exit
45
- else
46
- select_form = page.form('saveTeamSelection')
47
- if select_form
48
- options = []
49
- select_form.fields.first.options.each{|option|
50
- display "#{options.length + 1}. #{option.text}"
51
- options.push([option.text,option.value])
52
-
53
- }
54
- print "Enter the # for the account you wish to login to: "
55
- selection = ask
56
- if selection.to_i > (options.length )
57
- error "Invalid selection"
58
- return nil
59
-
60
- end
61
-
62
- team = options[selection.to_i - 1]
63
- select_form['memberDisplayId'] = team[1]
64
- page = @@agent.submit(select_form, select_form.buttons[1])
65
- return page
66
- else
67
- return page
68
- end
69
- end
70
- end
71
-
72
- def get_details(username, password)
73
- if login(username,password)
74
- @available_dev_profiles = development_provisioning_profiles
75
- profile = @available_dev_profiles[1]
76
- profile_id = profile[:id]
77
- puts profile_id
78
- puts profile[:editable]
79
- edit_profile = edit_provisioning_profile_and_get_devices(profile_id,false)
80
- devices = edit_profile[1]
81
- page = edit_profile[0]
82
-
83
- update_provisioning_profile_with_devices(page,[])
84
- #puts page.parser
85
- end
86
- end
87
-
88
- #####
89
- # provisioning
90
-
91
- def provisioning_profiles(url)
92
- page = @@agent.get(url)
93
- table = page.at("//table/tbody")
94
- profiles = []
95
- return profiles unless table
96
-
97
- table.children.each{|tr|
98
- children = tr.children
99
- cert_key = children[0].children[0]['value'].strip
100
- cert_name = children[2].content.strip
101
- app_id = children[4].content.strip
102
- editable = false
103
- children[8].search("a").each{|link|
104
- if link.inner_html == "Edit"
105
- editable = true
106
- break
107
- end
108
- }
109
-
110
- profiles.push({:name => cert_name, :id => cert_key, :app_id => app_id, :editable => editable })
111
- #p children
112
- }
113
- return profiles
114
- end
115
-
116
- def development_provisioning_profiles
117
- provisioning_profiles(DEV_PROVISIONING_PROFILE_URL)
118
- end
119
-
120
- def distribution_provisioning_profiles
121
-
122
- provisioning_profiles(DIST_PROVISIONING_PROFILE_URL)
123
-
124
- end
125
-
126
- def download_provisioning_profile(id)
127
- page = @@agent.get(DOWNLOAD_PROFILE_URL_WO_ID+id)
128
- return page
129
- end
130
-
131
- def edit_provisioning_profile_and_get_devices(id,get_devices)
132
- page = @@agent.get(EDIT_PROFILE_URL_WO_ID+id)
133
- profile_devices = []
134
-
135
- if get_devices
136
- devices = page.at("div[@class='checkboxlist last']")
137
-
138
- selected_devices = []
139
-
140
- hidden_name = ""
141
- checkbox_name = ""
142
- devices.at("table").children.each{|row|
143
- row.children.each{|column|
144
-
145
- column.children.each{|input|
146
- if input['type'] == "hidden"
147
- hidden_name = input['name']
148
- elsif input['type'] == "checkbox"
149
- checkbox_name = input['name']
150
- device = {}
151
-
152
- device[:checked] = !!input['checked']
153
- device[:udid] = input['value']
154
- device[:name] = input.parent.at("label").inner_html
155
- profile_devices.push(device)
156
- if input['checked']
157
- selected_devices.push(device)
158
- #puts "[√] #{device[:name] } #{device[:udid]}"
159
- else
160
- # puts "[ ] #{device[:name] } #{device[:udid]}"
161
- end
162
-
163
-
164
- end
165
-
166
- }
167
- }
168
- }
169
- end
170
- return [page, profile_devices]
171
- end
172
-
173
- def update_provisioning_profile_with_devices(page, devices)
174
- device_form = page.forms[1]
175
- device_form.checkboxes_with(:name=>/selectedDevices/).each do |checkbox|
176
- puts checkbox['value']
177
-
178
- if devices.include?(checkbox['value'])
179
- checkbox.checked
180
- put " √ "
181
- end
182
- end
183
- button = device_form.button_with(:name => /submit/)
184
- page = @@agent.submit(device_form, button)
185
-
186
-
187
- end
188
-
189
- def create_provisioning_profile
190
- page = @@agent.get(CREATE_ADHOC_PROFILE_URL) #adhoc profiles
191
- create_form = page.forms.first
192
-
193
- end
194
-
195
-
196
-
197
- get_details("nolanbrown@gmail.com","98xXp649")
data/terms DELETED
File without changes