Sha256: 704c636e1570e5818716c28213754d7ccf4ef250f4953ec79f2902c80ffb48ef

Contents?: true

Size: 831 Bytes

Versions: 6

Compression:

Stored size: 831 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(%(#{cli.destination_root}/**/*{#{whitelist.join ","}})).select(&:file?)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gemsmith-9.2.0 lib/gemsmith/generators/pragma.rb
gemsmith-9.1.0 lib/gemsmith/generators/pragma.rb
gemsmith-9.0.0 lib/gemsmith/generators/pragma.rb
gemsmith-8.2.0 lib/gemsmith/generators/pragma.rb
gemsmith-8.1.0 lib/gemsmith/generators/pragma.rb
gemsmith-8.0.0 lib/gemsmith/generators/pragma.rb