Class: PivotalTrackerCli::Client

Inherits:
Thor
  • Object
show all
Defined in:
lib/pivotal_tracker_cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, local_options, config) ⇒ Client

Returns a new instance of Client.



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/pivotal_tracker_cli.rb', line 18

def initialize(args, local_options, config)
  @config = YAML.load_file(ENV['HOME'] + '/.pt')

  @api_token = @config['api_token']
  @project_id = @config['project_id']
  @usernames = @config['usernames']

  @story_statuses = {
      'unstart' => 'unstarted',
      'start' => 'started',
      'deliver' => 'delivered',
      'finish' => %w(finished accepted)
  }

  @username_to_user_id_map = build_or_assign_user_cache(@config)
  super
end

Instance Attribute Details

#username_to_user_id_mapObject (readonly)

Returns the value of attribute username_to_user_id_map.



16
17
18
# File 'lib/pivotal_tracker_cli.rb', line 16

def username_to_user_id_map
  @username_to_user_id_map
end

Instance Method Details

#backlogObject



60
61
62
63
64
# File 'lib/pivotal_tracker_cli.rb', line 60

def backlog
  get_backlog(3).map do |story|
    output.puts("* #{story.id.to_s.red} - #{colorize_status(story.current_state)} - #{embiggen_string(story.name)} <#{get_owner_name_from_ids(story.owner_ids)}>")
  end
end

#listObject



38
39
40
41
42
43
44
# File 'lib/pivotal_tracker_cli.rb', line 38

def list
  get_current_stories_for_user.map do |story|
    output.puts('*' * 40)
    format_story(story)
  end
  output.puts('*' * 40)
end

#refreshObject



68
69
70
# File 'lib/pivotal_tracker_cli.rb', line 68

def refresh
  rebuild_user_cache(@config)
end

#show(id) ⇒ Object



48
49
50
# File 'lib/pivotal_tracker_cli.rb', line 48

def show(id)
  format_story(get_story(id))
end

#update(id, status) ⇒ Object



54
55
56
# File 'lib/pivotal_tracker_cli.rb', line 54

def update(id, status)
  validate_and_update_story(id, status)
end