class Gnawrnip::StepScreenshot

Public Class Methods

css() click to toggle source
# File lib/gnawrnip/step_screenshot.rb, line 8
def self.css
  File.read(File.dirname(__FILE__) + '/gnawrnip.css')
end

Public Instance Methods

build(step) click to toggle source

@param [TurnipFormatter::Resource::Step::Failure] step

# File lib/gnawrnip/step_screenshot.rb, line 15
def build(step)
  images = step.example.metadata[:gnawrnip][:screenshot]

  case images.length
  when 0
    ''
  when 1
    single_image(images.first)
  else
    animation_image(images)
  end
end

Private Instance Methods

animation_image(paths) click to toggle source
# File lib/gnawrnip/step_screenshot.rb, line 30
    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
develop(files) click to toggle source
# File lib/gnawrnip/step_screenshot.rb, line 57
def develop(files)
  files.map do |file|
    image = developer.develop(file.path)
    image.to_html
  end.join
end
developer() click to toggle source
# File lib/gnawrnip/step_screenshot.rb, line 64
def developer
  @developer ||= Developer.new
end
single_image(file) click to toggle source
# File lib/gnawrnip/step_screenshot.rb, line 51
def single_image(file)
  text = '<div class="screenshot">'
  text += develop([file])
  text + '</div>'
end