Class: Geera::Ticket
- Inherits:
-
Object
- Object
- Geera::Ticket
- Defined in:
- lib/geera/ticket.rb
Instance Attribute Summary collapse
-
#number ⇒ Object
readonly
Returns the value of attribute number.
Instance Method Summary collapse
-
#assign_to(username) ⇒ Object
Assign this ticket to
username
. -
#available_actions ⇒ Object
Returns a list of the actions that can be performed on this ticket.
-
#comment(text) ⇒ Object
Add a comment to this ticket with
text
. - #description ⇒ Object
- #estimate=(amount) ⇒ Object
-
#fix! ⇒ Object
Fix this ticket.
-
#fixable? ⇒ Boolean
Is this ticket in a Fix able state?.
-
#initialize(client, ticket_number) ⇒ Ticket
constructor
Create a new Ticket using Geera::Client
client
andticket_number
. - #inspect ⇒ Object
-
#resolve! ⇒ Object
Resolve this ticket.
-
#start! ⇒ Object
Start this ticket.
- #startable? ⇒ Boolean
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
#number ⇒ Object (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
68 69 70 71 |
# File 'lib/geera/ticket.rb', line 68 def assign_to username assign = Jira4R::V2::RemoteFieldValue.new('assignee', username) @ctx.updateIssue(@number, [assign]) end |
#available_actions ⇒ Object
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 |
#description ⇒ Object
78 79 80 |
# File 'lib/geera/ticket.rb', line 78 def description issue.description end |
#estimate=(amount) ⇒ Object
73 74 75 76 |
# File 'lib/geera/ticket.rb', line 73 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 55 |
# 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), ]) # FIX: wtf is that hardcoded string? That can't be right # TODO: redesign to be subclassed and override passthrough_attributes end |
#fixable? ⇒ Boolean
Is this ticket in a Fix able state?
43 44 45 |
# File 'lib/geera/ticket.rb', line 43 def fixable? available_actions.map { |a| a.name }.include?('Fix') end |
#inspect ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/geera/ticket.rb', line 82 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 |
#resolve! ⇒ Object
Resolve this ticket.
59 60 61 62 63 64 |
# File 'lib/geera/ticket.rb', line 59 def resolve! action = available_actions.find { |x| x.name == 'Resolve' } @ctx.progressWorkflowAction(@number, action.id, passthrough_attributes + [ Jira4R::V2::RemoteFieldValue.new('customfield_10176', @client.username), ]) # FIX: wtf is that hardcoded string? That can't be right 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
30 31 32 |
# File 'lib/geera/ticket.rb', line 30 def startable? available_actions.map { |a| a.name }.include?('Start') end |