Sha256: 4b20246954bf42ae3068c7bc215ddc89b9e8799e7450e70a3acf43af5b66082e
Contents?: true
Size: 1.52 KB
Versions: 15
Compression:
Stored size: 1.52 KB
Contents
module DevFlow class Task def as_title header = ' ' name = self.display_name name = self.display_name.bold if self.is_workable? name = self.display_name.blue if self.progress > 0 name = self.display_name.green if self.is_completed? name = self.display_name.magenta if self.is_urgent? name = self.display_name.red if self.is_delayed? if self.progress > 0 and self.progress < 100 on_branch = sprintf "(=> %s, %02d%%)", self.branch_name.bold, self.progress end d1 = DateName.zh(self.start_date, DateTime.now.strftime("%F")).bold d2 = DateName.zh(self.end_date, DateTime.now.strftime("%F")).bold title = sprintf("%s[%s]%s (%s-%s) %s", ' '*(self.level-1), header, name, d1, d2, on_branch) end ## a task is completable if all children complated def is_completable? return false if self.is_completed? self.children.each do |child| return false unless child.is_completed? end true end ## a task is workable (can be started) if all children # task and dependent task are completed def is_workable? # trivial: if already completed, do not start again return false if self.is_completed? return false if self.is_pending or self.is_deleted self.dependencies.each do |t| return false unless t.is_completed? end self.children.each do |t| return false unless t.is_completed? end true end end end
Version data entries
15 entries across 15 versions & 1 rubygems