Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing measurements to stdout via Rake tasks #23

Open
jimmycuadra opened this issue Jan 26, 2014 · 1 comment
Open

Printing measurements to stdout via Rake tasks #23

jimmycuadra opened this issue Jan 26, 2014 · 1 comment

Comments

@jimmycuadra
Copy link

Is there a way to make the measurement Rake tasks output results to stdout instead of a file, just as the CLI does? It looks like Yardstick::Config#output is coerced into a Yardstick::ReportOutput, which in turn coerces its target to a Pathname. I'd like to be able to just set config.output to an IO object directly.

@aaronmallen
Copy link

I managed to accomplish this via:

require 'yard'
require 'yaml'
require 'yardstick/rake/measurement'
require 'yardstick/rake/verify'

namespace :doc do
  yardstick_opts = YAML.load(File.read('.yardstick.yml'))
  yardstick_report = File.join('doc', 'coverage', 'report.txt')
  Yardstick::Rake::Measurement.new(:lint, yardstick_opts) do |measurement|
    measurement.output = yardstick_report
  end
  task :output_report do
    puts File.read(yardstick_report)
  end
  namespace :lint do
    Yardstick::Rake::Verify.new(:verify, yardstick_opts) do |verify|
      verify.threshold = 95
    end
  end
end

YARD::Rake::YardocTask.new(:doc) do |t|
  t.files         = ['lib/**/*.rb', 'spec/**/*_spec.rb']
  t.stats_options = ['--list-undoc']
end

Rake::Task[:'doc:lint'].enhance do
  Rake::Task[:'doc:output_report'].invoke
end

Rake::Task[:doc].enhance do
  Rake::Task[:'doc:lint'].invoke
  Rake::Task[:'doc:lint:verify'].invoke
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants