Class: Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotcli/runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Runner

Returns a new instance of Runner.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/pivotcli/runner.rb', line 7

def initialize(options)
  config = config = YAML.load_file("#{ENV['HOME']}/.pivotcli.yml")

  @story = options[:create]
  @project_name = options[:project] || config['project']
  @owner = options[:owner] || config['owner']
  @state = options[:state]
  @token = options[:token] || config['token']
  @show_desc = options[:show_descriptions]
  @story_type = options[:story_type]
  @ssl = config['ssl']

  PivotalTracker::Client.token = @token
  PivotalTracker::Client.use_ssl = @ssl

  @projects = PivotalTracker::Project.all

  @projects.each do |project|
    if project.name.downcase.eql? @project_name.downcase
      @project_id = project.id
    end
  end

  @project = PivotalTracker::Project.find(@project_id)
end

Instance Method Details

#create_storyObject



33
34
35
36
37
38
39
40
41
# File 'lib/pivotcli/runner.rb', line 33

def create_story
  if @story.include? ":"
    labels, story = @story.split ":"

    @project.stories.create(:name => story.strip, :labels => labels.split(' '))
  else
    @project.stories.create(:name => @story)
  end
end

#get_storiesObject



43
44
45
46
47
48
# File 'lib/pivotcli/runner.rb', line 43

def get_stories
  @project.stories.all(:current_state => @state, :owned_by => @owner).each do |story|
    puts "#{story.id.to_s.red} | #{story.name.green}"
    puts "\t#{story.description.cyan}" unless (@show_desc.nil? or story.description.empty?)
  end
end