Sha256: 029ee7c9387bd45ecae39e7ed1074697601e72d9f2b942e1ba2877e66d11021f

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

module Helpers
  def format_author(author)
    [:name, :email, :company, :website].map do |key|
      author[key]
    end.compact.join(', ')
  end
  
  def format_estimate(cardinality, interval)
    case interval
    when :days
      "#{cardinality}d"
    when :weeks
      "#{cardinality}w"
    else
      cardinality.to_s
    end
  end
  
  def format_story(story, kind=:regular)
    story_attributes = []
    story_attributes << "##{story[:id]}" if story[:id]
    story_attributes << story[:status] if story[:status]
    story_attributes << format_estimate(*story[:estimate]) if story[:estimate]
    story_attributes << "i#{story[:iteration]}" if story[:iteration]
    
    prefix = (kind == :nested) ? '| ' : ''
    formatted  = "#{prefix}#{story[:description]}"
    formatted << " - #{story_attributes.join(' ')}" unless story_attributes.empty?
    formatted << "\n"
    formatted << "#{prefix}  #{story[:notes]}\n" if story[:notes]
    story[:stories].each do |nested|
      formatted << format_story(nested, :nested)
    end if story[:stories]
    formatted
  end
  
  def format_definition(definition)
    [definition[:title], definition[:definition]].join(': ')
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
saga-0.11.1 templates/saga/helpers.rb
saga-0.11.0 templates/saga/helpers.rb
saga-0.10.0 templates/saga/helpers.rb
saga-0.9.1 templates/saga/helpers.rb
saga-0.9.0 templates/saga/helpers.rb
saga-0.8.1 templates/saga/helpers.rb
saga-0.8.0 templates/saga/helpers.rb