Class: AssistedWorkflow::Addons::Pivotal

Inherits:
Base
  • Object
show all
Defined in:
lib/assisted_workflow/addons/pivotal.rb

Instance Method Summary collapse

Methods inherited from Base

get_required_options, #name, required_options

Constructor Details

#initialize(output, options = {}) ⇒ Pivotal

Returns a new instance of Pivotal.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/assisted_workflow/addons/pivotal.rb', line 10

def initialize(output, options = {})
  super

  PivotalTracker::Client.token = options["token"]
  begin
    @project = PivotalTracker::Project.find(options["project_id"])
  rescue
    raise AssistedWorkflow::Error, "pivotal project #{options["project_id"]} not found."
  end
  @fullname = options["fullname"]
  @username = options["username"]
end

Instance Method Details

#find_story(story_id) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/assisted_workflow/addons/pivotal.rb', line 23

def find_story(story_id)
  if story_id.to_i > 0
    log "loading story ##{story_id}"
    story = @project.stories.find(story_id)
    story.other_id = @username || @fullname
    story.other_id = story.other_id.to_s.downcase.split.join
    story
  end
end

#finish_story(story, options = {}) ⇒ Object



38
39
40
41
42
43
# File 'lib/assisted_workflow/addons/pivotal.rb', line 38

def finish_story(story, options = {})
  log "finishing story ##{story.id}"
  if update_story! story, :current_state => finished_state(story)
    story.notes.create(:text => options[:note]) if options[:note]
  end
end

#pending_stories(options = {}) ⇒ Object



45
46
47
48
49
50
# File 'lib/assisted_workflow/addons/pivotal.rb', line 45

def pending_stories(options = {})
  log "loading pending stories"
  states = ["unstarted"]
  states << "started" if options[:include_started]
  @project.stories.all(:state => states, :owned_by => @fullname, :limit => 5)
end

#start_story(story, options = {}) ⇒ Object



33
34
35
36
# File 'lib/assisted_workflow/addons/pivotal.rb', line 33

def start_story(story, options = {})
  log "starting story ##{story.id}"
  update_story! story, options.merge(:current_state => "started")
end

#valid?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/assisted_workflow/addons/pivotal.rb', line 52

def valid?
  !@project.nil?
end