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

#component(project, name) ⇒ Object



33
34
35
# File 'lib/geera/client.rb', line 33

def component project, name
  self.components(project).find { |c| c.name.downcase == name.downcase }
end

#components(project) ⇒ Object



29
30
31
# File 'lib/geera/client.rb', line 29

def components project
  self.ctx.getComponents(project)
end

#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'


47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/geera/client.rb', line 47

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.components  = params[:components]
  issue.type        = '1' #FIXME: wtf is this for?
  issue.priority    = '5'
  issue = @ctx.createIssue issue
  ticket issue.key
end

#filtersObject



64
65
66
# File 'lib/geera/client.rb', line 64

def filters
  @ctx.getSavedFilters
end

#list(filter) ⇒ Object



68
69
70
# File 'lib/geera/client.rb', line 68

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