Class: Pragmater::Inserter

Inherits:
Object
  • Object
show all
Defined in:
lib/pragmater/inserter.rb

Overview

Inserts pragma comments.

Instance Method Summary collapse

Constructor Details

#initialize(parser: Parsers::File.new) ⇒ Inserter

Returns a new instance of Inserter.



12
13
14
15
# File 'lib/pragmater/inserter.rb', line 12

def initialize(parser: Parsers::File.new, **)
  @parser = parser
  super(**)
end

Instance Method Details

#callObject



17
18
19
20
21
22
# File 'lib/pragmater/inserter.rb', line 17

def call
  Pathname(settings.root_dir).files("{#{settings.patterns.join ","}}").map do |path|
    yield path if block_given?
    path.write parser.call(path, settings.comments, action: :insert).join
  end
end