Sha256: 37ce49dd5d6d0336e67f949231d2787d969d037ae0555d12dc5e59ca6d1e896f

Contents?: true

Size: 968 Bytes

Versions: 2

Compression:

Stored size: 968 Bytes

Contents

# frozen_string_literal: true

require "refinements/struct"

module Rubysmith
  module Builders
    # Builds project skeleton Rake support.
    class Rake < Abstract
      using Refinements::Struct

      def call
        return configuration unless configuration.build_rake

        add_binstub
        add_configuration
        configuration
      end

      private

      def add_binstub
        builder.call(configuration.merge(template_path: "%project_name%/bin/rake.erb"))
               .render
               .permit 0o755
      end

      def add_configuration
        builder.call(configuration.merge(template_path: "%project_name%/Rakefile.erb"))
               .render
               .replace(/\[\s+/, "[")
               .replace(/\s+\]/, "]")
               .replace("  ", "")
               .replace("task.options", "  task.options")
               .replace(/\n+(?=require)/, "\n")
               .replace(/\n{2,}/, "\n\n")
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysmith-6.10.0 lib/rubysmith/builders/rake.rb
rubysmith-6.9.0 lib/rubysmith/builders/rake.rb