Sha256: 9ed1f8777cbfacc7d9706f1056fb6d4a8e03922758bd6cc63c036d64c24bfe5e

Contents?: true

Size: 1.68 KB

Versions: 3

Compression:

Stored size: 1.68 KB

Contents

#!/usr/bin/env ruby

require 'thor'
require 'builder'

module CukePack
  class CLI < Thor
    include Thor::Actions

    def self.source_root
      File.expand_path('../../skel', __FILE__)
    end

    desc "install", "Install CukePack into the current directory"
    def install
      directory '.', '.'
    end

    desc "wip-guard", "Add the WIP guard to your Guardfile"
    def wip_guard
      FileUtils.touch 'Guardfile'

      append_file 'Guardfile', <<-RB
# added by cuke-pack

group :wip do
  guard 'cucumber', :env => :cucumber, :cli => '-p wip' do
    watch(%r{^features/.+\.feature$})
    watch(%r{^(app|lib).*})          { 'features' }
    watch(%r{^features/support/.+$})          { 'features' }
    watch(%r{^features/step_definitions/(.+)\.rb$}) { 'features' }
  end
end
      RB
    end

    desc "screenshots DIR", "Start a screenshot server"
    method_options %w{port -p} => 4432
    def screenshots(dir = "features/screenshots")
      require 'rack'

      Rack::Handler.default.run(ScreenshotsApp.new(dir), :Port => options[:port])
    end

    default_task :install
  end
end

class ScreenshotsApp
  def initialize(dir)
    @dir = dir
  end

  def call(env)
    by_file = {}

    Dir[@dir + '/**/*.png'].each do |file|
      file = file.gsub(%r{^#{@dir}/}, '')

      parts = file.split('/')

      browser = parts.shift

      name = parts.join('/')

      by_file[name] ||= []
      by_file[name] << browser
    end

    output = Builder::XmlMarkup.new

    output.html {
      output.head {
        output.title("Screenshots")
      }

      output.body {
        by_file.each do |name, browsers|

        end
      }
    }

    [ 200, {}, [ output.to_s ] ]
  end
end

CukePack::CLI.start

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cuke-pack-0.0.3 bin/cuke-pack
cuke-pack-0.0.2 bin/cuke-pack
cuke-pack-0.0.1 bin/cuke-pack