Sha256: 3c6eba82006b91e257cc526934c582177a65d8e42875ce0cf56e53fc51121485

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

#!/usr/bin/env jruby

# == Synopsis
#
# jetty_rails: jetty server for rails applications
#
# == Usage
#
# jetty_tails [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: 8080)
#
# --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
}

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.2 bin/jetty_rails