Rakefile in rmagick-2.16.0 vs Rakefile in rmagick-3.0.0
- old
+ new
@@ -1,25 +1,32 @@
require 'simplecov'
require './lib/rmagick/version'
require 'fileutils'
require 'English'
+desc "Open an irb session preloaded with this library"
+task :console do
+ sh "irb -r ./ext/RMagick/extconf.rb -r ./lib/rmagick.rb"
+end
+
task :config do
def version
Magick::VERSION
end
+
# e.g. 2.13.3 becomes RMagick_2-13-3
def version_tag
- "RMagick_#{version.gsub('.','-')}"
+ "RMagick_#{version.tr('.', '-')}"
end
+
# e.g. 2.13.3 becomes rmagick-2.13.3.gem
def gem_name
"rmagick-#{version}.gem"
end
def base
- File.expand_path('..', __FILE__)
+ File.expand_path(__dir__)
end
end
desc 'abort when repo is not clean or has uncommited code'
task :assert_clean_repo do
@@ -28,22 +35,22 @@
sh('git diff-index --quiet --cached HEAD')
abort 'Git repo not commited' unless $CHILD_STATUS.success?
end
desc 'build gem'
-task :build => [:config] do
+task build: [:config] do
sh 'gem build -V rmagick.gemspec'
if $CHILD_STATUS.success?
FileUtils.mkdir_p(File.join(base, 'pkg'))
FileUtils.mv(File.join(base, gem_name), 'pkg')
else
STDERR.puts 'Could not build gem'
exit $CHILD_STATUS.exitstatus
end
end
-task :push_and_tag => [:build] do
+task push_and_tag: [:build] do
sh "gem push #{File.join(base, 'pkg', gem_name)}"
if $CHILD_STATUS.success?
sh "git tag -a -m \"Version #{version}\" #{version_tag}"
STDOUT.puts "Tagged #{version_tag}."
sh 'git push'
@@ -52,14 +59,14 @@
abort 'tagging aborted pushing gem failed'
end
end
desc 'Release'
-task :release => [:assert_clean_repo, :push_and_tag]
+task release: %i[assert_clean_repo push_and_tag]
desc 'Release and build the legacy way'
-task :legacy_release=> ['legacy:README.html', 'legacy:extconf', 'legacy:doc', 'legacy:manifest', 'release']
+task legacy_release: ['legacy:README.html', 'legacy:extconf', 'legacy:doc', 'legacy:manifest', 'release']
namespace :legacy do
require 'find'
task :redcloth do
@@ -75,11 +82,11 @@
now = Time.new
now = now.strftime('%m/%d/%y')
lines = File.readlines name
lines.each do |line|
- line.gsub!(%r{0\.0\.0}, Magick::VERSION)
+ line.gsub!(/0\.0\.0/, Magick::VERSION)
line.gsub!(%r{YY/MM/DD}, now)
end
lines
end
@@ -88,11 +95,11 @@
lines = reversion(name)
tmp_name = name + '_tmp'
mv name, tmp_name
begin
File.open(name, 'w') { |f| lines.each { |line| f.write line } }
- rescue
+ rescue StandardError
mv tmp_name, name
ensure
rm tmp_name
end
end
@@ -141,12 +148,12 @@
# Remove files we don't want in the tarball.
# Ensure files are not executable. (ref: bug #10080)
desc "Remove files we don't want in the .gem; ensure files are not executable"
task :fix_files do
- rm 'README.txt', :verbose => true
- chmod 0644, FileList['doc/*.html', 'doc/ex/*.rb', 'doc/ex/images/*', 'examples/*.rb']
+ rm 'README.txt', verbose: true
+ chmod 0o644, FileList['doc/*.html', 'doc/ex/*.rb', 'doc/ex/images/*', 'examples/*.rb']
end
desc 'Build manifest'
task :manifest do
now = Time.new
@@ -155,11 +162,12 @@
File.open(MANIFEST, 'w') do |f|
f.puts "MANIFEST for #{Magick::VERSION} - #{now}\n\n"
Find.find('.') do |name|
next if File.directory? name
- f.puts name[2..-1] # remove leading "./"
+
+ f.puts name[2..-1] # remove leading "./"
end
end
end
end
@@ -174,15 +182,15 @@
Rake::TestTask.new(:test) do |t|
t.libs << 'test'
end
-task :test => :compile
-task :spec => :compile
+task test: :compile
+task spec: :compile
if ENV['STYLE_CHECKS']
require 'rubocop/rake_task'
RuboCop::RakeTask.new
- task :default => [:spec, :test, :rubocop]
+ task default: %i[spec test rubocop]
else
- task :default => [:spec, :test]
+ task default: %i[spec test]
end