Sha256: 0b981c110110e2fdb62da0d842012c38f0c5fbad3a0b266a72fb51120b1e3471

Contents?: true

Size: 1.07 KB

Versions: 42

Compression:

Stored size: 1.07 KB

Contents

require_relative "../scripts"
require_relative "../pivotal"

module Octopolo
  module Scripts
    class PivotalAuth
      include UserConfigWrapper
      include CLIWrapper

      attr_accessor :email
      attr_accessor :password
      attr_accessor :token

      def execute
        ask_credentials
        request_token
        store_token
      rescue Pivotal::BadCredentials => e
        cli.say e.message
      end

      # Private: Ask the user for their credentials
      def ask_credentials
        self.email = cli.prompt "Your Pivotal Tracker email: "
        self.password = cli.prompt_secret "Your Pivotal Tracker password (never stored): "
      end
      private :ask_credentials

      # Private: Fetch the user's token from the Pivotal API
      def request_token
        self.token = Pivotal::Client.fetch_token(email, password)
      end
      private :request_token

      # Private: Store the returned token from the Pivotal API
      def store_token
        user_config.set :pivotal_token, token
      end
      private :store_token
    end
  end
end

# vim: set ft=ruby: #

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
octopolo-1.12.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.11.4 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.11.3 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.11.1 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.11.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.9.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.8.1 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.8.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.7.1 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.7.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.6.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.5.3 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.5.2 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.5.1 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.5.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.4.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.3.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.2.1 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.2.0 lib/octopolo/scripts/pivotal_auth.rb
octopolo-1.1.1 lib/octopolo/scripts/pivotal_auth.rb