class Issue

Attributes

history[RW]

Public Class Methods

createNewIssue(title, type="bug") click to toggle source
# File bin/issues, line 75
def self.createNewIssue(title, type="bug")
  newIssue = Issue.new
  newIssue.id = SecureRandom.hex.force_encoding("UTF-8")
  newIssue.created  = Time.new
  newIssue.title = title
  newIssue.status = "open"
  newIssue.type = type
  newIssue.history = [LogEntry.new("Issue created")]
  newIssue
end
new() click to toggle source
# File bin/issues, line 69
def initialize
  @history = []
end

Public Instance Methods

copy_from(a_issue) click to toggle source
# File bin/issues, line 88
def copy_from(a_issue)
  self.class.fattrs.each do |a|
    value = a_issue.send(a)
    new_value = value.is_a?(Numeric) || value == nil ? value : value.dup
    a_issue.send(a) && self.send(a, new_value)
  end
end
edit_all() click to toggle source
# File bin/issues, line 170
def edit_all
  original_yaml = self.to_yaml
  new_yaml = edit_string(original_yaml)
  
  if (new_yaml != original_yaml)
    self.copy_from(YAML::parse(new_string))
    return true
  end 
  
  return false
end
edit_description() click to toggle source
# File bin/issues, line 157
def edit_description
  new_description = edit_string(@description)

  if new_description != @description
    @description = new_description.dup
    return true
  end

  return false
end
format_list(opts) click to toggle source
# File bin/issues, line 137
def format_list(opts)
  entry = @title.dup
  info_string = "#{short_id} (#{@type[0,1].capitalize})"

  if opts[:list_milestone] == true
    width = opts[:milestone_column_width]
    info_string << " " << (@milestone ? @milestone.ljust(width) : "UNASSIGNED".ljust(width))
  end

  if opts[:list_estimate] == true
    info_string << " " << (@estimate ? sprintf("%.2fh", @estimate).rjust(4) : "     ")
  end

  #suffix = estimate_milestone.count > 0 ? "[#{estimate_milestone.join(' => ')}]" : ""
  
  PrettyComment.format_line(entry, info_string, true) 
end
format_verbose(opts) click to toggle source
# File bin/issues, line 105
def format_verbose(opts)
  milestone = @milestone ? "#{@milestone}" : "NO MILESTONE"
  estimate = @estimate ? "#{@estimate}h" : "NO ESTIMATE"
  milestone_estimate = "[#{estimate}, #{milestone}]"
  
  result = []
  result << PrettyComment.separator
  result << PrettyComment.comment("#{@id[0,6]} #{@type.capitalize} (#{@status}) #{milestone_estimate} #{@created.to_s[0,16]}")
  result << PrettyComment.comment("")
  result << PrettyComment.format_line(@title, "#", false, "#")
  
  if @description
    result << PrettyComment.sub_heading("Description:")
    @description.split("\n").each do |l|
      result << PrettyComment.format_line(l, "#", false, "#")
    end
  end
  
  if @history && @history.count > 0
    result << PrettyComment.sub_heading("Log:")
    @history.each { |l| result << PrettyComment.format_line("#{l.message}", "# #{l.date.to_s[0,16]}", true, "#", "#") }
  end
  
  result << PrettyComment.separator
  result << ""
  result << ""
  
  result.join("\n")
end
log(message) click to toggle source
# File bin/issues, line 98
def log(message)
  @history ||= []
  @history << LogEntry.new(message)
end
short_id() click to toggle source
# File bin/issues, line 184
def short_id
  @id[0,6]
end