Class: Gemsmith::Generators::Pragma

Inherits:
Base
  • Object
show all
Defined in:
lib/gemsmith/generators/pragma.rb

Overview

Formats pragma comments in source files.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, run

Constructor Details

This class inherits a constructor from Gemsmith::Generators::Base

Class Method Details

.commentsObject



10
11
12
# File 'lib/gemsmith/generators/pragma.rb', line 10

def self.comments
  ["# frozen_string_literal: true"]
end

Instance Method Details

#runObject



29
30
31
# File 'lib/gemsmith/generators/pragma.rb', line 29

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

#whitelistObject

rubocop:disable Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gemsmith/generators/pragma.rb', line 15

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