Skip to content

Instantly share code, notes, and snippets.

@tadas-s
Created September 12, 2013 13:46
Show Gist options
  • Save tadas-s/6537653 to your computer and use it in GitHub Desktop.
Save tadas-s/6537653 to your computer and use it in GitHub Desktop.
Running local ruby scripts on remote Heroku app instance
#!/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