Skip to content

Instantly share code, notes, and snippets.

@dirkkelly
Last active December 17, 2015 23:39
Show Gist options
  • Save dirkkelly/5690677 to your computer and use it in GitHub Desktop.
Save dirkkelly/5690677 to your computer and use it in GitHub Desktop.
Dashing - Pivotal Tracker

Preview

Description

Simple Dashing job to display your Pivotal Tracker stories status.

  • Green: You don't own any rejected stories
  • Red: You own a rejected story
  • Striped: You haven't started a story

I borrowed heavily from the Semaphore extension, hopefully they look nice side-by-side.

##Dependencies

Pivotal Tracker Gem

Add it to dashing's gemfile:

gem 'pivotal-tracker'

Usage

Installation

  • dashing install 5690677
  • Copy in the Tracker logo
wget https://dl.dropboxusercontent.com/u/17429266/gems/dashing/tracker/tracker-logo.png
mv tracker-logo.png assets/images/tracker-logo.png

Configuration

To configure projects add the following block to the bottom of jobs/tracker.rb

  • PROJECT_ID available in the url of your project
  • TRACKER_TOKEN https://www.pivotaltracker.com/profile]
  • TRACKER_FULL_NAME The field called name under MY PROFILE
  • MY_TRACKER_PROJECT id of the widget in your template
SCHEDULER.every '1m', :first_in => 0 do |job|
  project = Tracker.new(PROJECT_ID, TRACKER_TOKEN, TRACKER_FULL_NAME)
  status = project.latest_status
  send_event MY_TRACKER_PROJECT, { passed: status.passing?, pending: status.pending? }
end

On Your Dashboard

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-view="Tracker" data-id="MY_TRACKER_PROJECT" data-title="George Michael's Tracker"></div>
</li>
class Dashing.Tracker extends Dashing.Widget
onData: (data) ->
$(@node).toggleClass('passed', data.passed)
$(@node).toggleClass('failed', !data.passed)
$(@node).toggleClass('pending', data.pending)
<h1 class="title" data-bind="title"></h1>
<p class="more-info" data-bind="moreinfo"></p>
<p class="updated-at" data-bind="updatedAtMessage"></p>
<i class="icon"></i>
require 'json'
require 'pivotal-tracker'
class Tracker
def initialize(project_id, user_token, *user_name)
@project_id, @user_name = project_id, user_name.join(" ")
PivotalTracker::Client.token = user_token
end
def latest_status
project = PivotalTracker::Project.find(@project_id)
project_view = TrackerProjectView.new(project, @user_name)
TrackerStatus.new(project_view)
end
end
class TrackerStatus
def initialize(project_view)
@project_view = project_view
end
def passing?
@project_view.rejected_stories.empty?
end
def pending?
@project_view.started_stories.empty? && \
@project_view.rejected_stories.empty?
end
end
class TrackerProjectView
def initialize(project, user_name)
@project, @user_name = project, user_name
end
def started_stories; stories_marked_as(:started); end
def rejected_stories; stories_marked_as(:rejected); end
private
def owned_stories
@owned_stories ||= @project.stories.all(:owned_by => @user_name)
end
def stories_marked_as(state)
owned_stories.select { |s| s.current_state == state.to_s }
end
end
SCHEDULER.every '1m', :first_in => 0 do |job|
project = Tracker.new(PROJECT_ID, TRACKER_TOKEN, TRACKER_FULL_NAME)
status = project.latest_status
send_event(MY_TRACKER_PROJECT, { passed: status.passing?, pending: status.pending? })
end
$background-error-color: #ad3b0e;
$background-passed-color: #8fb347;
$title-color: rgba(255, 255, 255, 0.7);
$updated-at-color: rgba(0, 0, 0, 0.3);
.widget-tracker {
&.passed {
background-color: $background-passed-color;
}
&.failed {
background-color: $background-error-color;
}
&.pending {
background-size: 72px 72px;
background-image: linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
-webkit-background-size: 72px 72px;
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(.5, rgba(255, 255, 255, .2)), color-stop(.5, transparent), to(transparent));
background-image: -webkit-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
-moz-background-size: 72px 72px;
background-image: -moz-linear-gradient(rgba(255, 255, 255, .2) 50%, transparent 50%, transparent);
}
i.icon {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-image: url('/assets/tracker-logo.png');
background-position: center center;
background-repeat: no-repeat;
}
h1.title {
text-transform: capitalize;
color: $title-color;
}
.updated-at {
color: $updated-at-color;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment