Skip to content

Commit

Permalink
[Rubocop] Autocorrect Rakefile.
Browse files Browse the repository at this point in the history
  • Loading branch information
Manfred committed Dec 11, 2023
1 parent 51e9eef commit b268e58
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
end

0 comments on commit b268e58

Please sign in to comment.