| 1 |
# frozen_string_literal: true |
| 2 |
|
| 3 |
require 'rubygems' |
| 4 |
|
| 5 |
# Adds build, release, etc. |
| 6 |
require 'bundler/gem_tasks' |
| 7 |
|
| 8 |
require 'rspec/core/rake_task' |
| 9 |
RSpec::Core::RakeTask.new(:spec) do |spec| |
| 10 |
spec.pattern = FileList['spec/**/*_spec.rb'] |
| 11 |
end |
| 12 |
namespace :spec do |
| 13 |
if RUBY_VERSION =~ /^1\.8/ |
| 14 |
desc 'Rspec code coverage (1.8.7)' |
| 15 |
RSpec::Core::RakeTask.new(:coverage) do |spec| |
| 16 |
spec.pattern = 'spec/**/*_spec.rb' |
| 17 |
spec.rcov = true |
| 18 |
end |
| 19 |
else |
| 20 |
desc 'Rspec code coverage (1.9+)' |
| 21 |
task :coverage do |
| 22 |
ENV['COVERAGE'] = 'true' |
| 23 |
Rake::Task['spec'].execute |
| 24 |
end |
| 25 |
end |
| 26 |
end |
| 27 |
|
| 28 |
require 'rubocop/rake_task' |
| 29 |
RuboCop::RakeTask.new |
| 30 |
|
| 31 |
require 'rdoc/task' |
| 32 |
Rake::RDocTask.new do |rdoc| |
| 33 |
version = File.exist?('VERSION') ? File.read('VERSION') : '' |
| 34 |
|
| 35 |
rdoc.rdoc_dir = 'rdoc' |
| 36 |
rdoc.title = "recursive-open-struct #{version}" |
| 37 |
rdoc.rdoc_files.include('README*') |
| 38 |
rdoc.rdoc_files.include('lib/**/*.rb') |
| 39 |
end |
| 40 |
|
| 41 |
task default: %i[spec rubocop] |
| 42 |
|
| 43 |
desc 'Ensure all files have appropriate permissions before building a package' |
| 44 |
task :fix_permissions do |
| 45 |
File.umask 0o022 |
| 46 |
filelist = `git ls-files`.split("\n") |
| 47 |
FileUtils.chmod 0o644, filelist, verbose: true |
| 48 |
FileUtils.chmod 0o755, %w[lib spec], verbose: true |
| 49 |
end |
| 50 |
|
| 51 |
desc 'Update the AUTHORS.txt file' |
| 52 |
task :update_authors do |
| 53 |
authors = `git log --format="%aN <%aE>"|sort -f|uniq` |
| 54 |
File.open('AUTHORS.txt', 'w') do |f| |
| 55 |
f.write("Recursive-open-struct was written by these fine people:\n\n") |
| 56 |
f.write(authors.split("\n").reject { |a| a.start_with?('dependabot[bot]') }.map { |a| "* #{a}" }.join("\n")) |
| 57 |
f.write("\n") |
| 58 |
end |
| 59 |
end |
| 60 |
|
| 61 |
task build: %i[update_authors fix_permissions] |
| 62 |
|
| 63 |
desc 'Run an interactive pry shell with ros required' |
| 64 |
task :pry do |
| 65 |
sh 'pry -I lib -r recursive-open-struct' |
| 66 |
end |