Sha256: 03f43a0f295c4c3dbd7aff5d78b922cefcfd78d5de43c11ab8990bd072b1f103

Contents?: true

Size: 959 Bytes

Versions: 8

Compression:

Stored size: 959 Bytes

Contents

# frozen_string_literal: true

require "refinements/struct"

module Rubysmith
  module Builders
    # Builds Bundler Gemfile configuration for project skeleton.
    class Bundler
      using Refinements::Struct

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

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

      def call
        builder.call(configuration.merge(template_path: "%project_name%/Gemfile.erb"))
               .render
               .replace(/\n\s+group/, "\n\ngroup")
               .replace(/\n\s+gem/, "\n  gem")
               .replace(/  (?=.+(refinements|zeitwerk))/, "")
               .replace(/(\n+|\s+)end/, "\nend")
               .replace(/\n\ngroup :(quality|development|test|tools) do\nend/, "")
               .replace(/org"\n+/, "org\"\n\n")

        configuration
      end

      private

      attr_reader :configuration, :builder
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rubysmith-6.6.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.5.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.4.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.3.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.2.1 lib/rubysmith/builders/bundler.rb
rubysmith-6.2.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.1.0 lib/rubysmith/builders/bundler.rb
rubysmith-6.0.0 lib/rubysmith/builders/bundler.rb