From c0c35443eab0ae26f3309b60ddfebee5b0d1dbec Mon Sep 17 00:00:00 2001 From: Evan Gray Date: Fri, 23 Jun 2023 23:16:01 -0500 Subject: [PATCH] Add rake tasks for bumping gem version --- Rakefile | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/Rakefile b/Rakefile index 0eaf019..3b5c5c4 100644 --- a/Rakefile +++ b/Rakefile @@ -19,3 +19,48 @@ RDoc::Task.new do |rdoc| end task default: :test + +namespace :version do + desc "Print the current version from the version.rb file" + task :current do + puts Attribool::VERSION + end + + namespace :increment do + desc "Increment the version's PATCH level" + task :patch do + File.join(__dir__, "lib", "attribool", "version.rb").then do |version_file| + File.write( + version_file, + File.read(version_file).sub(/(PATCH\s=\s)(\d+)/) { "#{$1}#{$2.next}" } + ) + end + system("bundle lock") + end + desc "Increment the version's MINOR level" + task :minor do + File.join(__dir__, "lib", "attribool", "version.rb").then do |version_file| + File.write( + version_file, + File.read(version_file) + .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" } + .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" } + ) + end + system("bundle lock") + end + desc "Increment the version's MAJOR level" + task :major do + File.join(__dir__, "lib", "attribool", "version.rb").then do |version_file| + File.write( + version_file, + File.read(version_file) + .sub(/(PATCH\s=\s)(\d+)/) { "#{$1}0" } + .sub(/(MINOR\s=\s)(\d+)/) { "#{$1}0" } + .sub(/(MAJOR\s=\s)(\d+)/) { "#{$1}#{$2.next}" } + ) + end + system("bundle lock") + end + end +end