Sha256: 4ef780c5269d2f139ac60d5d0a22813a9fee965359fe6a2a27b47d7b623fd274

Contents?: true

Size: 971 Bytes

Versions: 2

Compression:

Stored size: 971 Bytes

Contents

module TaskMapper::Provider
  # This is the Pivotal Tracker Provider for taskmapper
  module Pivotal
    include TaskMapper::Provider::Base
    TICKET_API = PivotalAPI::Story
    PROJECT_API = PivotalAPI::Project

    # This is for cases when you want to instantiate using TaskMapper::Provider::Lighthouse.new(auth)
    def self.new(auth = {})
      TaskMapper.new(:pivotal, auth)
    end

    # The authorize and initializer for this provider
    def authorize(auth = {})
      @authentication ||= TaskMapper::Authenticator.new(auth)
      auth = @authentication
      if auth.token.empty?
        raise "You should pass a token for authentication"
      end
      if auth.token
        PivotalAPI.token = auth.token
      elsif auth.username && auth.password
        PivotalAPI.authenticate(auth.username, auth.password)
      end
    end

    def valid?
      !PROJECT_API.find(:first).nil?
    rescue ActiveResource::UnauthorizedAccess
      false
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taskmapper-pivotal-0.9.0 lib/provider/pivotal.rb
taskmapper-pivotal-0.8.2 lib/provider/pivotal.rb