class Lionel::ProxyCard

Constants

MAX_ACTIONS

Attributes

card[R]

Public Class Methods

new(card) click to toggle source
# File lib/lionel/proxy_card.rb, line 9
def initialize(card)
  @card = card
end

Public Instance Methods

action_date(&block) click to toggle source
# File lib/lionel/proxy_card.rb, line 23
def action_date(&block)
  filtered = actions.select(&block)
  return "" if filtered.empty?
  action = filtered.sort { |a, b| a.date <=> b.date }.first
  format_date action.date
end
actions(options = {}) click to toggle source
# File lib/lionel/proxy_card.rb, line 18
def actions(options = {})
  options[:limit] = options.fetch(:limit, MAX_ACTIONS)
  @actions ||= card.actions(options).map { |a| Lionel::ProxyAction.new(a) }
end
checklist_count(name) click to toggle source
# File lib/lionel/proxy_card.rb, line 66
def checklist_count(name)
  checklist = card.checklists.find { |chl| chl.name == name }
  return 0 unless checklist
  checklist.check_items.count
end
date_moved_to(list_name) click to toggle source
# File lib/lionel/proxy_card.rb, line 30
def date_moved_to(list_name)
  action = first_action { |a| a.moved_to?(list_name) }
  return "" unless action
  format_date(action.date)
end
due_date() click to toggle source
# File lib/lionel/proxy_card.rb, line 62
def due_date
  format_date(due) if due
end
estimate() click to toggle source
# File lib/lionel/proxy_card.rb, line 56
def estimate
  match = card.name.match(/\[(?<estimate>\w+)\]/)
  return "" unless match
  match[:estimate]
end
first_action(&block) click to toggle source
# File lib/lionel/proxy_card.rb, line 40
def first_action(&block)
  actions.select(&block).sort { |a, b| a.date <=> b.date }.first
end
format_date(date, format = "%m/%d/%Y") click to toggle source
# File lib/lionel/proxy_card.rb, line 36
def format_date(date, format = "%m/%d/%Y")
  date.strftime(format)
end
labels() click to toggle source
# File lib/lionel/proxy_card.rb, line 52
def labels
  @labels ||= card.labels.map(&:name).map(&:downcase)
end
project() click to toggle source
# File lib/lionel/proxy_card.rb, line 48
def project
  labels.detect { |l| l !~ %r{bug|chore|task}i }
end
type() click to toggle source
# File lib/lionel/proxy_card.rb, line 44
def type
  labels.detect { |l| l =~ %r{bug|chore|task}i } || 'story'
end