# encoding: utf-8

namespace :metrics do
  allowed_versions = %w(mri-1.9.3 rbx-1.9.3)

  if allowed_versions.include?(Devtools.rvm) && system("which mutant > #{File::NULL}")
    desc 'Run mutant'
    task :mutant => :coverage do
      project = Devtools.project
      config  = project.mutant
      cmd = %[mutant -r ./spec/spec_helper.rb "::#{config.namespace}" --rspec-dm2]
      Kernel.system(cmd) or raise 'Mutant task is not successful'
    end
  else
    desc 'Run Mutant'
    task :mutant => :coverage do
      $stderr.puts 'Mutant is disabled'
    end
  end
end

# encoding: utf-8

namespace :metrics do
  allowed_versions = %w(mri-1.9.3 rbx-1.9.3)

  if allowed_versions.include?(Devtools.rvm) && system("which mutant > #{File::NULL}")
    desc 'Run mutant'
    task :mutant => :coverage do
      project = Devtools.project
      config  = project.mutant
      cmd = %W[mutant -r ./spec/spec_helper.rb "::#{config.namespace}" --rspec-dm2]
      system(*cmd) or raise 'Mutant task is not successful'
    end
  else
    desc 'Run Mutant'
    task :mutant => :coverage do
      $stderr.puts 'Mutant is disabled'
    end
  end
end

Change system command to use an Array as input
Change system command to use an Array as input

* This causes the arguments to be escaped automatically, preventing
  shell injection (not a huge risk in this case, but may prevent
  some kinds of errors; I wish this was the default interface).
