2024-10-18 08:32:34 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'bundler/gem_tasks'
|
|
|
|
|
|
|
|
module Bundler
|
|
|
|
class GemHelper
|
|
|
|
def tag_version(*)
|
|
|
|
yield if block_given?
|
|
|
|
end
|
|
|
|
|
|
|
|
def git_push(*); end
|
|
|
|
|
|
|
|
def perform_git_push(*); end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
CLEAN << '.yardoc'
|
|
|
|
CLEAN << 'coverage'
|
|
|
|
CLEAN << 'doc'
|
|
|
|
|
|
|
|
desc 'Run default checks'
|
|
|
|
task default: %i[test lint]
|
|
|
|
|
|
|
|
desc 'Run tests'
|
|
|
|
task test: :tests
|
|
|
|
|
|
|
|
desc 'Run code analysis tools'
|
|
|
|
task lint: %i[rubocop yard:cov]
|
|
|
|
|
2024-10-18 15:06:14 -04:00
|
|
|
desc 'Fix code style (rubocop --autocorrect)'
|
|
|
|
task fix: 'rubocop:autocorrect'
|
2024-10-18 08:32:34 -04:00
|
|
|
|
2024-10-18 10:48:00 -04:00
|
|
|
Rake::Task['release'].prereqs.unshift 'default'
|
|
|
|
Rake::Task['release:rubygem_push'].clear
|
|
|
|
|
2024-10-18 08:32:34 -04:00
|
|
|
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
|
|
|
|
sh 'bundle', 'exec',
|
|
|
|
File.expand_path(File.join('bin', 'console'), __dir__)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Run tests'
|
|
|
|
task :tests do
|
|
|
|
sh 'bundle', 'exec',
|
|
|
|
File.expand_path(File.join('tests', 'examples.rb'), __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}%"
|
2024-10-18 14:48:24 -04:00
|
|
|
raise 'Not fully documented!' if coverage < 36
|
2024-10-18 08:32:34 -04:00
|
|
|
end
|
|
|
|
end
|