Class: See::Plugins::Pivotal

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

Instance Method Summary collapse

Methods inherited from Plugin

#access_token

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
# File 'lib/see/plugins/pivotal.rb', line 14

def run(config, plugin_config)
  lines = []
  @token = access_token('PIVOTAL_TRACKER_ACCESS_TOKEN')

  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
    lines << "  Stories being worked on:".light_blue
    lines << stories
  else
    lines << "  No stories being worked on".yellow
  end


  if next_unowned_story
    lines << "  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
    lines << "    - #{id} #{name} #{time}"
  else
    lines << "No stories ready to work on".yellow
  end
  lines
end