Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: nomad/cupertino
base: 5366261669
...
head fork: nomad/cupertino
compare: 6f279b83cc
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 5 files changed
  • 0 commit comments
  • 1 contributor
View
7 README.md
@@ -51,6 +51,12 @@ $ ios profiles:list
+----------------------------------+--------------+---------+
```
+```sh
+$ ios profiles:manage:devices
+```
+
+_Opens an editor with a list of devices, each of which can be commented or uncommented to turn them off or on for that provisioning profile._
+
### App IDs
```sh
@@ -92,6 +98,7 @@ _Crossed out commands are not yet implemented_
- ~~`devices:remove`~~
- `profiles:list`
+- `profiles:manage:devices`
- ~~`profiles:add`~~
- ~~`profiles:edit`~~
View
2  lib/cupertino.rb
@@ -1,4 +1,4 @@
module Cupertino
- VERSION = '0.3.3'
+ VERSION = '0.4.0'
HOSTNAME = "developer.apple.com"
end
View
4 lib/cupertino/provisioning_portal.rb
@@ -4,7 +4,7 @@ module Cupertino
module ProvisioningPortal
class Device < Struct.new(:name, :udid)
def to_s
- "#{self.udid} #{self.name}"
+ "#{self.name} #{self.udid}"
end
end
@@ -20,7 +20,7 @@ def to_s
end
end
- class ProvisioningProfile < Struct.new(:name, :app_id, :status)
+ class ProvisioningProfile < Struct.new(:name, :type, :app_id, :status)
def to_s
"#{self.name}"
end
View
70 lib/cupertino/provisioning_portal/agent.rb
@@ -14,6 +14,8 @@ def initialize
end
def get(uri, parameters = [], referer = nil, headers = {})
+ uri = ::File.join("https://#{Cupertino::HOSTNAME}", uri) unless /^https?/ === uri
+
3.times do
super(uri, parameters, referer, headers)
@@ -62,12 +64,12 @@ def download_certificate(certificate)
page.parser.xpath('//div[@class="nt_multi"]/table/tbody/tr').each do |row|
name = row.at_xpath('td[@class="name"]//p/text()').to_s.strip rescue nil
-
+
if name == certificate.name
download_url = row.at_xpath('td[@class="last"]/a')['href'].to_s.strip rescue nil
self.pluggable_parser.default = Mechanize::Download
- download = get(::File.join("https://#{Cupertino::HOSTNAME}", download_url))
+ download = get(download_url)
download.save
return download.filename
end
@@ -135,7 +137,8 @@ def list_profiles(type = :development)
profiles = []
page.parser.xpath('//fieldset[@id="fs-0"]/table/tbody/tr').each do |row|
profile = ProvisioningProfile.new
- profile.name = row.at_xpath('td[@class="profile"]/text()').to_s.strip rescue nil
+ profile.name = row.at_xpath('td[@class="profile"]//text()').to_s.strip rescue nil
+ profile.type = type
profile.app_id = row.at_xpath('td[@class="appid"]/text()').to_s.strip rescue nil
profile.status = row.at_xpath('td[@class="statusXcode"]/text()').to_s.strip rescue nil
profiles << profile
@@ -143,6 +146,63 @@ def list_profiles(type = :development)
profiles
end
+ def manage_devices_for_profile(profile)
+ raise ArgumentError unless block_given?
+
+ list_profiles(profile.type)
+
+ modify_url = nil
+ page.parser.xpath('//fieldset[@id="fs-0"]/table/tbody/tr').each do |row|
+ break if modify_url
+
+ name = row.at_xpath('td[@class="profile"]//text()').to_s.strip rescue nil
+
+ if name == profile.name
+ row.css('td.action a').each do |a|
+ if /edit\.action/ === a['href']
+ modify_url = a['href']
+ end
+ end
+ end
+ end
+
+ if modify_url
+ get(modify_url)
+
+ on, off = [], []
+ page.parser.css('.checkboxlist.last td').each do |td|
+ checkbox = td.at_xpath('input[@type="checkbox"]')
+
+ device = Device.new
+ device.name = td.at_xpath('label/text()').to_s.strip rescue nil
+ device.udid = checkbox['value'].to_s.strip rescue nil
+
+ if checkbox['checked']
+ on << device
+ else
+ off << device
+ end
+ end
+
+ devices = yield on, off
+
+ form = page.form_with(:name => 'save')
+ form.checkboxes_with(:name => "selectedDevices").each do |checkbox|
+ checkbox.check
+ if devices.detect{|device| device.udid == checkbox['value']}
+ checkbox.check
+ else
+ checkbox.uncheck
+ end
+ end
+
+ button = form.button_with(:name => 'submit')
+ form.click_button(button)
+ end
+
+ return nil
+ end
+
def list_app_ids
get("https://developer.apple.com/ios/manage/bundles/index.action")
@@ -180,8 +240,8 @@ def select_team!
team_option = team_list.option_with(:text => self.team)
team_option.select
- btn = form.button_with(:name => 'action:saveTeamSelection!save')
- form.click_button(btn)
+ button = form.button_with(:name => 'action:saveTeamSelection!save')
+ form.click_button(button)
end
end
end
View
38 lib/cupertino/provisioning_portal/commands/profiles.rb
@@ -29,3 +29,41 @@
end
alias_command :profiles, :'profiles:list'
+
+command :'profiles:manage:devices' do |c|
+ c.syntax = 'ios profiles:manage:devices'
+ c.summary = 'Manage active devices for a development provisioning profile'
+ c.description = ''
+
+ c.action do |args, options|
+ type = args.first.downcase.to_sym rescue nil
+ profiles = try{agent.list_profiles(:development)}
+
+ say_warning "No #{type} provisioning profiles found." and abort if profiles.empty?
+
+ profile = choose "Select a provisioning profile to manage:", *profiles
+
+ agent.manage_devices_for_profile(profile) do |on, off|
+ lines = ["# Comment / Uncomment Devices to Turn Off / On for Provisioning Profile"]
+ lines += on.collect{|device| "#{device}"}
+ lines += off.collect{|device| "# #{device}"}
+ result = ask_editor lines.join("\n")
+
+ devices = []
+ result.split(/\n+/).each do |line|
+ next if /^\#/ === line
+ components = line.split(/\s+/)
+ device = Device.new
+ device.udid = components.pop
+ device.name = components.join(" ")
+ devices << device
+ end
+
+ devices
+ end
+
+ say_ok "Successfully managed devices"
+ end
+end
+
+alias_command :'profiles:manage', :'profiles:manage:devices'

No commit comments for this range

Something went wrong with that request. Please try again.