lib/provider/github.rb in ticketmaster-github-0.3.1 vs lib/provider/github.rb in ticketmaster-github-0.4.1

- old
+ new

@@ -1,14 +1,12 @@ 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 + attr_accessor :login, :api end # This is for cases when you want to instantiate using TicketMaster::Provider::Github.new(auth) def self.new(auth = {}) TicketMaster.new(:github, auth) @@ -20,34 +18,34 @@ auth = @authentication if auth.login.blank? and auth.username.blank? raise TicketMaster::Exception.new('Please provide at least a username') elsif auth.token.blank? TicketMaster::Provider::Github.login = auth.login || auth.username - Octopi::Api.api = Octopi::AnonymousApi.instance + TicketMaster::Provider::Github.api = Octokit.client(:login => auth.login) else TicketMaster::Provider::Github.login = auth.login || auth.username - Octopi::Api.api = Octopi::AuthApi.instance - Octopi::Api.api.token = auth.token - Octopi::Api.api.login = auth.login || auth.username + TicketMaster::Provider::Github.api = Octokit.client(:login => auth.login, :token => auth.token) 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 + Project.find_all(options) + elsif options.first.is_a? Array + options.first.collect { |name| Project.find_by_id(name) } + elsif options.first.is_a? Hash + Project.find_by_attributes(options.first) end end - - def project(*name) - unless name.empty? - Project.find(name.first) + + def project(*project) + unless project.empty? + Project.find_by_id(project.first) else super end end - + end end