aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/commands/runner/runner_command.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2017-07-17 14:53:36 -0500
committerGitHub <noreply@github.com>2017-07-17 14:53:36 -0500
commitbfea6f292b19f34216b643b6193be0a9867fc2cc (patch)
tree652eb7df106e28b88f1e42863890ca085c5ed417 /railties/lib/rails/commands/runner/runner_command.rb
parentc24be369322b9e0211fcef30003375de195ef660 (diff)
parented44b145bd6d621cd19a4a3c94eff1311e9c3755 (diff)
downloadrails-bfea6f292b19f34216b643b6193be0a9867fc2cc.tar.gz
rails-bfea6f292b19f34216b643b6193be0a9867fc2cc.tar.bz2
rails-bfea6f292b19f34216b643b6193be0a9867fc2cc.zip
Merge pull request #26343 from ccutrer/runner_from_stdin
support `-` as an argument to `rails runner`
Diffstat (limited to 'railties/lib/rails/commands/runner/runner_command.rb')
-rw-r--r--railties/lib/rails/commands/runner/runner_command.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/railties/lib/rails/commands/runner/runner_command.rb b/railties/lib/rails/commands/runner/runner_command.rb
index 6864a9726b..c931fc2152 100644
--- a/railties/lib/rails/commands/runner/runner_command.rb
+++ b/railties/lib/rails/commands/runner/runner_command.rb
@@ -13,7 +13,7 @@ module Rails
end
def self.banner(*)
- "#{super} [<'Some.ruby(code)'> | <filename.rb>]"
+ "#{super} [<'Some.ruby(code)'> | <filename.rb> | -]"
end
def perform(code_or_file = nil, *command_argv)
@@ -29,7 +29,9 @@ module Rails
ARGV.replace(command_argv)
- if File.exist?(code_or_file)
+ if code_or_file == "-"
+ eval($stdin.read, binding, "stdin")
+ elsif File.exist?(code_or_file)
$0 = code_or_file
Kernel.load code_or_file
else