From b268e583fb16330e779e79507b53c18d5a760765 Mon Sep 17 00:00:00 2001 From: Manfred Stienstra Date: Mon, 11 Dec 2023 10:35:00 +0100 Subject: [PATCH] [Rubocop] Autocorrect Rakefile. --- Rakefile | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/Rakefile b/Rakefile index c790528..e71b8fa 100644 --- a/Rakefile +++ b/Rakefile @@ -1,27 +1,32 @@ +# frozen_string_literal: true + require 'rdoc/task' -$:.unshift(File.expand_path('../ext', __FILE__)) +$LOAD_PATH.unshift(File.expand_path('ext', __dir__)) task default: :test -task compile: "extconf:compile" +task compile: 'extconf:compile' -desc "Run all tests" +desc 'Run all tests' task test: :compile do - Dir[File.dirname(__FILE__) + '/test/**/*_test.rb'].each do |file| + Dir["#{File.dirname(__FILE__)}/test/**/*_test.rb"].each do |file| ruby file end end namespace :profile do - desc "Profile memory" + desc 'Profile memory' task memory: :compile do - sh 'valgrind --tool=memcheck --leak-check=yes --num-callers=10 --track-fds=yes ruby test/profile/memory.rb' + sh( + 'valgrind --tool=memcheck --leak-check=yes --num-callers=10 ' \ + '--track-fds=yes ruby test/profile/memory.rb' + ) end end task :clean do - crap = "*.{bundle,so,o,obj,log}" - ["*.gem", "ext/**/#{crap}", "ext/**/Makefile"].each do |glob| + crap = '*.{bundle,so,o,obj,log}' + ['*.gem', "ext/**/#{crap}", 'ext/**/Makefile'].each do |glob| Dir.glob(glob).each do |file| rm(file) end @@ -31,25 +36,25 @@ end namespace :extconf do task :makefile do Dir.chdir('ext') do - ruby "extconf.rb" + ruby 'extconf.rb' end end task make: :makefile do Dir.chdir('ext') do - sh(RUBY_PLATFORM =~ /win32/ ? 'nmake' : 'make') do |ok, res| - if !ok - require "fileutils" + sh(RUBY_PLATFORM.match?(/win32/) ? 'nmake' : 'make') do |ok, _res| + unless ok + require 'fileutils' FileUtils.rm_rf(Dir.glob('*.{so,o,dll,bundle}')) end end end end - desc "Compile the Ruby extension" + desc 'Compile the Ruby extension' task compile: :make do - if Dir.glob("ext/*.{o,so,dll}").length == 0 - $stderr.puts("Failed to build ext.") + if Dir.glob('ext/*.{o,so,dll}').empty? + warn('Failed to build ext.') exit(1) end end @@ -58,8 +63,8 @@ end namespace :docs do Rake::RDocTask.new('generate') do |rdoc| rdoc.title = 'Tedrahcu' - rdoc.main = "README.md" + rdoc.main = 'README.md' rdoc.rdoc_files.include('README.md', 'ext/tedrahcu.c') - rdoc.options << "--all" << "--charset" << "utf-8" + rdoc.options << '--all' << '--charset' << 'utf-8' end -end \ No newline at end of file +end