#!/usr/bin/env ruby $:.push File.expand_path('../../lib', __FILE__) require 'rubygems' require 'optparse' require 'rest-assured/config' user_opts = {} OptionParser.new do |opts| opts.banner = "Usage: rest-assured [options]" opts.on('-a', '--adapter mysql|sqlite|postgresql') do |adapter| user_opts[:adapter] = adapter end opts.on('-d', '--database FILENAME', "Either path to database file (sqlite, defaults to ./rest-assured.db) or db name (defaults to rest_assured) or :memory: for in-memory sqlite") do |fname| user_opts[:database] = fname end opts.on('-u', '--dbuser DBUSER', "Db username (mysql, postgresql only)") do |user| user_opts[:user] = user end opts.on('--dbpass DBPASSWORD', 'Db password (mysql, postgresql only). Defaults to empty') do |password| user_opts[:dbpass] = password end opts.on('--dbhost DBHOST', 'Db host (mysql, postgresql only). Defaults to mysql default host (localhost)') do |dbhost| user_opts[:dbhost] = dbhost end opts.on('--dbport DBPORT', Integer, 'Db port (mysql, postgresql only). Defaults to adapters default port') do |dbport| user_opts[:dbport] = dbport end opts.on('--dbencoding DBENCODING', 'Db encoding (mysql, postgresql only). Defaults to adapters default encoding') do |dbencoding| user_opts[:dbencoding] = dbencoding end opts.on('--dbsocket DBSOCKET', 'Db socket (mysql only). Defaults to mysql default socket') do |dbsocket| user_opts[:dbsocket] = dbsocket end opts.on('-p', '--port PORT', Integer, "Server port. Defaults to 4578") do |port| user_opts[:port] = port end opts.on('-l', '--logfile FILENAME', "Path to logfile. Defaults to ./rest-assured.log") do |logfile| user_opts[:logfile] = logfile end opts.on('--ssl', "Whether or not to run on https. Defaults to false (http)") do user_opts[:ssl] = true end opts.on('-c', '--ssl_cert FILENAME', "Path to ssl_cert. Defaults to self signed certificate shipped with rest-assured") do |ssl_cert| user_opts[:ssl_cert] = ssl_cert end opts.on('-k', '--ssl_key FILENAME', "Path to ssl_key. Defaults to key shipped with rest-assured") do |ssl_key| user_opts[:ssl_key] = ssl_key end opts.on_tail("--help", "Show this message") do puts opts exit end end.parse! RestAssured::Config.build(user_opts) require 'rest-assured/application' RestAssured::Application.run!(:threaded => false, :server => 'thin') do |server| ssl_options = { :cert_chain_file => AppConfig.ssl_cert, :private_key_file => AppConfig.ssl_key, :verify_peer => false } server.ssl = AppConfig.ssl server.ssl_options = ssl_options end