Skip to content

Instantly share code, notes, and snippets.

@rtcoms
Forked from ohammersmith/gist:48788
Created August 31, 2022 11:04
Show Gist options
  • Save rtcoms/e3716ad7197e900146a4068149e9eee8 to your computer and use it in GitHub Desktop.
Save rtcoms/e3716ad7197e900146a4068149e9eee8 to your computer and use it in GitHub Desktop.
Ruby script in a Windows batch script
@echo off
goto endofruby
#!/bin/ruby
git_repo = "git://github.com/rails/rails.git"
help = %Q{
Rails Info:
-v, --version Show the Rails version number and quit.
-h, --help Show this help message and quit.
General Options:
-p, --pretend Run but do not make any changes.
--force Overwrite files that already exist.
-s, --skip Skip files that already exist.
-q, --quiet Suppress normal output.
-t, --backtrace Debugging: show backtrace on errors.
Description:
The 'edge_rails' command creates a new Rails application with a default
directory structure and configuration at the path you specify, using the
very latest version of Rails.
Example:
edge_rails ~/Code/Ruby/weblog
This generates a skeletal Rails installation in ~/Code/Ruby/weblog.
See the README in the newly created application to get going.
}
require 'fileutils'
if ARGV.empty?
puts help
exit
end
dir = ARGV.shift
args = ARGV.join (" ")
FileUtils::mkdir(dir)
FileUtils::mkdir("#{dir}/vendor")
puts "Exporting EdgeRails from #{git_repo}"
# system "svn export http://svn.rubyonrails.org/rails/trunk #{dir}/vendor/rails"
system "git clone --depth=1 #{git_repo} #{dir}/vendor/rails"
system "rm -rf #{dir}/vendor/rails/.git*"
system "ruby #{dir}/vendor/rails/railties/bin/rails #{dir} #{args}"
__END__
:endofruby
"%~d0%~p0ruby" -x "%~f0" %*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment