Sha256: c80c56365fba8d6ada498eee5ccf0ce166bdd6ac6b8d4dfdeb991efbb68346b5

Contents?: true

Size: 1.22 KB

Versions: 2

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

ENV["RACK_ENV"] ||= "development"

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "rubocop/rake_task"
require "yard"

RSpec::Core::RakeTask.new(:spec)
RuboCop::RakeTask.new(:rubocop)
YARD::Rake::YardocTask.new

desc "allows running a demo controller"
task :demo do
  system("rackup --host 0.0.0.0 -P #{File.expand_path(".")}/tmp/daemon.pid")
end

desc "automatically bump the gem's version"
task :bump, [:type] do |_t, args|
  type = args[:type] || ENV["TYPE"] || "patch"
  current_version = Metatron::VERSION
  new_version = calculate_new_version(type)
  puts "Bumping gem version from #{current_version} to #{new_version}"
  update_version(new_version)
end

task default: %i[spec rubocop yard]

def calculate_new_version(type)
  version = Metatron::VERSION.split(".").map(&:to_i)
  case type
  when "patch"
    version[2] += 1
  when "minor"
    version[1] += 1
    version[2] = 0
  when "major"
    version[0] += 1
    version[1] = 0
    version[2] = 0
  end

  version.join(".")
end

def update_version(new_version)
  file = File.read("lib/metatron/version.rb")
  new_contents = file.gsub(/VERSION = "(.+)"/, %(VERSION = "#{new_version}"))
  File.write("lib/metatron/version.rb", new_contents)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metatron-0.6.0 Rakefile
metatron-0.5.0 Rakefile