Class: GitPivotalTrackerIntegration::Util::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/git-pivotal-tracker-integration/util/story.rb

Overview

Utilities for dealing with PivotalTracker::Storys

Class Method Summary collapse

Class Method Details

.pretty_print(story) ⇒ void

This method returns an undefined value.

Print a human readable version of a story. This pretty prints the title, description, and notes for the story.

Parameters:

  • story (PivotalTracker::Story)

    the story to pretty print



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/git-pivotal-tracker-integration/util/story.rb', line 28

def self.pretty_print(story)
  print_label LABEL_TITLE
  print_value story.name

  description = story.description
  if !description.nil? && !description.empty?
    print_label 'Description'
    print_value description
  end

  PivotalTracker::Note.all(story).sort_by { |note| note.noted_at }.each_with_index do |note, index|
    print_label "Note #{index + 1}"
    print_value note.text
  end

  puts
end

.select_story(project, filter = nil, limit = 5) ⇒ PivotalTracker::Story

Selects a Pivotal Tracker story by doing the following steps:

Parameters:

  • project (PivotalTracker::Project)

    the project to select stories from

  • filter (String, nil) (defaults to: nil)

    a filter for selecting the story to start. This filter can be either:

    • a story id: selects the story represented by the id

    • a story type (feature, bug, chore): offers the user a selection of stories of the given type

    • nil: offers the user a selection of stories of all types

  • limit (Fixnum) (defaults to: 5)

    The number maximum number of stories the user can choose from

Returns:

  • (PivotalTracker::Story)

    The Pivotal Tracker story selected by the user



56
57
58
59
60
61
62
63
64
# File 'lib/git-pivotal-tracker-integration/util/story.rb', line 56

def self.select_story(project, filter = nil, limit = 5)
  if filter =~ /[[:digit:]]/
    story = project.stories.find filter.to_i
  else
    story = find_story project, filter, limit
  end

  story
end