2023-05-02 08:57:39 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
|
2023-05-09 13:39:57 +00:00
|
|
|
CLEAN << '.yardoc'
|
2023-05-09 13:58:09 +00:00
|
|
|
CLEAN << 'coverage'
|
2023-05-09 13:39:57 +00:00
|
|
|
CLEAN << 'doc'
|
2023-05-09 13:58:09 +00:00
|
|
|
CLEAN << 'spec/examples.txt'
|
2023-05-09 13:39:57 +00:00
|
|
|
|
2023-05-09 13:33:15 +00:00
|
|
|
desc 'Run default checks'
|
2023-05-09 13:58:09 +00:00
|
|
|
task default: %i[test lint]
|
|
|
|
|
|
|
|
desc 'Run tests'
|
|
|
|
task test: :spec
|
2023-05-09 13:33:15 +00:00
|
|
|
|
|
|
|
desc 'Run code analysis tools'
|
2023-05-09 13:39:57 +00:00
|
|
|
task lint: %i[rubocop yard:cov]
|
2023-05-09 13:33:15 +00:00
|
|
|
|
|
|
|
desc 'Fix code style (rubocop --auto-correct)'
|
|
|
|
task fix: 'rubocop:auto_correct'
|
|
|
|
|
2023-05-09 13:58:09 +00:00
|
|
|
begin
|
|
|
|
require 'rspec/core/rake_task'
|
|
|
|
RSpec::Core::RakeTask.new
|
|
|
|
rescue LoadError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2023-05-09 13:33:15 +00:00
|
|
|
begin
|
|
|
|
require 'rubocop/rake_task'
|
|
|
|
RuboCop::RakeTask.new
|
|
|
|
rescue LoadError
|
|
|
|
nil
|
|
|
|
end
|
2023-05-02 08:57:39 +00:00
|
|
|
|
2023-05-09 13:39:57 +00:00
|
|
|
begin
|
|
|
|
require 'yard'
|
|
|
|
YARD::Rake::YardocTask.new
|
|
|
|
rescue LoadError
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
|
2023-05-02 08:57:39 +00:00
|
|
|
desc 'Open development console'
|
|
|
|
task :console do
|
2023-05-02 13:48:32 +00:00
|
|
|
exec 'bundle', 'exec', File.expand_path(File.join('bin', 'console'), __dir__)
|
2023-05-02 08:57:39 +00:00
|
|
|
end
|
2023-05-09 13:39:57 +00:00
|
|
|
|
|
|
|
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
|