class PivotalIntegration::Command::Base

An abstract base class for all commands @abstract Subclass and override {#run} to implement command functionality

Attributes

description[R]

Public Class Methods

desc(text) click to toggle source
# File lib/pivotal-integration/command/base.rb, line 59
def desc(text)
  @description = text
end
new(options = {}) click to toggle source

Common initialization functionality for all command classes. This enforces that:

  • the command is being run within a valid Git repository

  • the user has specified their Pivotal Tracker API token

  • all communication with Pivotal Tracker will be protected with SSL

  • the user has configured the project id for this repository

# File lib/pivotal-integration/command/base.rb, line 31
def initialize(options = {})
  @options = options
  @repository_root = PivotalIntegration::Util::Git.repository_root
  @configuration = PivotalIntegration::Command::Configuration.new

  PivotalTracker::Client.token = @configuration.api_token
  PivotalTracker::Client.use_ssl = true

  @project = PivotalTracker::Project.find @configuration.project_id
end

Public Instance Methods

run(*arguments) click to toggle source

The main entry point to the command’s execution @abstract Override this method to implement command functionality

# File lib/pivotal-integration/command/base.rb, line 44
def run(*arguments)
  raise NotImplementedError
end
story() click to toggle source
# File lib/pivotal-integration/command/base.rb, line 48
def story
  if @options[:story_id]
    @configuration.project.stories.find(@options[:story_id])
  else
    @configuration.story
  end
end