Sha256: 0f0f4591d5610926efef21a7ba0de3d96a21e486dc9a0bad2542e93e85d0a075
Contents?: true
Size: 1.79 KB
Versions: 3
Compression:
Stored size: 1.79 KB
Contents
require 'turnip_formatter/step_template/exception' require 'gnawrnip/developer' module Gnawrnip class StepScreenshot < TurnipFormatter::StepTemplate::Exception on_failed :build def self.css File.read(File.dirname(__FILE__) + '/gnawrnip.css') end def build(example) images = example.metadata[:gnawrnip][:screenshot] case images.length when 0 '' when 1 single_image(images.first) else animation_image(images) end end private def animation_image(paths) text = <<-EOS <div class="screenshot animation"> <div class="nav"> <div class="pager"></div> <div class="manipulate"> <i class="fa fa-2x fa-step-backward prev"></i> <i class="fa fa-2x fa-play play"></i> <i class="fa fa-2x fa-pause pause"></i> <i class="fa fa-2x fa-step-forward next"></i> </div> </div> <div class="slides"> EOS text += develop(paths) text + <<-EOS </div> </div> EOS end def single_image(file) text = '<div class="screenshot">' text += develop([file]) text + '</div>' end def develop(files) files.map do |file| image = developer.develop(file.path) image.to_html end.join end def developer @developer ||= Developer.new end end end TurnipFormatter.configure do |c| c.add_javascript('https://cdnjs.cloudflare.com/ajax/libs/jquery.cycle2/20130801/jquery.cycle2.min.js') c.add_stylesheet('https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css') c.add_javascript(File.dirname(__FILE__) + '/gnawrnip.js') end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gnawrnip-0.5.0 | lib/gnawrnip/step_screenshot.rb |
gnawrnip-0.4.0 | lib/gnawrnip/step_screenshot.rb |
gnawrnip-0.3.2 | lib/gnawrnip/step_screenshot.rb |