Class: Commands::Pick

Inherits:
Base
  • Object
show all
Defined in:
lib/commands/pick.rb

Direct Known Subclasses

Bug, Chore, Feature

Instance Attribute Summary

Attributes inherited from Base

#input, #options, #output

Instance Method Summary collapse

Methods inherited from Base

#get, #initialize, #put, #sys

Constructor Details

This class inherits a constructor from Commands::Base

Instance Method Details

#branch_suffixObject



14
15
16
# File 'lib/commands/pick.rb', line 14

def branch_suffix
  raise Error "must define in subclass"
end

#plural_typeObject



10
11
12
# File 'lib/commands/pick.rb', line 10

def plural_type
  raise Error "must define in subclass"
end

#run!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/commands/pick.rb', line 18

def run!
  super

  put "Retrieving latest #{plural_type} from Pivotal Tracker..."

  unless story
    put "No #{plural_type} available!"
    return 0
  end

  put "Story: #{story.name}"
  put "URL:   #{story.url}"

  put "Updating #{type} status in Pivotal Tracker..."
  if story.start!(:owned_by => options[:full_name])

    suffix = branch_suffix
    unless options[:quiet]
      put "Enter branch name (will be prepended by #{story.id}) [#{suffix}]: ", false
      suffix = input.gets.chomp
  
      suffix = "feature" if suffix == ""
    end

    branch = "#{story.id}-#{suffix}"
    if get("git branch").match(branch).nil?
      put "Creating #{branch} branch..."
      sys "git checkout -b #{branch}"
    end

    return 0
  else
    put "Unable to mark #{type} as started"
    
    return 1
  end
end

#typeObject



6
7
8
# File 'lib/commands/pick.rb', line 6

def type
  raise Error "must define in subclass"
end