class Ditz::Issue

Constants

DISPOSITIONS
DISPOSITION_STRINGS
INTERPOLATED_FIELDS

these are the fields we interpolate issue names on

STATUSES
STATUS_SORT_ORDER
STATUS_STRINGS
STATUS_WIDGET
TYPES
TYPE_LETTER
TYPE_ORDER

Attributes

name[RW]
pathname[RW]
project[RW]

Public Instance Methods

assign_to_component(component, who, comment) click to toggle source
# File lib/model-objects.rb, line 276
def assign_to_component component, who, comment
  log "assigned to component #{component.name} from #{self.component}", who, comment
  self.component = component.name
end
assign_to_release(release, who, comment) click to toggle source
# File lib/model-objects.rb, line 271
def assign_to_release release, who, comment
  log "assigned to release #{release.name} from #{self.release || 'unassigned'}", who, comment
  self.release = release.name
end
assigned?() click to toggle source
# File lib/model-objects.rb, line 222
def assigned?; !unassigned? end
bug?() click to toggle source
# File lib/model-objects.rb, line 219
def bug?; type == :bugfix end
change(hash, who, comment, silent) click to toggle source
# File lib/model-objects.rb, line 246
def change hash, who, comment, silent
  what = []
  if title != hash[:title]
    what << "title"
    self.title = hash[:title]
  end

  if desc != hash[:description]
    what << "description"
    self.desc = hash[:description]
  end

  if reporter != hash[:reporter]
    what << "reporter"
    self.reporter = hash[:reporter]
  end

  unless what.empty? || silent
    log "edited " + what.join(", "), who, comment
    true
  end

  !what.empty?
end
claim(who, comment, force=false) click to toggle source
# File lib/plugins/issue-claiming.rb, line 24
def claim who, comment, force=false
  raise Error, "already claimed by #{claimer}" if claimer && !force
  log "issue claimed", who, comment
  self.claimer = who
end
claimed?() click to toggle source
# File lib/plugins/issue-claiming.rb, line 41
def claimed?; claimer end
close(disp, who, comment) click to toggle source
# File lib/model-objects.rb, line 231
def close disp, who, comment
  raise Error, "unknown disposition #{disp}" unless DISPOSITIONS.member? disp
  log "closed with disposition #{disp}", who, comment
  self.status = :closed
  self.disposition = disp
end
closed?() click to toggle source
# File lib/model-objects.rb, line 215
def closed?; status == :closed end
deserialized_form_of(field, value) click to toggle source
Calls superclass method
# File lib/model-objects.rb, line 187
def deserialized_form_of field, value
  return super unless INTERPOLATED_FIELDS.member? field

  if field == :log_events
    value.map do |time, who, what, comment|
      comment = @project.issues.inject(comment) do |s, i|
        s.gsub(/\{issue #{i.id}\}/, i.name)
      end.gsub(/\{issue \w+\}/, "[unknown issue]")
      [time, who, what, comment]
    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() click to toggle source
# File lib/model-objects.rb, line 213
def disposition_string; DISPOSITION_STRINGS[disposition] || disposition.to_s end
feature?() click to toggle source
# File lib/model-objects.rb, line 220
def feature?; type == :feature end
get_component(config, project) click to toggle source
# File lib/model-objects.rb, line 292
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) click to toggle source
# File lib/model-objects.rb, line 300
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) click to toggle source
# File lib/model-objects.rb, line 313
def get_reporter config, project
  reporter = ask "Creator", :default => config.user
end
get_type(config, project) click to toggle source
# File lib/model-objects.rb, line 287
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() click to toggle source
# File lib/plugins/git.rb, line 35
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?() click to toggle source
# File lib/model-objects.rb, line 217
def in_progress?; status == :in_progress end
make_id(config, project) click to toggle source

make a unique id

# File lib/model-objects.rb, line 205
def make_id config, project
  SHA1.hexdigest [Time.now, rand, creation_time, reporter, title, desc].join("\n")
end
open?() click to toggle source
# File lib/model-objects.rb, line 216
def open?; !closed? end
paused?() click to toggle source
# File lib/model-objects.rb, line 223
def paused?; status == :paused end
serialized_form_of(field, value) click to toggle source
Calls superclass method
# File lib/model-objects.rb, line 170
def serialized_form_of field, value
  return super unless INTERPOLATED_FIELDS.member? field

  if field == :log_events
    value.map do |time, who, what, comment|
      comment = @project.issues.inject(comment) do |s, i|
        s.gsub(/\b#{i.name}\b/, "{issue #{i.id}}")
      end
      [time, who, what, comment]
    end
  else
    @project.issues.inject(value) do |s, i|
      s.gsub(/\b#{i.name}\b/, "{issue #{i.id}}")
    end
  end
end
sort_order() click to toggle source
# File lib/model-objects.rb, line 209
def sort_order; [STATUS_SORT_ORDER[status], creation_time] end
start_work(who, comment;) click to toggle source
# File lib/model-objects.rb, line 225
def start_work who, comment; change_status :in_progress, who, comment end
status_string() click to toggle source
# File lib/model-objects.rb, line 212
def status_string; STATUS_STRINGS[status] || status.to_s end
status_widget() click to toggle source
# File lib/model-objects.rb, line 210
def status_widget; STATUS_WIDGET[status] end
stop_work(who, comment) click to toggle source
# File lib/model-objects.rb, line 226
def stop_work who, comment
  raise Error, "unstarted" unless self.status == :in_progress
  change_status :paused, who, comment
end
unassign(who, comment) click to toggle source
# File lib/model-objects.rb, line 281
def unassign who, comment
  raise Error, "not assigned to a release" unless release
  log "unassigned from release #{release}", who, comment
  self.release = nil
end
unassigned?() click to toggle source
# File lib/model-objects.rb, line 221
def unassigned?; release.nil? end
unclaim(who, comment, force=false) click to toggle source
# File lib/plugins/issue-claiming.rb, line 30
def unclaim who, comment, force=false
  raise Error, "not claimed" unless claimer
  raise Error, "can only be unclaimed by #{claimer}" unless claimer == who || force
  if claimer == who
    log "issue unclaimed", who, comment
  else
    log "unassigned from #{claimer}", who, comment
  end
  self.claimer = nil
end
unclaimed?() click to toggle source
# File lib/plugins/issue-claiming.rb, line 42
def unclaimed?; !claimed? end
unstarted?() click to toggle source
# File lib/model-objects.rb, line 218
def unstarted?; !in_progress? end

Private Instance Methods

change_status(to, who, comment) click to toggle source
# File lib/model-objects.rb, line 238
def change_status to, who, comment
  raise Error, "unknown status #{to}" unless STATUSES.member? to
  raise Error, "already marked as #{to}" if status == to
  log "changed status from #{status} to #{to}", who, comment
  self.status = to
end