Sha256: 424a40301b4b8cfef7b2c4deea36280661e0d7e5dd49340172d8fa6f8ca3505d

Contents?: true

Size: 1.15 KB

Versions: 6

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

require "bundler/gem_tasks"
require "rspec/core/rake_task"
require "active_support"
require "active_support/core_ext"

RSpec::Core::RakeTask.new(:spec)

task default: :spec

desc "Generate executables for command classes"
task :generate_executables do
  require "fileutils"

  # Load the gem's library files
  $LOAD_PATH.unshift("#{__dir__}/lib")

  require "matheus"

  Zeitwerk::Loader.eager_load_all

  exe_dir = File.expand_path("#{__dir__}/exe")

  Matheus::Command.descendants.each do |command_class|
    script_path = File.join(exe_dir, command_class.name.demodulize.underscore.dasherize)
    next if File.exist?(script_path)

    script_content = <<~SCRIPT
      #!/usr/bin/env ruby

      $LOAD_PATH.unshift("\#{__dir__}/../lib")

      require "matheus"

      Matheus::#{command_class.name.demodulize}.call ARGV
    SCRIPT

    File.write(script_path, script_content)
    FileUtils.chmod("+x", script_path)

    puts "Generated executable: #{script_path}"
  end
end

# Ensure the generate_executables task runs before the build task
task build: :generate_executables
# Ensure tests are run before releasing the gem
task release: :spec

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
matheus-0.6.3 Rakefile
matheus-0.6.2 Rakefile
matheus-0.6.1 Rakefile
matheus-0.6.0 Rakefile
matheus-0.5.0 Rakefile
matheus-0.4.0 Rakefile