lib/provider/github.rb in ticketmaster-github-0.2.1 vs lib/provider/github.rb in ticketmaster-github-0.3.0

- old
+ new

@@ -2,10 +2,14 @@ # 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 @@ -13,20 +17,21 @@ # 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?) - raise "Please provide token and login" + TicketMaster::Provider::Github.login = auth.login || auth.username + return else Octopi::Api.api = Octopi::AuthApi.instance - Octopi::Api.api.token = auth.token + 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 => Octopi::Api.api.login).collect{|repo| Project.new repo} + 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