Sha256: 81eb11799366305b5eff468e6058caf166d1e4ced3abaf5869d3b2d426026ab2

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'English'
require 'tempfile'
require 'fileutils'
require 'open3'
require 'reek/cli/application'

begin
  require 'pry'
  require 'byebug'
rescue LoadError # rubocop:disable Lint/HandleExceptions
end

class ReekWorld
  def run(cmd)
    stderr_file = Tempfile.new('reek-world')
    stderr_file.close
    @last_stdout = `#{cmd} 2> #{stderr_file.path}`
    @last_exit_status = $CHILD_STATUS.exitstatus
    @last_stderr = IO.read(stderr_file.path)
  end

  def reek(args)
    run("ruby -Ilib bin/reek --no-color #{args}")
  end

  def reek_with_pipe(stdin, args)
    run("echo \"#{stdin}\" | ruby -Ilib bin/reek --no-color #{args}")
  end

  def rake(name, task_def)
    header = <<EOS
$:.unshift('lib')
require 'reek/rake/task'

EOS
    rakefile = Tempfile.new('rake_task', '.')
    rakefile.puts(header + task_def)
    rakefile.close
    run("rake -f #{rakefile.path} #{name}")
    lines = @last_stdout.split("\n")
    if lines.length > 0 && lines[0] =~ /^\(/
      @last_stdout = lines[1..-1].join("\n")
    end
  end
end

World do
  ReekWorld.new
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
reek-1.6.1 features/support/env.rb
reek-1.6.0 features/support/env.rb