Class: PivotalIntegration::Command::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal-integration/command/base.rb

Overview

This class is abstract.

Subclass and override #run to implement command functionality

An abstract base class for all commands

Direct Known Subclasses

Assign, Comment, Estimate, Finish, Info, Label, Mark, New, Open, Release, Start, Switch

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

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



31
32
33
34
35
36
37
38
39
40
# 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

Class Attribute Details

.descriptionObject (readonly)

Returns the value of attribute description.



57
58
59
# File 'lib/pivotal-integration/command/base.rb', line 57

def description
  @description
end

Class Method Details

.desc(text) ⇒ Object



59
60
61
# File 'lib/pivotal-integration/command/base.rb', line 59

def desc(text)
  @description = text
end

Instance Method Details

#run(*arguments) ⇒ Object

This method is abstract.

Override this method to implement command functionality

The main entry point to the command’s execution

Raises:

  • (NotImplementedError)


44
45
46
# File 'lib/pivotal-integration/command/base.rb', line 44

def run(*arguments)
  raise NotImplementedError
end

#storyObject



48
49
50
51
52
53
54
# 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