Class: Wlog::Issue

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/wlog/domain/issue.rb

Overview

Author:

  • Simon Symeonidis

Constant Summary collapse

StatusNew =
0
StatusStarted =
1
StatusFinished =
2
StatusArchived =
3

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.find_not_archivedObject

Anything which is not archived (eg: new, started work, finished)



23
# File 'lib/wlog/domain/issue.rb', line 23

def self.find_not_archived; where("status NOT IN (?)", StatusArchived) end

Instance Method Details

#archive!Object

Archive the issue



59
# File 'lib/wlog/domain/issue.rb', line 59

def archive!; self.status = 3 end

#log_time(sec) ⇒ Object

Log the seconds into the issue



26
27
28
29
# File 'lib/wlog/domain/issue.rb', line 26

def log_time(sec)
  self.timelog += sec
  save
end

#mark_finished!Object

Mark the issue as finished



56
# File 'lib/wlog/domain/issue.rb', line 56

def mark_finished!; self.status = 2 end

#mark_started!Object

Mark issue as started



50
# File 'lib/wlog/domain/issue.rb', line 50

def mark_started!; self.status = 0 end

#mark_working!Object

Mark the issue as working



53
# File 'lib/wlog/domain/issue.rb', line 53

def mark_working!; self.status = 1 end

#status_sObject

Get the status as a string



62
# File 'lib/wlog/domain/issue.rb', line 62

def status_s; Statuses[status] end

#to_sObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/wlog/domain/issue.rb', line 31

def to_s
  le_count = self.log_entries.count
  @strmaker = SysConfig.string_decorator
  "#{@strmaker.yellow('Issue')} ##{id}#{$/}"\
  "  #{@strmaker.blue('Reported')} : #{created_at.asctime}#{$/}"\
  "  #{@strmaker.blue('Due')}      : #{due_date.asctime}#{$/}"\
  "  #{@strmaker.blue('Entries')}  : #{le_count} #{$/}"\
  "  #{@strmaker.blue('Status')}   : #{Statuses[status]}#{$/}"\
  "  #{@strmaker.blue('Time')}     : #{TimelogHelper.time_to_s(timelog)}#{$/}"\
  "#{$/}"\
"#{@strmaker.yellow('Summary')} #{$/}"\
  "  #{description}#{$/ + $/}"\
"#{@strmaker.yellow('Description')} #{$/}"\
  "  #{Helpers.break_string(long_description, 80)}#{$/ + $/}"\
  "#{@strmaker.yellow('Files')}#{$/}"\
  "#{attachments_s}"
end