Sha256: a40450ca745023c70d29f9af9ce3e2053738c21d5bb0169a166253a18e1967cc

Contents?: true

Size: 817 Bytes

Versions: 2

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

module Rubysmith
  module Builders
    module RSpec
      # Builds RSpec spec helper for project skeleton.
      class Helper
        def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call

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

        def call
          return unless configuration.build_rspec

          builder.call(configuration.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
                 .render
                 .replace(/\n{3,}/, "\n\n")
                 .replace(/\n\s{2}(?=(require|Simple|using|Pathname|Dir))/, "\n")
        end

        private

        attr_reader :configuration, :builder
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubysmith-0.11.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-0.10.0 lib/rubysmith/builders/rspec/helper.rb