Class: Bugzilla::User

Inherits:
APITemplate show all
Defined in:
lib/bugzilla.rb

Overview

Bugzilla::User

Bugzilla::User class is to access the Bugzilla::WebService::User API that allows you to create User Accounts and log in/out using an existing account.

Instance Method Summary collapse

Methods inherited from APITemplate

#initialize, #method_missing

Methods inherited from Skeleton

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Bugzilla::APITemplate

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Bugzilla::APITemplate

Instance Method Details

#session(user, password) ⇒ Object

Bugzilla::User#session(user, password)

Keeps the bugzilla session during doing something in the block.



755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
# File 'lib/bugzilla.rb', line 755

def session(user, password)
  fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml')
  if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then
    conf = YAML.load(File.open(fname).read)
    host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host)
    cookie = conf[host]
    unless cookie.nil? then
      @iface.cookie = cookie
      print "Using cookie\n"
      yield
      conf[host] = @iface.cookie
      File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)}
      return
    end
  end
  if user.nil? || password.nil? then
    yield
  else
    ({'login'=>user, 'password'=>password, 'remember'=>true})
    yield
    logout
  end
  
end