Sha256: 2c5b75ca221b247935d366f6e4016cf4ccf685154f0f922799e13d7bdec291d5

Contents?: true

Size: 694 Bytes

Versions: 1

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

require "refinements/pathnames"

module Pragmater
  # Adds/removes pragma comments for files in given path.
  class Runner
    using Refinements::Pathnames

    def self.for **attributes
      new Context[attributes]
    end

    def initialize context, parser: Parsers::File.new
      @context = context
      @parser = parser
    end

    def call
      Pathname(context.root_dir).files("{#{context.includes.join ","}}").map(&method(:write))
    end

    private

    attr_reader :context, :parser

    def write path
      path.tap do |a_path|
        a_path.write parser.call(a_path, context.comments, action: context.action).join
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pragmater-8.1.0 lib/pragmater/runner.rb