Sha256: c64dc33e7605f275a1d60ce4b9f0be370a6ffd8bec2452e4921d960320598f33

Contents?: true

Size: 1.43 KB

Versions: 8

Compression:

Stored size: 1.43 KB

Contents

# Monkey Patch Commander::UI to alias password to avoid conflicts
module Commander::UI
  alias :pw :password
end

class String
  include Term::ANSIColor
end

module Cupertino
  module ProvisioningPortal
    module Helpers
      def agent
        unless @agent
          @agent = Cupertino::ProvisioningPortal::Agent.new

          @agent.instance_eval do
            def username
              @username ||= ask "Username:"
            end

            def password
              @password ||= pw "Password:"
            end

            def team
              teams = page.form_with(:name => 'saveTeamSelection').field_with(:name => 'memberDisplayId').options.collect(&:text)
              @team ||= choose "Select a team:", *teams
            end
          end
        end

        @agent
      end
      
      def pluralize(n, singular, plural = nil)
        n.to_i == 1 ? "1 #{singular}" : "#{n} #{plural || singular + 's'}"
      end
      
      def try
        return unless block_given?

        begin
          yield
        rescue UnsuccessfulAuthenticationError
          say_error "Could not authenticate with Apple Developer Center. Check that your username & password are correct, and that your membership is valid and all pending Terms of Service & agreements are accepted. If this problem continues, try logging into https://developer.apple.com/membercenter/ from a browser to see what's going on." and abort
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
cupertino-0.7.1 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.7.0 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.6.1 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.6.0 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.5.1 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.5.0 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.4.0 ./lib/cupertino/provisioning_portal/helpers.rb
cupertino-0.3.3 ./lib/cupertino/provisioning_portal/helpers.rb