Created
September 12, 2013 13:46
-
-
Save tadas-s/6537653 to your computer and use it in GitHub Desktop.
Running local ruby scripts on remote Heroku app instance
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 ruby | |
# | |
# Usage: | |
# irbify.rb script.rb | heroku run rails console --app=my-app | |
# | |
# Why eval and not piping directly? Piping directly would run all lines even if previous line was an invalid statement. | |
# | |
script_name = ARGV[0] | |
script = File.open(script_name, 'r').read | |
if File.readable? script_name | |
puts 'eval ' + script.dump + '; exit' | |
exit 0 | |
else | |
puts "Cannot read/open '#{ARGV[0]}'" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment