Module: Gith::Estimate

Includes:
Pivotal
Included in:
Commands
Defined in:
lib/gith/commands/estimate.rb

Constant Summary

Constants included from Pivotal

Pivotal::ACCEPTED, Pivotal::DELIVERED, Pivotal::FINISHED, Pivotal::REJECTED, Pivotal::STARTED, Pivotal::V5_URL

Instance Method Summary collapse

Methods included from Pivotal

#accept_story, #compress_comments, #delete_comment, #deliver_story, #finish_story, #hubot_commit_comments, #me, #project, #project_from_story, #projects, #start_story, #story, #take_ownership

Instance Method Details

#estimate(id, points = nil) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/gith/commands/estimate.rb', line 8

def estimate(id, points=nil)
  error "Please include estimate" if points.nil?
  @story    = story(id)
  @project  = project_from_story(id)

  error "Invalid estimate. Please use #{@project.point_scale}" unless @project.point_scale.split(',').include?(points)

  update_estimate = true

  if @story.estimate.to_i == points.to_i
    success "Story already estimated at #{points}"
    return true
  end

  unless yes_or_no("Story already estimated at #{@story.estimate} points. Change estimate to #{points}?")
    update_estimate = false
    success "Leaving estimate at #{@story.estimate}"
    return true
  end if @story.story_type == 'feature' && @story.estimate != -1

  if update_estimate
    @story.update estimate: points
    success "Story estimated at #{points} points"
    return true
  end

  false
end