Sha256: c4aa5708613c0de71cc071bc7544d11be79aa2d0fd80fec0667da4622ae069fb

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'castronaut'))
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../vendor/sinatra/lib')
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../vendor/rack/lib')

require 'rack'
require 'sinatra'
require 'optparse'

options = {}
OptionParser.new do |opts|
  opts.banner = "Usage: castronaut -C /path/to/config/file"

  opts.on("-C", "--config", "Config File") do |c|
    options[:config_file] = ARGV[0]
  end
end.parse!

if options[:config_file]
  Castronaut.config = Castronaut::Configuration.load(options[:config_file])
else
  default_config = File.expand_path("./castronaut.yml")
  
  if File.exist?(default_config)
    Castronaut.config = Castronaut::Configuration.load(default_config)
  else
    puts "Unable to locate configuration.  Currently looking at #{default_config}.  You can pass a custom configuration path by using the -C flag."
    exit(0)
  end
end

Sinatra::Application.default_options.merge!(
  :env => Castronaut.config.environment.to_sym,
  :run => true,
  :raise_errors => true,
  :logging => true
)

Castronaut.logger.debug("Sinatra - Loading app/config.rb")
load File.expand_path(File.join(File.dirname(__FILE__), '..', 'app', 'config.rb'))

Castronaut.logger.debug("Sinatra - Loading app/application.rb")
load File.expand_path(File.join(File.dirname(__FILE__), '..', 'app', 'controllers', 'application.rb'))

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
relevance-castronaut-0.2.0 bin/castronaut
relevance-castronaut-0.2.5 bin/castronaut