add catchup

This commit is contained in:
John Bintz 2011-09-29 09:35:23 -04:00
parent 61ad631ba4
commit 73e0dca6d9
2 changed files with 18 additions and 0 deletions

View File

@ -7,6 +7,7 @@ require 'thor'
require 'rainbow' require 'rainbow'
require 'tempfile' require 'tempfile'
require 'yaml' require 'yaml'
require 'chronic'
CACHE_TIME = 60 CACHE_TIME = 60
GIT_PIVOTAL_PROJECT_ID_KEY = "pivotal.project-id" GIT_PIVOTAL_PROJECT_ID_KEY = "pivotal.project-id"
@ -69,6 +70,22 @@ class Tracker < Thor
:score => '2255cc' :score => '2255cc'
} }
desc "catchup", "Catch up on the latest changes to all your projects"
method_options :limit => "30"
def catchup(since = 'yesterday')
PivotalTracker::Activity.all(nil, :limit => options[:limit].to_i, :occurred_since_date => Chronic.parse(since)).each do |activity|
story = activity.description.dup
story.gsub!(%r{^#{activity.author} }, '')
story.gsub!(%r{"(.*)"}, '\1'.foreground(COLORS[:comment]))
time = activity.occurred_at.strftime('%Y-%m-%d %H:%M')
project = all_projects.find { |p| p.id == activity.project_id }
puts "[#{time.foreground(COLORS[:id])}] #{activity.author.foreground(COLORS[:label])} #{story} in #{project.name.foreground(COLORS[:project])} (#{activity.stories.first.id.to_s.foreground(COLORS[:id])})"
end
end
desc "feature NAME <score>", "Create a new feature in the current project" desc "feature NAME <score>", "Create a new feature in the current project"
def feature(name, estimate = nil) def feature(name, estimate = nil)
params = { :name => name, :story_type => :feature, :current_state => :unstarted } params = { :name => name, :story_type => :feature, :current_state => :unstarted }

View File

@ -23,4 +23,5 @@ Gem::Specification.new do |s|
s.add_runtime_dependency "pivotal-tracker", '~> 0.4.0' s.add_runtime_dependency "pivotal-tracker", '~> 0.4.0'
s.add_runtime_dependency "rainbow" s.add_runtime_dependency "rainbow"
s.add_runtime_dependency "thor" s.add_runtime_dependency "thor"
s.add_runtime_dependency "chronic"
end end