Sha256: 205ec0a9b8be35651169a43e63d8a85cb9b1d72a29be7444466aa33c55e54a30

Contents?: true

Size: 1.53 KB

Versions: 14

Compression:

Stored size: 1.53 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
        puts "No username or API key specified. Assuming you're using Heroku Sauce"
      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

14 entries across 14 versions & 1 rubygems

Version Path
sauce-0.17.6 generators/sauce/sauce_generator.rb
sauce-0.17.5 generators/sauce/sauce_generator.rb
sauce-0.17.4 generators/sauce/sauce_generator.rb
sauce-0.17.3 generators/sauce/sauce_generator.rb
sauce-0.17.3.alpha2 generators/sauce/sauce_generator.rb
sauce-0.17.3.alpha1 generators/sauce/sauce_generator.rb
sauce-0.17.2 generators/sauce/sauce_generator.rb
sauce-0.17.1 generators/sauce/sauce_generator.rb
sauce-0.17.0 generators/sauce/sauce_generator.rb
sauce-0.16.2 generators/sauce/sauce_generator.rb
sauce-0.16.1 generators/sauce/sauce_generator.rb
sauce-0.15.1 generators/sauce/sauce_generator.rb
sauce-0.15.0 generators/sauce/sauce_generator.rb
sauce-0.15.0.alpha.2 generators/sauce/sauce_generator.rb