Sha256: 510a662c24d9c9d14476a9330f244f65c93ca372f8459e837decc329feaebbe1

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

require 'ticketmaster'

module TicketMaster::Provider
  # This is the Yoursystem Provider for ticketmaster
  module Bugzilla
    include TicketMaster::Provider::Base
    PROJECT_API = Rubyzilla::Product
    
    # This is for cases when you want to instantiate using TicketMaster::Provider::Yoursystem.new(auth)
    def self.new(auth = {})
      TicketMaster.new(:bugzilla, auth)
    end
    
    # declare needed overloaded methods here
    def authorize(auth = {})
      @authentication ||= TicketMaster::Authenticator.new(auth)
      auth = @authentication
      if (auth.username.nil? || auth.url.nil? || auth.password.nil?)
        raise "Please provide username, password and url"
      end
      url = auth.url.gsub(/\/$/,'')
      unless url.split('/').last == 'xmlrpc.cgi'
        auth.url = url+'/xmlrpc.cgi'
      end
      @bugzilla = Rubyzilla::Bugzilla.new(auth.url)
      @bugzilla.login(auth.username,auth.password)
    end

    def projects(*options)
      if options.empty?
        PROJECT_API.list.collect { |product| Project.new product }
      elsif options.first.is_a? Array
        options.first.collect { |id| Project.find(id) }
      elsif options.first.is_a? Hash
        Project.find_by_attributes(options)
      end
    end

    def project(*options)
      unless options.empty?
        Project.find(options.first)
      else
        super
      end
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ticketmaster-bugzilla-0.0.6 lib/provider/bugzilla.rb
ticketmaster-bugzilla-0.0.5 lib/provider/bugzilla.rb
ticketmaster-bugzilla-0.0.4 lib/provider/bugzilla.rb
ticketmaster-bugzilla-0.0.3 lib/provider/bugzilla.rb
ticketmaster-bugzilla-0.0.2 lib/provider/bugzilla.rb