Sha256: e187a1146d85bded685e7bc33cb8b87949ac223384d0745db6ecd536e9fb3c20

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require 'taskmapper'

module TaskMapper::Provider
  # This is the Yoursystem Provider for taskmapper
  module Bugzilla
    include TaskMapper::Provider::Base
    PROJECT_API = Rubyzilla::Product
    
    # This is for cases when you want to instantiate using TaskMapper::Provider::Yoursystem.new(auth)
    def self.new(auth = {})
      TaskMapper.new(:bugzilla, auth)
    end
    
    # declare needed overloaded methods here
    def authorize(auth = {})
      @authentication ||= TaskMapper::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)
      begin
        @bugzilla.login(auth.username,auth.password)
      rescue
        warn 'Authentication was invalid'
      end
    end

    def valid?
      Rubyzilla::Bugzilla.logged_in?
    end

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
taskmapper-bugzilla-0.4.0 lib/provider/bugzilla.rb
taskmapper-bugzilla-0.3.0 lib/provider/bugzilla.rb