Sha256: 6279f020de5b21cb7e6708ee5997ab0d2e54ad327dd4d130577196babc408fe6

Contents?: true

Size: 868 Bytes

Versions: 14

Compression:

Stored size: 868 Bytes

Contents

# frozen_string_literal: true

require "refinements/structs"

module Rubysmith
  module Builders
    module RSpec
      # Builds RSpec spec helper for project skeleton.
      class Helper
        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_rspec

          builder.call(configuration.merge(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")

          configuration
        end

        private

        attr_reader :configuration, :builder
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rubysmith-3.4.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-3.3.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-3.2.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-3.1.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-3.0.1 lib/rubysmith/builders/rspec/helper.rb
rubysmith-3.0.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-2.0.2 lib/rubysmith/builders/rspec/helper.rb
rubysmith-2.0.1 lib/rubysmith/builders/rspec/helper.rb
rubysmith-2.0.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-1.3.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-1.2.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-1.1.1 lib/rubysmith/builders/rspec/helper.rb
rubysmith-1.1.0 lib/rubysmith/builders/rspec/helper.rb
rubysmith-1.0.0 lib/rubysmith/builders/rspec/helper.rb