Class: Slurper::Engine

Inherits:
Struct
  • Object
show all
Defined in:
lib/slurper/engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Engine

Returns a new instance of Engine.



6
7
8
9
10
11
# File 'lib/slurper/engine.rb', line 6

def initialize(*args)
  super(*args)
  @client = Slurper::Client.new
  @client.get_trello_write_token
  @client.create_list
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



4
5
6
# File 'lib/slurper/engine.rb', line 4

def client
  @client
end

#story_fileObject

Returns the value of attribute story_file

Returns:

  • (Object)

    the current value of story_file



2
3
4
# File 'lib/slurper/engine.rb', line 2

def story_file
  @story_file
end

Instance Method Details

#processObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/slurper/engine.rb', line 17

def process
  puts "Validating story content"
  stories.each(&:valid?)

  puts "Preparing to slurp #{stories.size} stories into Trello..."
  stories.each_with_index do |story, index|
    if client.create_card(story)
      puts "#{index+1}. #{story.name}"
    else
      puts "Slurp failed. #{story.error_message}"
    end
  end
end

#storiesObject



13
14
15
# File 'lib/slurper/engine.rb', line 13

def stories
  @stories ||= YAML.load(yamlize_story_file).map { |attrs| Slurper::Story.new(attrs) }
end