Sha256: 1a3a532fa8e6efad5167209232b37010fb5fc4e914e983d38e7c264d5282ac59

Contents?: true

Size: 1.35 KB

Versions: 17

Compression:

Stored size: 1.35 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

      title = sprintf("%s[%s]%s%s", '  '*(self.level-1), header, name, 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

17 entries across 17 versions & 1 rubygems

Version Path
dev_flow-0.1.6 lib/dev_flow/task_console.rb
dev_flow-0.1.5 lib/dev_flow/task_console.rb
dev_flow-0.1.4 lib/dev_flow/task_console.rb
dev_flow-0.1.3 lib/dev_flow/task_console.rb
dev_flow-0.1.2 lib/dev_flow/task_console.rb
dev_flow-0.1.1 lib/dev_flow/task_console.rb
dev_flow-0.1.0 lib/dev_flow/task_console.rb
dev_flow-0.0.13 lib/dev_flow/task_console.rb
dev_flow-0.0.12 lib/dev_flow/task_console.rb
dev_flow-0.0.11 lib/dev_flow/task_console.rb
dev_flow-0.0.10 lib/dev_flow/task_console.rb
dev_flow-0.0.9 lib/dev_flow/task_console.rb
dev_flow-0.0.8 lib/dev_flow/task_console.rb
dev_flow-0.0.7 lib/dev_flow/task_console.rb
dev_flow-0.0.6 lib/dev_flow/task_console.rb
dev_flow-0.0.5 lib/dev_flow/task_console.rb
dev_flow-0.0.4 lib/dev_flow/task_console.rb