Class: Flux::CLI::PT

Inherits:
Thor
  • Object
show all
Extended by:
Forwardable
Includes:
Util
Defined in:
lib/flux/cli/pivotal_tracker.rb

Constant Summary collapse

STORY_LIST_HEADERS =
%w(>ID STATE ASSIGNEE >EST STORY)

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#puts_table

Class Method Details

.loginObject



18
19
20
# File 'lib/flux/cli/pivotal_tracker.rb', line 18

def 
  ::PivotalTracker::Client.token = Flux::PT.config['token']
end

.story_update(name, attrs = nil, &get_attrs) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/flux/cli/pivotal_tracker.rb', line 22

def story_update(name, attrs = nil, &get_attrs)
  desc "#{name} STORY_ID", "#{name} a story"
  method_option :estimate, :type => :numeric, :aliases => '-e'
  define_method name do |story_id|
    a = attrs || instance_eval(&get_attrs)

    a[:estimate] = options[:estimate] if options[:estimate]

    story(story_id).update a
  end
end

Instance Method Details

#listObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/flux/cli/pivotal_tracker.rb', line 45

def list
  stories = begin
              if %w(none n).include?(options[:owner])
                current_project.stories.unassigned
              elsif %w(all a).include?(options[:owner])
                current_project.stories.scheduled
              else
                m = if options[:owner] == 'me'
                      current_project.members.me
                    else
                      current_project.members.find { |e|
                        e.name == options[:member]
                      }
                    end

                current_project.stories.owned_by(m)
              end
            end

  stories.reject! { |s| s.state == 'accepted' }

  table   =
    [STORY_LIST_HEADERS] +
    stories.map { |s|
      [s.id, s.state, s.owned_by, s.est, s.name]
    }

  puts_table table
end