Skip to content

Commit

Permalink
+ ruby-parse: add ability to read fragment from stdin (#844)
Browse files Browse the repository at this point in the history
  • Loading branch information
jstanley0 committed Jan 27, 2022
1 parent 930f8c6 commit df46c5d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/parser/runner.rb
Expand Up @@ -166,6 +166,7 @@ def parse_options(options)
@option_parser.parse!(options)

# Slop has just removed recognized options from `options`.
@fragments << $stdin.read if options.delete('-')
options.each do |file_or_dir|
if File.directory?(file_or_dir)
Find.find(file_or_dir) do |path|
Expand Down
5 changes: 5 additions & 0 deletions test/test_runner_parse.rb
Expand Up @@ -53,4 +53,9 @@ def test_emit_json_empty
assert_prints ['--emit-json', '-e', ''],
"\n"
end

def test_stdin_input
assert_prints ['--emit-ruby', '-', { stdin_data: '123' }],
's(:int, 123)'
end
end

0 comments on commit df46c5d

Please sign in to comment.