Class: Geera::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/geera/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
# File 'lib/geera/client.rb', line 6

def initialize url
  @ctx = Jira4R::JiraTool.new 2, url

  # Make jira4r quiet
  @ctx.logger = Logger.new nil
  @username = nil
end

Instance Attribute Details

#ctxObject (readonly)

Returns the value of attribute ctx.



4
5
6
# File 'lib/geera/client.rb', line 4

def ctx
  @ctx
end

#usernameObject (readonly)

Returns the value of attribute username.



3
4
5
# File 'lib/geera/client.rb', line 3

def username
  @username
end

Instance Method Details

#create_ticket(params) ⇒ Object

Create a ticket using params. params should be a hash, and must have a project, summary, and description field.

For example:

client.create_ticket :project => 'AB',
                     :summary => 'foo',
                     :description => 'bar'


39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/geera/client.rb', line 39

def create_ticket params
  [:project, :summary].each do |param|
    raise(ArgumentError, "#{param} required") unless params[param]
  end

  issue = Jira4R::V2::RemoteIssue.new
  issue.project     = params[:project]
  issue.summary     = params[:summary]
  issue.description = params[:description]
  issue.assignee    = params[:assignee] || @username
  issue.type        = '1' #FIXME: wtf is this for?
  issue.priority    = '5'
  issue = @ctx.createIssue issue
  ticket issue.key
end

#filtersObject



55
56
57
# File 'lib/geera/client.rb', line 55

def filters
  @ctx.getSavedFilters
end

#list(filter) ⇒ Object



59
60
61
# File 'lib/geera/client.rb', line 59

def list filter
  @ctx.getIssuesFromFilter filter
end

#login(user, password) ⇒ Object

Login with user and password



16
17
18
19
# File 'lib/geera/client.rb', line 16

def  user, password
  @username = user
  @ctx. user, password
end

#ticket(number) ⇒ Object

Get the ticket with number. Returns a Geera::Ticket object.

client.ticket 'BZ-123' # => #<Geera::Ticket>


25
26
27
# File 'lib/geera/client.rb', line 25

def ticket number
  Geera::Ticket.new self, number
end