Class: Ditz::Issue
Defined Under Namespace
Classes: Error
Constant Summary
collapse
- INTERPOLATED_FIELDS =
these are the fields we interpolate issue names on
[:title, :desc, :log_events]
- STATUS_SORT_ORDER =
{ :unstarted => 2, :paused => 1, :in_progress => 0, :closed => 3 }
- STATUS_WIDGET =
{ :unstarted => "_", :in_progress => ">", :paused => "=", :closed => "x" }
- DISPOSITIONS =
[ :fixed, :wontfix, :reorg ]
- TYPES =
[ :bugfix, :feature, :task ]
- TYPE_ORDER =
{ :bugfix => 0, :feature => 1, :task => 2 }
- TYPE_LETTER =
{ 'b' => :bugfix, 'f' => :feature, 't' => :task }
- STATUSES =
STATUS_WIDGET.keys
- STATUS_STRINGS =
{ :in_progress => "in progress", :wontfix => "won't fix" }
- DISPOSITION_STRINGS =
{ :wontfix => "won't fix", :reorg => "reorganized" }
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#assign_to_component(component, who, comment) ⇒ Object
-
#assign_to_release(release, who, comment) ⇒ Object
-
#assigned? ⇒ Boolean
-
#bug? ⇒ Boolean
-
#change(hash, who, comment) ⇒ Object
-
#close(disp, who, comment) ⇒ Object
-
#closed? ⇒ Boolean
-
#deserialized_form_of(field, value) ⇒ Object
-
#disposition_string ⇒ Object
-
#feature? ⇒ Boolean
-
#get_component(config, project) ⇒ Object
-
#get_release(config, project) ⇒ Object
-
#get_reporter(config, project) ⇒ Object
-
#get_type(config, project) ⇒ Object
-
#git_commits ⇒ Object
-
#in_progress? ⇒ Boolean
-
#make_id(config, project) ⇒ Object
-
#open? ⇒ Boolean
-
#serialized_form_of(field, value) ⇒ Object
-
#sort_order ⇒ Object
-
#start_work(who, comment) ⇒ Object
-
#status_string ⇒ Object
-
#status_widget ⇒ Object
-
#stop_work(who, comment) ⇒ Object
-
#unassign(who, comment) ⇒ Object
-
#unassigned? ⇒ Boolean
-
#unstarted? ⇒ Boolean
Methods inherited from ModelObject
#changed!, #changed?, changes_are_logged, create_interactively, #each_modelobject, field, field_names, from, inherited, #initialize, #inspect, #log, #save!, #to_s, #to_yaml, #to_yaml_type, #unchanged!, yaml_domain, yaml_other_thing
Instance Attribute Details
Returns the value of attribute name.
127
128
129
|
# File 'lib/model-objects.rb', line 127
def name
@name
end
|
Returns the value of attribute pathname.
127
128
129
|
# File 'lib/model-objects.rb', line 127
def pathname
@pathname
end
|
Returns the value of attribute project.
127
128
129
|
# File 'lib/model-objects.rb', line 127
def project
@project
end
|
Instance Method Details
#assign_to_component(component, who, comment) ⇒ Object
246
247
248
249
|
# File 'lib/model-objects.rb', line 246
def assign_to_component component, who,
log "assigned to component #{component.name} from #{self.component}", who,
self.component = component.name
end
|
#assign_to_release(release, who, comment) ⇒ Object
241
242
243
244
|
# File 'lib/model-objects.rb', line 241
def assign_to_release release, who,
log "assigned to release #{release.name} from #{self.release || 'unassigned'}", who,
self.release = release.name
end
|
#assigned? ⇒ Boolean
195
|
# File 'lib/model-objects.rb', line 195
def assigned?; !unassigned? end
|
#bug? ⇒ Boolean
192
|
# File 'lib/model-objects.rb', line 192
def bug?; type == :bugfix end
|
#change(hash, who, comment) ⇒ Object
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
# File 'lib/model-objects.rb', line 218
def change hash, who,
what = []
if title != hash[:title]
what << "changed title"
self.title = hash[:title]
end
if desc != hash[:description]
what << "changed description"
self.desc = hash[:description]
end
if reporter != hash[:reporter]
what << "changed reporter"
self.reporter = hash[:reporter]
end
unless what.empty?
log what.join(", "), who,
true
end
end
|
#close(disp, who, comment) ⇒ Object
203
204
205
206
207
208
|
# File 'lib/model-objects.rb', line 203
def close disp, who,
raise Error, "unknown disposition #{disp}" unless DISPOSITIONS.member? disp
log "closed with disposition #{disp}", who,
self.status = :closed
self.disposition = disp
end
|
#closed? ⇒ Boolean
188
|
# File 'lib/model-objects.rb', line 188
def closed?; status == :closed end
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/model-objects.rb', line 160
def deserialized_form_of field, value
return super unless INTERPOLATED_FIELDS.member? field
if field == :log_events
value.map do |time, who, what, |
= @project.issues.inject() do |s, i|
s.gsub(/\{issue #{i.id}\}/, i.name)
end.gsub(/\{issue \w+\}/, "[unknown issue]")
[time, who, what, ]
end
else
@project.issues.inject(value) do |s, i|
s.gsub(/\{issue #{i.id}\}/, i.name)
end.gsub(/\{issue \w+\}/, "[unknown issue]")
end
end
|
#disposition_string ⇒ Object
186
|
# File 'lib/model-objects.rb', line 186
def disposition_string; DISPOSITION_STRINGS[disposition] || disposition.to_s end
|
#feature? ⇒ Boolean
193
|
# File 'lib/model-objects.rb', line 193
def feature?; type == :feature end
|
#get_component(config, project) ⇒ Object
262
263
264
265
266
267
268
|
# File 'lib/model-objects.rb', line 262
def get_component config, project
if project.components.size == 1
project.components.first
else
ask_for_selection project.components, "component", :name
end.name
end
|
#get_release(config, project) ⇒ Object
270
271
272
273
274
275
276
277
278
279
280
281
|
# File 'lib/model-objects.rb', line 270
def get_release config, project
releases = project.releases.select { |r| r.unreleased? }
if !releases.empty? && ask_yon("Assign to a release now?")
if releases.size == 1
r = releases.first
puts "Assigning to release #{r.name}."
r
else
ask_for_selection releases, "release", :name
end.name
end
end
|
#get_reporter(config, project) ⇒ Object
283
284
285
|
# File 'lib/model-objects.rb', line 283
def get_reporter config, project
reporter = ask "Creator", :default => config.user
end
|
#get_type(config, project) ⇒ Object
257
258
259
260
|
# File 'lib/model-objects.rb', line 257
def get_type config, project
type = ask "Is this a (b)ugfix, a (f)eature, or a (t)ask?", :restrict => /^[bft]$/
TYPE_LETTER[type]
end
|
#git_commits ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/plugins/git.rb', line 7
def git_commits
return @git_commits if @git_commits
filters = ["--grep=\"Ditz-issue: #{id}\""]
filters << "master..#{git_branch}" if git_branch
output = filters.map do |f|
`git log --pretty=format:\"%aD\t%an <%ae>\t%h\t%s\" #{f}`
end.join
@git_commits = output.split(/\n/).map { |l| l.split("\t") }.
map { |date, email, hash, msg| [Time.parse(date).utc, email, hash, msg] }
end
|
#in_progress? ⇒ Boolean
190
|
# File 'lib/model-objects.rb', line 190
def in_progress?; status == :in_progress end
|
#make_id(config, project) ⇒ Object
178
179
180
|
# File 'lib/model-objects.rb', line 178
def make_id config, project
SHA1.hexdigest [Time.now, rand, creation_time, reporter, title, desc].join("\n")
end
|
#open? ⇒ Boolean
189
|
# File 'lib/model-objects.rb', line 189
def open?; !closed? end
|
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# File 'lib/model-objects.rb', line 143
def serialized_form_of field, value
return super unless INTERPOLATED_FIELDS.member? field
if field == :log_events
value.map do |time, who, what, |
= @project.issues.inject() do |s, i|
s.gsub(/\b#{i.name}\b/, "{issue #{i.id}}")
end
[time, who, what, ]
end
else
@project.issues.inject(value) do |s, i|
s.gsub(/\b#{i.name}\b/, "{issue #{i.id}}")
end
end
end
|
#sort_order ⇒ Object
182
|
# File 'lib/model-objects.rb', line 182
def sort_order; [STATUS_SORT_ORDER[status], creation_time] end
|
#start_work(who, comment) ⇒ Object
197
|
# File 'lib/model-objects.rb', line 197
def start_work who, ; change_status :in_progress, who, end
|
#status_string ⇒ Object
185
|
# File 'lib/model-objects.rb', line 185
def status_string; STATUS_STRINGS[status] || status.to_s end
|
183
|
# File 'lib/model-objects.rb', line 183
def status_widget; STATUS_WIDGET[status] end
|
#stop_work(who, comment) ⇒ Object
198
199
200
201
|
# File 'lib/model-objects.rb', line 198
def stop_work who,
raise Error, "unstarted" unless self.status == :in_progress
change_status :paused, who,
end
|
#unassign(who, comment) ⇒ Object
251
252
253
254
255
|
# File 'lib/model-objects.rb', line 251
def unassign who,
raise Error, "not assigned to a release" unless release
log "unassigned from release #{release}", who,
self.release = nil
end
|
#unassigned? ⇒ Boolean
194
|
# File 'lib/model-objects.rb', line 194
def unassigned?; release.nil? end
|
#unstarted? ⇒ Boolean
191
|
# File 'lib/model-objects.rb', line 191
def unstarted?; !in_progress? end
|