File: rails_runner

package info (click to toggle)
jruby 9.4.14.0%2Bds-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 89,708 kB
  • sloc: ruby: 553,384; java: 277,371; yacc: 25,867; ansic: 6,322; xml: 6,111; sh: 2,121; sed: 94; makefile: 76; jsp: 48; tcl: 40; exp: 12
file content (46 lines) | stat: -rwxr-xr-x 1,426 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env jruby
require 'rubygems'
require 'fileutils'
require 'optparse'

ENV['RAILS_ENV'] = "development"
# FIXME: -rlogger is because logger is getting loaded in CRuby but not
# for us.  
ENV['JRUBY_OPTS'] = "--dev -rlogger"

#launcher, options, rails_version = "jruby", "", "6.1.3.2"
launcher, options, rails_version = "jruby", "", "7.0.8.7"
OptionParser.new do |opt|
  opt.banner = "Usage: runner [OPTIONS]"
  opt.separator  ""
  opt.separator  "Options"
  opt.on('-r', '--ruby ruby', 'which ruby you want to run') { |v| launcher = v }
  opt.on('-o', '--options opts', 'options for ruby command') { |v| options = v }
  opt.on('-v', '--version version', 'rails version to run') { |v| rails_version = v }
end.parse!

full_path = File.expand_path launcher
launcher = full_path if File.exist? full_path

$jruby = "#{launcher} #{options} "

def jruby_command(command, *args)
  command = "#{$jruby} -rlogger -S #{command} #{args.join(' ')}"
  puts "$ #{command}"
  value = system command
  puts value
end

rails_app = 'frogger'

FileUtils.rm_rf rails_app
jruby_command("gem", "install rails --version=#{rails_version}")
jruby_command("rails", "new", rails_app)
Dir.chdir(rails_app) do
  jruby_command("bundle", "update")
  jruby_command("rails", "generate scaffold person name:string")
  jruby_command("rake", "db:migrate")
#  jruby_command("rails", "webpacker:install")
  jruby_command("rails", "server")
end
puts "Done"