Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add a profiles:download command to download provisioning profiles. #13

Merged
merged 1 commit into from

2 participants

@newhouseb

Works exactly the same way as certificates:download does and filters out any inactive provisioning profiles.

I have also literally never written any ruby code before, so I just pattern matched my way through. If I've committed some grave ruby error, let me know and I'd be happy to fix.

Thanks!

@mattt
Owner

That's some pretty non-trivial code for your first time using Ruby! Well done! This looks just fine. Thanks for adding this :)

@mattt mattt merged commit 31cfdbb into nomad:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 18, 2012
  1. Added profiles:download command that functions analogously to certifi…

    Ben Newhouse authored
    …cates:download
This page is out of date. Refresh to see the latest.
View
1  README.md
@@ -107,6 +107,7 @@ _Crossed out commands are not yet implemented_
- `profiles:list`
- `profiles:manage:devices`
+- `profiles:download`
- ~~`profiles:add`~~
- ~~`profiles:edit`~~
View
19 lib/cupertino/provisioning_portal/agent.rb
@@ -146,6 +146,25 @@ def list_profiles(type = :development)
profiles
end
+ def download_profile(profile)
+ list_profiles(profile.type)
+
+ page.parser.xpath('//fieldset[@id="fs-0"]/table/tbody/tr').each do |row|
+ name = row.at_xpath('td[@class="profile"]//span/text()').to_s.strip rescue nil
+
+ if name == profile.name
+ download_url = row.at_xpath('td[@class="action"]/a')['href'].to_s.strip rescue nil
+
+ self.pluggable_parser.default = Mechanize::Download
+ download = get(download_url)
+ download.save
+ return download.filename
+ end
+ end
+
+ return nil
+ end
+
def manage_devices_for_profile(profile)
raise ArgumentError unless block_given?
View
20 lib/cupertino/provisioning_portal/commands/profiles.rb
@@ -67,3 +67,23 @@
end
alias_command :'profiles:manage', :'profiles:manage:devices'
+
+command :'profiles:download' do |c|
+ c.syntax = 'ios profiles:download'
+ c.summary = 'Downloads the Provisioning Profiles'
+ c.description = ''
+
+ c.action do |args, options|
+ type = args.first.downcase.to_sym rescue nil
+ profiles = try{agent.list_profiles(type ||= :development)}
+ profiles = profiles.find_all{|profile| profile.status == 'Active'}
+
+ say_warning "No active #{type} profiles found." and abort if profiles.empty?
+ profile = choose "Select a profile to download:", *profiles
+ if filename = agent.download_profile(profile)
+ say_ok "Successfully downloaded: '#{filename}'"
+ else
+ say_error "Could not download profile"
+ end
+ end
+end
Something went wrong with that request. Please try again.