Class: FakeIssue
Constant Summary collapse
- @@issue_number =
1
Instance Attribute Summary collapse
-
#effort ⇒ Object
readonly
Returns the value of attribute effort.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#worker ⇒ Object
readonly
Returns the value of attribute worker.
Instance Method Summary collapse
- #block ⇒ Object
- #blocked? ⇒ Boolean
- #change_status(date:, new_status:, new_status_id:) ⇒ Object
- #do_work(date:, effort:) ⇒ Object
- #done? ⇒ Boolean
- #fix_change_timestamps ⇒ Object
-
#initialize(date:, type:, worker:) ⇒ FakeIssue
constructor
A new instance of FakeIssue.
- #key ⇒ Object
- #unblock ⇒ Object
Constructor Details
#initialize(date:, type:, worker:) ⇒ FakeIssue
Returns a new instance of FakeIssue.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/jirametrics/experimental/generator.rb', line 15 def initialize date:, type:, worker: @raw = { key: "FAKE-#{@@issue_number += 1}", changelog: { histories: [] }, fields: { created: to_time(date), updated: to_time(date), creator: { displayName: 'George Jetson' }, issuetype: { name: type }, status: { name: 'To Do', id: 1, statusCategory: { id: 2, name: 'To Do' } }, priority: { name: '' }, summary: RandomWord.phrases.next.gsub(/_/, ' '), issuelinks: [], fixVersions: [] } } @workers = [worker] @effort = case type when 'Story' [1, 2, 3, 3, 3, 3, 4, 4, 4, 5, 6].sample else [1, 2, 3].sample end unblock @done = false @last_status = 'To Do' @last_status_id = 1 change_status new_status: 'In Progress', new_status_id: 3, date: date end |
Instance Attribute Details
#effort ⇒ Object (readonly)
Returns the value of attribute effort.
13 14 15 |
# File 'lib/jirametrics/experimental/generator.rb', line 13 def effort @effort end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
13 14 15 |
# File 'lib/jirametrics/experimental/generator.rb', line 13 def raw @raw end |
#worker ⇒ Object (readonly)
Returns the value of attribute worker.
13 14 15 |
# File 'lib/jirametrics/experimental/generator.rb', line 13 def worker @worker end |
Instance Method Details
#block ⇒ Object
62 |
# File 'lib/jirametrics/experimental/generator.rb', line 62 def block = @blocked = true |
#blocked? ⇒ Boolean
61 |
# File 'lib/jirametrics/experimental/generator.rb', line 61 def blocked? = @blocked |
#change_status(date:, new_status:, new_status_id:) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/jirametrics/experimental/generator.rb', line 92 def change_status date:, new_status:, new_status_id: @raw[:changelog][:histories] << { author: { emailAddress: '[email protected]', displayName: 'George Jetson' }, created: to_time(date), items: [ { field: 'status', fieldtype: 'jira', fieldId: 'status', from: @last_status_id, fromString: @last_status, to: new_status_id, toString: new_status } ] } @last_status = new_status @last_status_id = new_status_id end |
#do_work(date:, effort:) ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/jirametrics/experimental/generator.rb', line 67 def do_work date:, effort: raise 'Already done' if done? @effort -= effort return unless done? change_status new_status: 'Done', new_status_id: 5, date: date # fix_change_timestamps end |
#done? ⇒ Boolean
90 |
# File 'lib/jirametrics/experimental/generator.rb', line 90 def done? = @effort <= 0 |
#fix_change_timestamps ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/jirametrics/experimental/generator.rb', line 77 def # since the timestamps have random hours, it's possible for them to be issued out of order. Sort them now changes = @raw[:changelog][:histories] times = [@raw[:fields][:created]] + changes.collect { |change| change[:created] } times.sort! @raw[:fields][:created] = times.shift @raw[:fields][:updated] = times[-1] changes.each do |change| change[:created] = times.shift end end |
#key ⇒ Object
65 |
# File 'lib/jirametrics/experimental/generator.rb', line 65 def key = @raw[:key] |
#unblock ⇒ Object
63 |
# File 'lib/jirametrics/experimental/generator.rb', line 63 def unblock = @blocked = false |