Sha256: ee4e6be331528f500de26ab13f7be934f7b3b21d3a77c131e3c4b5ec9d271639

Contents?: true

Size: 810 Bytes

Versions: 12

Compression:

Stored size: 810 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  # Adds/removes pragma comments for files in given path.
  class Runner
    # rubocop:disable Metrics/ParameterLists
    def initialize path = ".", comments: [], includes: [], writer: Writer
      @path = Pathname path
      @comments = Array comments
      @includes = Array includes
      @writer = writer
    end
    # rubocop:enable Metrics/ParameterLists

    def files
      return [] unless path.exist? && path.directory? && !includes.empty?

      Pathname.glob(%(#{path}/{#{includes.join ","}})).select(&:file?)
    end

    def run action:
      files.each do |file|
        writer.new(file, comments).public_send action
        yield file if block_given?
      end
    end

    private

    attr_reader :path, :comments, :includes, :writer
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
pragmater-7.2.0 lib/pragmater/runner.rb
pragmater-7.1.0 lib/pragmater/runner.rb
pragmater-7.0.1 lib/pragmater/runner.rb
pragmater-7.0.0 lib/pragmater/runner.rb
pragmater-6.3.3 lib/pragmater/runner.rb
pragmater-6.3.2 lib/pragmater/runner.rb
pragmater-6.3.1 lib/pragmater/runner.rb
pragmater-6.3.0 lib/pragmater/runner.rb
pragmater-6.2.1 lib/pragmater/runner.rb
pragmater-6.2.0 lib/pragmater/runner.rb
pragmater-6.1.0 lib/pragmater/runner.rb
pragmater-6.0.0 lib/pragmater/runner.rb