class PivotalIntegration::Command::New

The class that encapsulates starting a Pivotal Tracker Story

Constants

STORY_TYPES

Public Class Methods

collect_type_and_name(arguments) click to toggle source
# File lib/pivotal-integration/command/new.rb, line 34
def collect_type_and_name(arguments)
  type = STORY_TYPES.include?(arguments.first.try(:downcase)) ? arguments.shift : choose_type
  type = type.downcase.to_sym

  name = arguments.shift || ask('Provide a name for the new story: ')

  [name, type]
end

Private Class Methods

choose_type() click to toggle source
# File lib/pivotal-integration/command/new.rb, line 45
def choose_type
  choose do |menu|
    menu.prompt = 'What type of story do you want to create: '
    STORY_TYPES.each { |type| menu.choice(type.titleize) }
  end
end

Public Instance Methods

run(*arguments) click to toggle source
# File lib/pivotal-integration/command/new.rb, line 24
def run(*arguments)
  options = self.class.collect_type_and_name(arguments)

  puts
  print 'Creating new story on Pivotal Tracker... '
  PivotalIntegration::Util::Story.new(@configuration.project, *options)
  puts 'OK'
end