Class: Slurper
- Inherits:
-
Object
- Object
- Slurper
- Defined in:
- lib/slurper.rb
Instance Attribute Summary collapse
-
#stories ⇒ Object
Returns the value of attribute stories.
-
#story_file ⇒ Object
Returns the value of attribute story_file.
-
#story_query ⇒ Object
Returns the value of attribute story_query.
-
#update_epics ⇒ Object
Returns the value of attribute update_epics.
Class Method Summary collapse
Instance Method Summary collapse
- #create_stories ⇒ Object
-
#initialize(story_file, options) ⇒ Slurper
constructor
A new instance of Slurper.
- #load_stories ⇒ Object
- #prepare_stories ⇒ Object
- #sort_stories(reverse) ⇒ Object
Constructor Details
#initialize(story_file, options) ⇒ Slurper
Returns a new instance of Slurper.
21 22 23 24 25 |
# File 'lib/slurper.rb', line 21 def initialize(story_file, ) self.story_file = story_file self.update_epics = [:update_epics] self.story_query = [:story_query] end |
Instance Attribute Details
#stories ⇒ Object
Returns the value of attribute stories.
9 10 11 |
# File 'lib/slurper.rb', line 9 def stories @stories end |
#story_file ⇒ Object
Returns the value of attribute story_file.
9 10 11 |
# File 'lib/slurper.rb', line 9 def story_file @story_file end |
#story_query ⇒ Object
Returns the value of attribute story_query.
9 10 11 |
# File 'lib/slurper.rb', line 9 def story_query @story_query end |
#update_epics ⇒ Object
Returns the value of attribute update_epics.
9 10 11 |
# File 'lib/slurper.rb', line 9 def update_epics @update_epics end |
Class Method Details
.slurp(story_file, options) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/slurper.rb', line 11 def self.slurp(story_file, ) slurper = new(story_file, ) slurper.load_stories slurper.prepare_stories slurper.sort_stories([:reverse]) slurper.create_stories end |
Instance Method Details
#create_stories ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/slurper.rb', line 44 def create_stories puts "Preparing to slurp #{stories.size} stories into Tracker..." stories.each_with_index do |story, index| begin if story.save puts "#{index+1}. #{story.name}" else puts "Slurp failed. #{story.errors.}" end rescue ActiveResource::ConnectionError => e msg = "Slurp failed on story " if story.attributes["name"] msg << story.attributes["name"] else msg << "##{[:reverse] ? index + 1 : stories.size - index }" end puts msg + ". Error: #{e}" end end end |
#load_stories ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/slurper.rb', line 27 def load_stories if update_epics self.stories = Story.find_unlinked_epics(story_query) else self.stories = YAML.load(yamlize_story_file) end end |
#prepare_stories ⇒ Object
35 36 37 |
# File 'lib/slurper.rb', line 35 def prepare_stories stories.each { |story| story.prepare } end |
#sort_stories(reverse) ⇒ Object
39 40 41 42 |
# File 'lib/slurper.rb', line 39 def sort_stories(reverse) stories.sort! stories.reverse! unless reverse end |