class BundleGrep

Constants

VERSION

Public Instance Methods

exec(command, args) click to toggle source
# File lib/bundle_grep.rb, line 9
def exec(command, args)
  # TODO: could just shell out to `bundle list --paths` instead?
  paths = with_captured_stdout {
    Bundler::CLI::List.new("paths" => true).run
  }.lines.map(&:strip)
  cmd = "grep --color -r #{args.join(' ')} #{paths.join(' ')}"
  system(cmd)
end

Private Instance Methods

with_captured_stdout() { || ... } click to toggle source
# File lib/bundle_grep.rb, line 18
        def with_captured_stdout
  original_stdout = $stdout
  $stdout = StringIO.new
  yield
  $stdout.string
ensure
  $stdout = original_stdout
end