Class: See::Plugins::Pivotal

Inherits:
Object
  • Object
show all
Defined in:
lib/see/plugins/pivotal.rb

Instance Method Summary collapse

Instance Method Details

#config_nameObject



10
11
12
# File 'lib/see/plugins/pivotal.rb', line 10

def config_name
  "pivotal"
end

#display_nameObject



6
7
8
# File 'lib/see/plugins/pivotal.rb', line 6

def display_name
  'Pivotal Tracker'
end

#run(config, plugin_config) ⇒ Object



14
15
16
17
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
55
56
57
58
59
60
# File 'lib/see/plugins/pivotal.rb', line 14

def run(config, plugin_config)
  info = []
  token = ENV['PIVOTAL_TRACKER_ACCESS_TOKEN']
  unless token
    info << "  You must set PIVOTAL_TRACKER_ACCESS_TOKEN env variable".red
    return info
  end

  PivotalTracker::Client.token = token
  project = PivotalTracker::Project.find(plugin_config['project'])

  next_unowned_story = nil
  has_current = false

  stories = []
  project.stories.all.each do |story|
    next if story.accepted_at != nil
    if story.owned_by == nil and not next_unowned_story
      next_unowned_story = story
    elsif story.owned_by
      has_current = true
      owner = "[#{story.owned_by}]".cyan
      time = "- #{story.created_at.strftime("%b %e,%l:%M %p")}".black
      id = "#{story.id}".light_yellow
      stories << "    - #{story.name} #{owner} #{id} #{time}"
    end
  end

  if stories.length > 0
    info << "  Stories being worked on:".light_blue
    info << stories
  else
    info << "  No stories being worked on".yellow
  end


  if next_unowned_story
    info << "  Next story that can be worked on:".light_blue
    time = "- #{next_unowned_story.created_at.strftime("%b %e,%l:%M %p")}".black
    id = "#{next_unowned_story.id}".light_yellow
    name = next_unowned_story.name
    info << "    - #{id} #{name} #{time}"
  else
    info << "No stories ready to work on".yellow
  end
  info
end