Class: Credentials

Inherits:
Object
  • Object
show all
Defined in:
lib/jirarest2/credentials.rb

Overview

A Credentials object contains the data required to connect to a JIRA(tm) instance.

Direct Known Subclasses

CookieCredentials, PasswordCredentials

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url, username) ⇒ Credentials

Returns a new instance of Credentials.

Parameters:

  • url (String)

    URL to JIRA(tm) instance

  • username (String)

    Username of the user who connects to jira

Raises:



34
35
36
37
38
39
40
41
42
43
# File 'lib/jirarest2/credentials.rb', line 34

def initialize(url,username)
  uri = URI(url)
  if uri.instance_of?(URI::HTTP) || uri.instance_of?(URI::HTTPS) then
    @connecturl = url
    @username = username
    @baseurl = @connecturl.gsub(/rest\/api\/.+/,"rest/")
  else
    raise Jirarest2::NotAnURLError
  end
end

Instance Attribute Details

#baseurlObject (readonly)

basepath for the REST methods



29
30
31
# File 'lib/jirarest2/credentials.rb', line 29

def baseurl
  @baseurl
end

#connecturlObject

url to connect to the JIRA(tm) instance



25
26
27
# File 'lib/jirarest2/credentials.rb', line 25

def connecturl
  @connecturl
end

#usernameObject

username to use



27
28
29
# File 'lib/jirarest2/credentials.rb', line 27

def username
  @username
end

Instance Method Details

#get_auth_header(request) ⇒ Object

Get the auth header to send to the server

Parameters:

  • request (Net:::HTTP::Post, Net:::HTTP::Put, Net:::HTTP::Get, Net:::HTTP::Delete)

    Request object



59
60
61
# File 'lib/jirarest2/credentials.rb', line 59

def get_auth_header(request)

end