yardstick
yardstick copied to clipboard
Printing measurements to stdout via Rake tasks
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.
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