Sha256: 19f9d7507a1b829ea682d37cd1dccaaa577ea42640ce7d88511e04e276873b61

Contents?: true

Size: 904 Bytes

Versions: 22

Compression:

Stored size: 904 Bytes

Contents

# frozen_string_literal: true

require "refinements/structs"

module Rubysmith
  module Builders
    # Builds project skeleton Rake support.
    class Rake
      using Refinements::Structs

      def self.call(...) = new(...).call

      def initialize configuration, builder: Builder
        @configuration = configuration
        @builder = builder
      end

      def call
        return configuration unless configuration.build_rake

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

        configuration
      end

      private

      attr_reader :configuration, :builder
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
rubysmith-4.3.0 lib/rubysmith/builders/rake.rb
rubysmith-4.2.0 lib/rubysmith/builders/rake.rb
rubysmith-4.1.0 lib/rubysmith/builders/rake.rb
rubysmith-4.0.1 lib/rubysmith/builders/rake.rb
rubysmith-4.0.0 lib/rubysmith/builders/rake.rb
rubysmith-3.8.0 lib/rubysmith/builders/rake.rb
rubysmith-3.7.0 lib/rubysmith/builders/rake.rb
rubysmith-3.6.0 lib/rubysmith/builders/rake.rb
rubysmith-3.5.0 lib/rubysmith/builders/rake.rb
rubysmith-3.4.0 lib/rubysmith/builders/rake.rb
rubysmith-3.3.0 lib/rubysmith/builders/rake.rb
rubysmith-3.2.0 lib/rubysmith/builders/rake.rb
rubysmith-3.1.0 lib/rubysmith/builders/rake.rb
rubysmith-3.0.1 lib/rubysmith/builders/rake.rb
rubysmith-3.0.0 lib/rubysmith/builders/rake.rb
rubysmith-2.0.2 lib/rubysmith/builders/rake.rb
rubysmith-2.0.1 lib/rubysmith/builders/rake.rb
rubysmith-2.0.0 lib/rubysmith/builders/rake.rb
rubysmith-1.3.0 lib/rubysmith/builders/rake.rb
rubysmith-1.2.0 lib/rubysmith/builders/rake.rb