class Bugzilla::User
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.
Public Instance Methods
get_userinfo(user)
click to toggle source
Bugzilla::User#get_userinfo(params)
¶ ↑
# File lib/bugzilla/user.rb, line 103 def get_userinfo(user) p = {} ids = [] names = [] if user.kind_of?(Array) then user.each do |u| names << u if u.kind_of?(String) id << u if u.kind_of?(Integer) end elsif user.kind_of?(String) then names << user elsif user.kind_of?(Integer) then ids << user else raise ArgumentError, sprintf("Unknown type of arguments: %s", user.class) end result = get({'ids'=>ids, 'names'=>names}) result['users'] end
session(user, password) { || ... }
click to toggle source
Bugzilla::User#session
(user, password)¶ ↑
Keeps the bugzilla session during doing something in the block.
# File lib/bugzilla/user.rb, line 45 def session(user, password) r = check_version('5.0.0') if r[0] then key = :api_key fname = File.join(ENV['HOME'], '.ruby-bugzilla-api.yml') else r = check_version('4.4.3') if r[0] then key = :token fname = File.join(ENV['HOME'], '.ruby-bugzilla-token.yml') else key = :cookie fname = File.join(ENV['HOME'], '.ruby-bugzilla-cookie.yml') end end host = @iface.instance_variable_get(:@xmlrpc).instance_variable_get(:@host) val = nil if File.exist?(fname) && File.lstat(fname).mode & 0600 == 0600 then conf = YAML.load(File.open(fname).read) val = conf[host] else conf = {} end if !val.nil? then if key == :api_key then @iface.api_key = val elsif key == :token then @iface.token = val else @iface.cookie = val end yield elsif user.nil? || password.nil? then yield return else login({'login'=>user, 'password'=>password, 'remember'=>true}) yield end if key == :token then conf[host] = @iface.token else conf[host] = @iface.cookie end File.open(fname, 'w') {|f| f.chmod(0600); f.write(conf.to_yaml)} return key end
Protected Instance Methods
__create(cmd, *args)
click to toggle source
# File lib/bugzilla/user.rb, line 167 def __create(cmd, *args) # FIXME end
__offer_account_by_email(cmd, *args)
click to toggle source
# File lib/bugzilla/user.rb, line 163 def __offer_account_by_email(cmd, *args) # FIXME end
__update(cmd, *args)
click to toggle source
# File lib/bugzilla/user.rb, line 171 def __update(cmd, *args) # FIXME end
_get(cmd, *args)
click to toggle source
# File lib/bugzilla/user.rb, line 175 def _get(cmd, *args) raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash) requires_version(cmd, 3.4) res = @iface.call(cmd, args[0]) # FIXME end
_login(cmd, *args)
click to toggle source
Bugzilla::User#logout¶ ↑
Raw Bugzilla
API to log out the user.
See www.bugzilla.org/docs/tip/en/html/api/Bugzilla/WebService/User.html
# File lib/bugzilla/user.rb, line 148 def _login(cmd, *args) raise ArgumentError, "Invalid parameters" unless args[0].kind_of?(Hash) res = @iface.call(cmd,args[0]) unless res['token'].nil? then @iface.token = res['token'] end return res end
_logout(cmd, *args)
click to toggle source
# File lib/bugzilla/user.rb, line 159 def _logout(cmd, *args) @iface.call(cmd) end