Created
September 1, 2016 16:05
-
-
Save enebo/aaf72a926358165b360a5e6221b31522 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env jruby | |
require 'rubygems' | |
require 'fileutils' | |
require 'optparse' | |
ENV['RAILS_ENV'] = "development" | |
launcher, options = "jruby", "" | |
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 } | |
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} -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=4.2.7") | |
jruby_command("rails", "new", rails_app) | |
Dir.chdir(rails_app) do | |
jruby_command("bundle", "install") | |
jruby_command("rails", "generate scaffold person name:string") | |
jruby_command("rake", "db:migrate") | |
jruby_command("rails", "server") | |
end | |
puts "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment