Sha256: 7bf5e62d32162986b8b5a152b494f604df9c62816b723be5858cd0d684f6fece

Contents?: true

Size: 819 Bytes

Versions: 4

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

require "pragmater"
require "pathname"

module Gemsmith
  module Generators
    # Formats pragma comments in source files.
    class Pragma < Base
      def self.comments
        ["# frozen_string_literal: true"]
      end

      # rubocop:disable Metrics/MethodLength
      def whitelist
        %W[
          Gemfile
          Guardfile
          Rakefile
          config.ru
          bin/#{configuration.dig :gem, :name}
          bin/rails
          .gemspec
          .rake
          .rb
        ]
      end

      def run
        whitelisted_files.each { |file| Pragmater::Writer.new(file, self.class.comments).add }
      end

      private

      def whitelisted_files
        Pathname.glob(%(#{gem_root}/**/*{#{whitelist.join ","}})).select(&:file?)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gemsmith-9.6.0 lib/gemsmith/generators/pragma.rb
gemsmith-9.5.0 lib/gemsmith/generators/pragma.rb
gemsmith-9.4.0 lib/gemsmith/generators/pragma.rb
gemsmith-9.3.0 lib/gemsmith/generators/pragma.rb