Skip to content

Instantly share code, notes, and snippets.

@a-suenami
Created July 2, 2019 13:09
Show Gist options
  • Save a-suenami/d835db18976126249a384b9639c3099d to your computer and use it in GitHub Desktop.
Save a-suenami/d835db18976126249a384b9639c3099d to your computer and use it in GitHub Desktop.
Execute local ruby script on Heroku.
#!/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