Sha256: 1108bedaa67e326f5cdf6e1cd1a9c551b3414ba1bf53b7e398fb855b9be3a90b

Contents?: true

Size: 895 Bytes

Versions: 1

Compression:

Stored size: 895 Bytes

Contents

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

class ReekWorld
  def run(cmd)
    out, err, status = Open3.capture3(cmd)
    @last_stdout = out
    @last_stderr = err
    @last_exit_status = status.exitstatus
  end

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

  def reek_with_pipe(stdin, args)
    run("echo \"#{stdin}\" | ruby -Ilib -rubygems 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

1 entries across 1 versions & 1 rubygems

Version Path
reek-1.4.0 features/support/env.rb