Class: Ditz::Issue
Defined Under Namespace
Classes: Error
Constant Summary
collapse
- 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 ]
- 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_release(release, who, comment) ⇒ Object
-
#before_serialize(project) ⇒ Object
-
#bug? ⇒ Boolean
-
#change(hash, who, comment) ⇒ Object
-
#close(disp, who, comment) ⇒ Object
-
#closed? ⇒ Boolean
-
#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
-
#in_progress? ⇒ Boolean
-
#interpolated_desc(issues) ⇒ Object
-
#make_id(config, project) ⇒ Object
-
#open? ⇒ Boolean
-
#sort_order ⇒ Object
-
#start_work(who, comment) ⇒ Object
-
#status_string ⇒ Object
-
#status_widget ⇒ Object
-
#stop_work(who, comment) ⇒ Object
-
#unassign(who, comment) ⇒ Object
Methods inherited from ModelObject
#after_deserialize, #changed!, #changed?, changes_are_logged, create_interactively, #each_modelobject, field, fields, from, inherited, #initialize, #log, #save!, #to_yaml_properties, #to_yaml_type, yaml_domain, yaml_other_thing
Instance Attribute Details
Returns the value of attribute name.
116
117
118
|
# File 'lib/model-objects.rb', line 116
def name
@name
end
|
Instance Method Details
#assign_to_release(release, who, comment) ⇒ Object
200
201
202
203
|
# File 'lib/model-objects.rb', line 200
def assign_to_release release, who,
log "assigned to release #{release.name} from #{self.release || 'unassigned'}", who,
self.release = release.name
end
|
#before_serialize(project) ⇒ Object
127
128
129
130
131
|
# File 'lib/model-objects.rb', line 127
def before_serialize project
self.desc = project.issues.inject(desc) do |s, i|
s.gsub(/\b#{i.name}\b/, "{issue #{i.id}}")
end
end
|
#bug? ⇒ Boolean
153
|
# File 'lib/model-objects.rb', line 153
def bug?; type == :bugfix end
|
#change(hash, who, comment) ⇒ Object
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
# File 'lib/model-objects.rb', line 177
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
162
163
164
165
166
167
|
# File 'lib/model-objects.rb', line 162
def close disp, who,
raise Error, "unknown disposition #{disp}" unless DISPOSITIONS.member? disp
log "closed issue with disposition #{disp}", who,
self.status = :closed
self.disposition = disp
end
|
#closed? ⇒ Boolean
150
|
# File 'lib/model-objects.rb', line 150
def closed?; status == :closed end
|
#disposition_string ⇒ Object
148
|
# File 'lib/model-objects.rb', line 148
def disposition_string; DISPOSITION_STRINGS[disposition] || disposition.to_s end
|
#feature? ⇒ Boolean
154
|
# File 'lib/model-objects.rb', line 154
def feature?; type == :feature end
|
#get_component(config, project) ⇒ Object
216
217
218
219
220
221
222
|
# File 'lib/model-objects.rb', line 216
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
224
225
226
227
228
229
230
231
232
233
234
235
|
# File 'lib/model-objects.rb', line 224
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
237
238
239
|
# File 'lib/model-objects.rb', line 237
def get_reporter config, project
reporter = ask "Creator", :default => config.user
end
|
#get_type(config, project) ⇒ Object
211
212
213
214
|
# File 'lib/model-objects.rb', line 211
def get_type config, project
type = ask "Is this a (b)ugfix or a (f)eature?", :restrict => /^[bf]$/
type == "b" ? :bugfix : :feature
end
|
#in_progress? ⇒ Boolean
152
|
# File 'lib/model-objects.rb', line 152
def in_progress?; status == :in_progress end
|
#interpolated_desc(issues) ⇒ Object
133
134
135
136
137
|
# File 'lib/model-objects.rb', line 133
def interpolated_desc issues
issues.inject(desc) do |s, i|
s.gsub(/\{issue #{i.id}\}/, block_given? ? yield(i) : i.name)
end.gsub(/\{issue \w+\}/, "[unknown issue]")
end
|
#make_id(config, project) ⇒ Object
140
141
142
|
# File 'lib/model-objects.rb', line 140
def make_id config, project
SHA1.hexdigest [Time.now, rand, creation_time, reporter, title, desc].join("\n")
end
|
#open? ⇒ Boolean
151
|
# File 'lib/model-objects.rb', line 151
def open?; !closed? end
|
#sort_order ⇒ Object
144
|
# File 'lib/model-objects.rb', line 144
def sort_order; [STATUS_SORT_ORDER[@status], creation_time] end
|
#start_work(who, comment) ⇒ Object
156
|
# File 'lib/model-objects.rb', line 156
def start_work who, ; change_status :in_progress, who, end
|
#status_string ⇒ Object
147
|
# File 'lib/model-objects.rb', line 147
def status_string; STATUS_STRINGS[status] || status.to_s end
|
145
|
# File 'lib/model-objects.rb', line 145
def status_widget; STATUS_WIDGET[@status] end
|
#stop_work(who, comment) ⇒ Object
157
158
159
160
|
# File 'lib/model-objects.rb', line 157
def stop_work who,
raise Error, "unstarted" unless self.status == :in_progress
change_status :paused, who,
end
|
#unassign(who, comment) ⇒ Object
205
206
207
208
209
|
# File 'lib/model-objects.rb', line 205
def unassign who,
raise Error, "not assigned to a release" unless release
log "unassigned from release #{release}", who,
self.release = nil
end
|