Sha256: 47f6a3426f6968074718c174cc55e3b49c0b51b0a4cbad9e32d73217b87a6f39

Contents?: true

Size: 569 Bytes

Versions: 8

Compression:

Stored size: 569 Bytes

Contents

# frozen_string_literal: true

require "refinements/pathname"

module Pragmater
  # Inserts pragma comments.
  class Inserter
    include Import[:settings]

    using Refinements::Pathname

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

    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

    private

    attr_reader :parser
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
pragmater-15.7.0 lib/pragmater/inserter.rb
pragmater-15.6.0 lib/pragmater/inserter.rb
pragmater-15.5.0 lib/pragmater/inserter.rb
pragmater-15.4.0 lib/pragmater/inserter.rb
pragmater-15.3.0 lib/pragmater/inserter.rb
pragmater-15.2.0 lib/pragmater/inserter.rb
pragmater-15.1.0 lib/pragmater/inserter.rb
pragmater-15.0.0 lib/pragmater/inserter.rb