Sha256: 16a750ba85f0c0f917d1da19be63e4eb1dac7931e4698ea837f4b35a12d3c537
Contents?: true
Size: 891 Bytes
Versions: 2
Compression:
Stored size: 891 Bytes
Contents
module Slurper class Engine < Struct.new(:story_file) def stories @stories ||= YAML.load(yamlize_story_file).map { |attrs| Slurper::Story.new(attrs) } end def process puts "Validating story content" stories.each(&:valid?) puts "Preparing to slurp #{stories.size} stories into Tracker..." stories.each_with_index do |story, index| if story.save puts "#{index+1}. #{story.name}" else puts "Slurp failed. #{story.error_message}" end end end protected def yamlize_story_file IO.read(story_file) .then {|x| x.strip} .then {|x| x.gsub(/^ \b/, " ") } .then {|x| x.gsub(/^/, " ") } .then {|x| x.gsub(/ $/, "") } .then {|x| x.gsub(/ ==.*/, "-") } .then {|x| x.gsub(/ description:$/, " description: |") } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
slurper-2.2.0 | lib/slurper/engine.rb |
slurper-2.1.0 | lib/slurper/engine.rb |