Sha256: 9040930fb4a4e0ac7a58968630fec2e75255aa10f18baba30939c52664101d0b

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

module TicketMaster::Provider
  # This is the Github Provider for ticketmaster
  module Github
    include TicketMaster::Provider::Base
    PROJECT_API = Octopi::Repository
    ISSUE_API = Octopi::Issue

    class << self
      attr_accessor :login
    end
    
    # This is for cases when you want to instantiate using TicketMaster::Provider::Github.new(auth)
    def self.new(auth = {})
      TicketMaster.new(:github, auth)
    end
    
    # declare needed overloaded methods here
    def authorize(auth = {})
      @authentication ||= TicketMaster::Authenticator.new(auth)
      auth = @authentication
      if auth.token.nil? or (auth.login.nil? and auth.username.nil?)
        TicketMaster::Provider::Github.login = auth.login || auth.username
        return
      else
        Octopi::Api.api = Octopi::AuthApi.instance
        Octopi::Api.api.token = auth.token unless auth.token.blank?
        Octopi::Api.api.login = auth.login || auth.username
      end
    end

    def projects(*options)
      if options.empty?
        PROJECT_API.find(:user => TicketMaster::Provider::Github.login).collect{|repo| Project.new repo}
      elsif  options.first.is_a?(Array)
        options.collect{|name| Project.find(name)}.first
      end
    end
    
    def project(*name)
      unless name.empty?
        Project.find(name.first)
      else
        super
      end
    end
    
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ticketmaster-github-0.3.0 lib/provider/github.rb