From 73e0dca6d92f61117cc5be341ec1ea211a7eef65 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Thu, 29 Sep 2011 09:35:23 -0400 Subject: [PATCH] add catchup --- bin/tracker | 17 +++++++++++++++++ pretty-tracker.gemspec | 1 + 2 files changed, 18 insertions(+) diff --git a/bin/tracker b/bin/tracker index 261ff43..a8b324a 100755 --- a/bin/tracker +++ b/bin/tracker @@ -7,6 +7,7 @@ require 'thor' require 'rainbow' require 'tempfile' require 'yaml' +require 'chronic' CACHE_TIME = 60 GIT_PIVOTAL_PROJECT_ID_KEY = "pivotal.project-id" @@ -69,6 +70,22 @@ class Tracker < Thor :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 ", "Create a new feature in the current project" def feature(name, estimate = nil) params = { :name => name, :story_type => :feature, :current_state => :unstarted } diff --git a/pretty-tracker.gemspec b/pretty-tracker.gemspec index a1aded1..35796d0 100644 --- a/pretty-tracker.gemspec +++ b/pretty-tracker.gemspec @@ -23,4 +23,5 @@ Gem::Specification.new do |s| s.add_runtime_dependency "pivotal-tracker", '~> 0.4.0' s.add_runtime_dependency "rainbow" s.add_runtime_dependency "thor" + s.add_runtime_dependency "chronic" end