59 lines
1.1 KiB
Ruby
59 lines
1.1 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
CLEAN << '.yardoc'
|
|
CLEAN << 'coverage'
|
|
CLEAN << 'doc'
|
|
CLEAN << 'spec/examples.txt'
|
|
|
|
desc 'Run default checks'
|
|
task default: %i[test lint]
|
|
|
|
desc 'Run tests'
|
|
task test: :spec
|
|
|
|
desc 'Run code analysis tools'
|
|
task lint: %i[rubocop yard:cov]
|
|
|
|
desc 'Fix code style (rubocop --auto-correct)'
|
|
task fix: 'rubocop:auto_correct'
|
|
|
|
begin
|
|
require 'rspec/core/rake_task'
|
|
RSpec::Core::RakeTask.new
|
|
rescue LoadError
|
|
nil
|
|
end
|
|
|
|
begin
|
|
require 'rubocop/rake_task'
|
|
RuboCop::RakeTask.new
|
|
rescue LoadError
|
|
nil
|
|
end
|
|
|
|
begin
|
|
require 'yard'
|
|
YARD::Rake::YardocTask.new
|
|
rescue LoadError
|
|
nil
|
|
end
|
|
|
|
desc 'Open development console'
|
|
task :console do
|
|
exec 'bundle', 'exec', File.expand_path(File.join('bin', 'console'), __dir__)
|
|
end
|
|
|
|
namespace :yard do
|
|
desc 'Measure documentation coverage'
|
|
task :cov do
|
|
result = `bundle exec yard stats`.lines.last.strip.freeze
|
|
m = result.match(/\A(\d+(\.\d+)?)% documented\z/)
|
|
raise 'Invalid result' if m.nil?
|
|
|
|
coverage = m[1].to_f.round(2)
|
|
puts "Documentation coverage: #{coverage}%"
|
|
# TODO: raise 'Not fully documented!' if coverage != 100
|
|
end
|
|
end
|