Sha256: d299f139ffb559e9210112bba5bdfefa49cf50b286f60a9edcd8c217de0d98a3

Contents?: true

Size: 963 Bytes

Versions: 12

Compression:

Stored size: 963 Bytes

Contents

$:.unshift 'lib'

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

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

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

  def reek_with_pipe(stdin, args)
    run("echo \"#{stdin}\" | ruby -Ilib -rubygems bin/reek #{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("RUBYOPT=rubygems rake -f #{rakefile.path} #{name}")
    lines = @last_stdout.split("\n")
    if lines.length > 0 and lines[0] =~ /^\(/
      @last_stdout = lines[1..-1].join("\n")
    end
  end
end

World do
  ReekWorld.new
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
reek-1.3.6 features/support/env.rb
reek-1.3.5 features/support/env.rb
reek-1.3.4 features/support/env.rb
reek-1.3.3 features/support/env.rb
reek-1.3.2 features/support/env.rb
reek-1.3.1 features/support/env.rb
reek-1.3 features/support/env.rb
reek-1.2.13 features/support/env.rb
reek-1.2.12 features/support/env.rb
reek-1.2.11 features/support/env.rb
reek-1.2.10 features/support/env.rb
reek-1.2.9 features/support/env.rb