Class: Houston::Adapters::TicketTracker::UnfuddleAdapter::Ticket
- Inherits:
-
Object
- Object
- Houston::Adapters::TicketTracker::UnfuddleAdapter::Ticket
- Defined in:
- app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb
Instance Attribute Summary collapse
-
#closed_at ⇒ Object
readonly
Returns the value of attribute closed_at.
-
#component ⇒ Object
readonly
Returns the value of attribute component.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#milestone_id ⇒ Object
readonly
Returns the value of attribute milestone_id.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#prerequisites ⇒ Object
readonly
Returns the value of attribute prerequisites.
-
#raw_attributes ⇒ Object
readonly
Returns the value of attribute raw_attributes.
-
#remote_id ⇒ Object
readonly
Returns the value of attribute remote_id.
-
#reporter_email ⇒ Object
readonly
Returns the value of attribute reporter_email.
-
#resolution ⇒ Object
readonly
Returns the value of attribute resolution.
-
#severity ⇒ Object
readonly
Returns the value of attribute severity.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #attributes ⇒ Object
- #close! ⇒ Object
- #create_comment!(comment) ⇒ Object
- #destroy_comment!(comment) ⇒ Object
- #get_custom_value(custom_field_name) ⇒ Object
-
#initialize(connection, attributes) ⇒ Ticket
constructor
A new instance of Ticket.
- #reopen! ⇒ Object
- #resolve! ⇒ Object
- #set_milestone!(milestone_id) ⇒ Object
- #update_comment!(comment) ⇒ Object
Constructor Details
#initialize(connection, attributes) ⇒ Ticket
Returns a new instance of Ticket.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 9 def initialize(connection, attributes) @connection = connection @raw_attributes = attributes @severity = get_severity_name(attributes["severity_id"]) if attributes["severity_id"] @component = get_component_name(attributes["component_id"]) if attributes["component_id"] # required @remote_id = attributes["id"] @number = attributes["number"] @summary = attributes["summary"] @description = attributes["description"] @reporter_email = attributes["reporter_email"] @resolution = attributes["resolution"] @milestone_id = attributes["milestone_id"] @type = get_type @created_at = Time.parse(attributes["created_at"]) if attributes["created_at"] @closed_at = Time.parse(attributes["closed_on"]) if attributes["closed_on"] # optional @tags = @prerequisites = parse_prerequisites(attributes["associations"]) @due_date = attributes["due_on"] end |
Instance Attribute Details
#closed_at ⇒ Object (readonly)
Returns the value of attribute closed_at.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def closed_at @closed_at end |
#component ⇒ Object (readonly)
Returns the value of attribute component.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def component @component end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def created_at @created_at end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def description @description end |
#due_date ⇒ Object (readonly)
Returns the value of attribute due_date.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def due_date @due_date end |
#milestone_id ⇒ Object (readonly)
Returns the value of attribute milestone_id.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def milestone_id @milestone_id end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def number @number end |
#prerequisites ⇒ Object (readonly)
Returns the value of attribute prerequisites.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def prerequisites @prerequisites end |
#raw_attributes ⇒ Object (readonly)
Returns the value of attribute raw_attributes.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def raw_attributes @raw_attributes end |
#remote_id ⇒ Object (readonly)
Returns the value of attribute remote_id.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def remote_id @remote_id end |
#reporter_email ⇒ Object (readonly)
Returns the value of attribute reporter_email.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def reporter_email @reporter_email end |
#resolution ⇒ Object (readonly)
Returns the value of attribute resolution.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def resolution @resolution end |
#severity ⇒ Object (readonly)
Returns the value of attribute severity.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def severity @severity end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def summary @summary end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def @tags end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
33 34 35 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 33 def type @type end |
Instance Method Details
#attributes ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 52 def attributes { remote_id: remote_id, number: number, summary: summary, description: description, reporter_email: reporter_email, resolution: resolution, milestone_id: milestone_id, type: type, created_at: created_at, closed_at: closed_at, tags: , prerequisites: prerequisites, due_date: due_date } end |
#close! ⇒ Object
80 81 82 83 84 85 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 80 def close! Houston.benchmark title: "Close Unfuddle Ticket" do ticket = unfuddle.ticket(remote_id) ticket.update_attributes!("status" => "closed") end end |
#create_comment!(comment) ⇒ Object
107 108 109 110 111 112 113 114 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 107 def create_comment!(comment) Houston.benchmark title: "Create Unfuddle Comment" do unfuddle.as_user(comment.user) do ticket = unfuddle.ticket(remote_id) ticket.create_comment("body" => comment.body).id end end end |
#destroy_comment!(comment) ⇒ Object
128 129 130 131 132 133 134 135 136 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 128 def destroy_comment!(comment) Houston.benchmark title: "Destroy Unfuddle Comment" do unfuddle_comment = comment(comment.remote_id) return unless unfuddle_comment unfuddle_comment.project_id = unfuddle.project_id unfuddle_comment.destroy! end end |
#get_custom_value(custom_field_name) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 140 def get_custom_value(custom_field_name) unfuddle_ticket = @raw_attributes retried_once = false begin custom_field_key = custom_field_name.underscore.gsub(/\s/, "_") key = find_in_cache_or_execute(custom_field_key(custom_field_key)) do connection.get_ticket_attribute_for_custom_value_named!(custom_field_name) rescue "undefined" end value_id = unfuddle_ticket[key] return nil if value_id.blank? find_in_cache_or_execute(custom_value_key(custom_field_key, value_id)) do connection.find_custom_field_value_by_id!(custom_field_name, value_id).value end rescue if retried_once raise else # If an error occurred above, it may be because # we cached the wrong value for something. retried_once = true connection.invalidate_cache!("#{custom_field_key}_field", "#{custom_field_key}_value_#{value_id}") retry end end end |
#reopen! ⇒ Object
87 88 89 90 91 92 93 94 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 87 def reopen! unless %w{closed}.member? @raw_attributes["status"].to_s.downcase Houston.benchmark title: "Reopen Unfuddle Ticket" do ticket = unfuddle.ticket(remote_id) ticket.update_attributes!("status" => "Reopened", "resolution" => "") end end end |
#resolve! ⇒ Object
71 72 73 74 75 76 77 78 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 71 def resolve! unless %w{resolved closed}.member? @raw_attributes["status"].to_s.downcase Houston.benchmark title: "Resolve Unfuddle Ticket" do ticket = unfuddle.ticket(remote_id) ticket.update_attributes!("status" => "Resolved", "resolution" => "fixed") end end end |
#set_milestone!(milestone_id) ⇒ Object
98 99 100 101 102 103 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 98 def set_milestone!(milestone_id) Houston.benchmark title: "Update Unfuddle Ticket" do ticket = unfuddle.ticket(remote_id) ticket.update_attribute("milestone_id", milestone_id || 0) end end |
#update_comment!(comment) ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 |
# File 'app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb', line 116 def update_comment!(comment) Houston.benchmark title: "Update Unfuddle Comment" do unfuddle.as_user(comment.user) do unfuddle_comment = comment(comment.remote_id) return unless unfuddle_comment unfuddle_comment.project_id = unfuddle.project_id unfuddle_comment.update_attributes!("body" => comment.body) end end end |