Class: Geera::Ticket

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, ticket_number) ⇒ Ticket

Create a new Ticket using Geera::Client client and ticket_number. This constructor should not be called directly, use Geera::Client#ticket instead.



11
12
13
14
15
16
# File 'lib/geera/ticket.rb', line 11

def initialize client, ticket_number
  @client = client
  @ctx    = client.ctx
  @number = ticket_number
  @issue  = nil
end

Instance Attribute Details

#numberObject (readonly)

Returns the value of attribute number.



5
6
7
# File 'lib/geera/ticket.rb', line 5

def number
  @number
end

Instance Method Details

#assign_to(username) ⇒ Object

Assign this ticket to username



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

def assign_to username
  assign = Jira4R::V2::RemoteFieldValue.new('assignee', username)
  @ctx.updateIssue(@number, [assign])
end

#available_actionsObject

Returns a list of the actions that can be performed on this ticket.



26
27
28
# File 'lib/geera/ticket.rb', line 26

def available_actions
  @ctx.getAvailableActions @number
end

#comment(text) ⇒ Object

Add a comment to this ticket with text.



20
21
22
# File 'lib/geera/ticket.rb', line 20

def comment text
  @ctx.addComment @number, Jira4R::V2::RemoteComment.new(nil, text)
end

#descriptionObject



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

def description
  issue.description
end

#estimate=(amount) ⇒ Object



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

def estimate= amount
  assign = Jira4R::V2::RemoteFieldValue.new('timetracking', amount)
  @ctx.updateIssue(@number, [assign])
end

#fix!Object

Fix this ticket.



49
50
51
52
53
54
# File 'lib/geera/ticket.rb', line 49

def fix!
  action = available_actions.find { |x| x.name == 'Fix' }
  @ctx.progressWorkflowAction(@number, action.id, passthrough_attributes + [
   Jira4R::V2::RemoteFieldValue.new('customfield_10176', @client.username),
  ])
end

#fixable?Boolean

Is this ticket in a Fix able state?

Returns:

  • (Boolean)


43
44
45
# File 'lib/geera/ticket.rb', line 43

def fixable?
  available_actions.map { |a| a.name }.include?('Fix')
end

#inspectObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/geera/ticket.rb', line 72

def inspect
  template = ERB.new <<-eoinspect
## Reporter: <%= issue.reporter %>
## Assignee: <%= issue.assignee %>
## Priority: <%= issue.priority %>
## Fix Versions: <%= issue.fixVersions.map {|fv| fv.name}.join(', ') %>

## Summary

<%= issue.summary %>

## Description:

<%= issue.description %>

## Comments:
<% comments.each do |comment| %>
* <%= comment.author %>
  <% comment.body.split(/[\r\n]+/).each do |line| %>
  > <%= line %><% end %>
<% end %>

  eoinspect
  template.result binding
end

#start!Object

Start this ticket.



36
37
38
39
# File 'lib/geera/ticket.rb', line 36

def start!
  action = available_actions.find { |x| x.name == 'Start' }
  @ctx.progressWorkflowAction(@number, action.id, passthrough_attributes)
end

#startable?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/geera/ticket.rb', line 30

def startable?
  available_actions.map { |a| a.name }.include?('Start')
end