Sha256: c66f84bda05c944c40982d500cc2b73d2b7aa02f97849c3d26dc18e623693c3b

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

#!/usr/bin/env jruby

# == Synopsis
#
# jetty_rails: jetty server for rails applications
#
# == Usage
#
# jetty_rails [OPTION] ... BASEDIR
#
# -h, --help::
#    show help
#
# --context-path PATH, -u PATH::
#    change the application context path (default: '/')
#
# --port PORT, -p PORT::
#    change server port (default: 3000)
#
# --environment ENV, -e ENV::
#    change rails environment (default: development)
#
# BASEDIR (optional): directory to be run (default: current).

require "java"
require "jetty_rails"
require 'rdoc/usage'
require 'getoptlong'

# fix to work with rubygems (use current file instead of main)
def RDoc.usage_no_exit(*args)
  comment = File.open(__FILE__) do |file|
    find_comment(file)
  end

  comment = comment.gsub(/^\s*#/, '')

  markup = SM::SimpleMarkup.new
  flow_convertor = SM::ToFlow.new

  flow = markup.convert(comment, flow_convertor)

  format = "plain"

  unless args.empty?
    flow = extract_sections(flow, args)
  end

  options = RI::Options.instance
  if args = ENV["RI"]
    options.parse(args.split)
  end
  formatter = options.formatter.new(options, "")
  formatter.display_flow(flow)
end

opts = GetoptLong.new(
    [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
    [ '--context-path', '-u', GetoptLong::REQUIRED_ARGUMENT ],
    [ '--port', '-p', GetoptLong::REQUIRED_ARGUMENT ],
    [ '--environment', '-e', GetoptLong::REQUIRED_ARGUMENT ]
  )

config = {
  :base => Dir.pwd,
  :port => 3000,
  :adapter => :rails
}

opts.each do |opt, arg|
  case opt
    when '--help'
      RDoc::usage
    when '--context-path'
      config[:context_path] = arg
    when '--port'
      config[:port] = arg.to_i
    when '--environment'
      config[:environment] = arg
  end
end

config[:base] = ARGV.shift unless ARGV.empty?

runner = JettyRails::Runner.new(config)
runner.start

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jetty-rails-0.4 bin/jetty_rails