Class: Gemsmith::Generators::Pragma

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

Overview

Formats pragma comments in source files.

Constant Summary

Constants inherited from Base

Base::LIB_ROOT

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



34
35
36
37
38
39
40
# File 'lib/gemsmith/generators/pragma.rb', line 34

def run
  Pragmater::Runner.new(
    gem_root,
    comments: self.class.comments,
    whitelist: whitelist
  ).run action: :add
end

#whitelistObject

rubocop:disable Metrics/MethodLength



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

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