Sha256: 767607228e3a865b5aa9c755ace45cd75ad669db9be2a5068914aced483fe5b1

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require "pragmater"
require "refinements/pathname"

module Rubysmith
  module Extensions
    # Ensures project skeleton has pragmas.
    class Pragmater
      include Import[:settings, :logger]

      using Refinements::Pathname

      CLIENT = ::Pragmater::Inserter.new(
        settings: ::Pragmater::Configuration::Model[
          comments: ["# frozen_string_literal: true"],
          patterns: %w[
            **/*.rake
            **/*.rb
            *.gemspec
            exe/*
            bin/console
            bin/rake
            bin/rspec
            bin/rubocop
            bin/setup
            config.ru
            Gemfile
            Rakefile
          ]
        ]
      ).freeze

      def initialize(client: CLIENT, **)
        @client = client
        super(**)
      end

      def call
        logger.info { "Adding frozen string literal pragmas..." }
        settings.project_root.change_dir { client.call }
        true
      end

      private

      attr_reader :client
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubysmith-7.9.0 lib/rubysmith/extensions/pragmater.rb
rubysmith-7.8.0 lib/rubysmith/extensions/pragmater.rb
rubysmith-7.7.0 lib/rubysmith/extensions/pragmater.rb
rubysmith-7.6.0 lib/rubysmith/extensions/pragmater.rb
rubysmith-7.5.0 lib/rubysmith/extensions/pragmater.rb
rubysmith-7.4.0 lib/rubysmith/extensions/pragmater.rb