#!/usr/bin/env ruby if Object.const_defined?("Bundler") puts "detected bundler environment from a different app!" puts "trying to shell out of bundler's environment..." ENV["RUBYOPT"] = ENV["RUBYOPT"].gsub("-rbundler/setup", "") Kernel.exec(__FILE__) end require File.expand_path("../../bundler_version", __FILE__) require "rubygems" gem "bundler", SCREW_SERVER_BUNDLER_VERSION require "bundler" ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile.run", __FILE__) Bundler.require require 'yaml' options = { :port => 3210, :spec_base_dir => "spec/javascripts", :code_base_dir => "public" } begin YAML.load_file('.screw_server.yml').each do |key, value| options[key.to_sym] = value end rescue Errno::ENOENT end OptionParser.new do |opt| opt.on('--port -p ', Integer, 'port to start screw_server on (default is 3210)') do |port| options[:port] = port end opt.on( "--spec spec_base_dir", "directory that contains the javascript specs (default is ./#{options[:spec_base_dir]})" ) do |spec_base_dir| options[:spec_base_dir] = spec_base_dir end opt.on( '--code code_base_dir', "directory that contains the javascript code (default is ./#{options[:code_base_dir]})" ) do |code_base_dir| options[:code_base_dir] = code_base_dir end end.parse! puts "Starting Screw Server on port #{options[:port]} " + "with spec_base_dir '#{options[:spec_base_dir]}' and code_base_dir '#{options[:code_base_dir]}'" ScrewServer::Base.spec_base_dir = File.expand_path(options[:spec_base_dir]) ScrewServer::Base.code_base_dir = File.expand_path(options[:code_base_dir]) ScrewServer::App.run!(:host => 'localhost', :port => options[:port], :environment => "production")