Sha256: 877a6947af0ad410ef32a99c2b32f9db50c068b6e1b90a90093a654ba5b1e4ee

Contents?: true

Size: 1.5 KB

Versions: 11

Compression:

Stored size: 1.5 KB

Contents

require 'sauce/config'

# This generator bootstraps a Rails project for use with Sauce OnDemand
class SauceGenerator < Rails::Generator::Base
  def initialize(runtime_args, runtime_options = {})
    config = Sauce::Config.new
    if config.username.nil? || config.access_key.nil?
      if runtime_args.size != 2
        raise "Usage: #{$0} sauce <USERNAME> <ACCESS_KEY>"
      else
        system("sauce config #{runtime_args[0]} #{runtime_args[1]}")
      end
    end
    super
  end

  def manifest
    record do |m|
      if File.directory? 'spec'
        m.directory File.join('spec', 'selenium') if File.directory? 'spec'
        m.setup_helper(File.join('spec', 'spec_helper.rb')) if File.directory? 'spec'
      end

      m.directory File.join('lib', 'tasks')
      m.directory File.join('test', 'selenium') if File.directory? 'test'
      m.file      'sauce.rake', File.join('lib', 'tasks', 'sauce.rake')
      m.setup_helper(File.join('test', 'test_helper.rb')) if File.directory? 'test'
    end
  end

  def setup_helper(file)
    contents = File.read(file)
    if contents !~ /Sauce.config/
      File.open(file, "a") do |file|
        file.write <<-CONFIG

require 'sauce'

Sauce.config do |conf|
    conf.browser_url = "http://#{rand(100000)}.test/"
    conf.browsers = [
        ["Windows 2003", "firefox", "3."]
    ]
    conf.application_host = "127.0.0.1"
    conf.application_port = "3001"
end
        CONFIG
      end
    end
  end

protected

  def banner
    "Usage: #{$0} sauce [<USERNAME> <ACCESS_KEY>]"
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sauce-0.15.0.alpha.1 generators/sauce/sauce_generator.rb
sauce-0.14.2 generators/sauce/sauce_generator.rb
sauce-0.14.1 generators/sauce/sauce_generator.rb
sauce-0.14.0 generators/sauce/sauce_generator.rb
sauce-0.13.2 generators/sauce/sauce_generator.rb
sauce-0.13.1 generators/sauce/sauce_generator.rb
sauce-0.13.0 generators/sauce/sauce_generator.rb
sauce-0.12.10 generators/sauce/sauce_generator.rb
sauce-0.12.9 generators/sauce/sauce_generator.rb
sauce-0.12.8 generators/sauce/sauce_generator.rb
sauce-0.12.7 generators/sauce/sauce_generator.rb