Class: PivotalToTrello::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/pivotal_to_trello/core.rb

Overview

The core entry point of the gem, which handles the import process.

Instance Method Summary collapse

Constructor Details

#initialize(options = OpenStruct.new) ⇒ Core

Constructor



9
10
11
# File 'lib/pivotal_to_trello/core.rb', line 9

def initialize(options = OpenStruct.new)
  @options = options
end

Instance Method Details

#import!Object

Generates a film clip based on the given input audio file, and saves it to the given output path.



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
61
# File 'lib/pivotal_to_trello/core.rb', line 15

def import!
  prompt_for_details

  puts "\nBeginning import..."
  pivotal.stories(options.pivotal_project_id).each do |story|
    list_id = label = nil

    if story.current_state == 'accepted'
      list_id = options.accepted_list_id
    elsif story.current_state == 'rejected'
      list_id = options.rejected_list_id
    elsif story.current_state == 'finished'
      list_id = options.finished_list_id
    elsif story.current_state == 'delivered'
      list_id = options.delivered_list_id
    elsif story.current_state == 'started'
      list_id = options.current_list_id
    elsif story.current_state == 'unscheduled'
      list_id = options.icebox_list_id
    elsif story.current_state == 'unstarted' && story.story_type == 'feature'
      list_id = options.feature_list_id
    elsif story.current_state == 'unstarted' && story.story_type == 'chore'
      list_id = options.chore_list_id
    elsif story.current_state == 'unstarted' && story.story_type == 'bug'
      list_id = options.bug_list_id
    elsif story.current_state == 'unstarted' && story.story_type == 'release'
      list_id = options.release_list_id
    else
      puts "Ignoring story #{story.id} - type is '#{story.story_type}', state is '#{story.current_state}'"
    end

    if story.story_type == 'bug' && options.bug_label
      label = options.bug_label
    elsif story.story_type == 'feature' && options.feature_label
      label = options.feature_label
    elsif story.story_type == 'chore' && options.chore_label
      label = options.chore_label
    elsif story.story_type == 'release' && options.release_label
      label = options.release_label
    end

    if list_id
      card = trello.create_card(list_id, story)
      trello.add_label(card, label) unless label.nil?
    end
  end
end

#optionsObject

Returns the options struct.



64
65
66
# File 'lib/pivotal_to_trello/core.rb', line 64

def options
  @options
end