Sha256: 4d8a5e6a9ff6b900ee83a54831c4c9942fef551cde77afc6440abbe884f696bc

Contents?: true

Size: 639 Bytes

Versions: 41

Compression:

Stored size: 639 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  module Formatters
    # Formats all pragmas in a consistent manner.
    class Main
      FORMATTERS = [General, Shebang].freeze

      PATTERN = FORMATTERS.map { |formatter| formatter::PATTERN }
                          .then { |patterns| Regexp.union(*patterns) }
                          .freeze

      def initialize string, formatters: FORMATTERS
        @string = string
        @formatters = formatters
      end

      def call = formatters.reduce(string) { |pragma, formatter| formatter.new(pragma).call }

      private

      attr_reader :string, :formatters
    end
  end
end

Version data entries

41 entries across 41 versions & 1 rubygems

Version Path
pragmater-16.0.0 lib/pragmater/formatters/main.rb
pragmater-15.7.0 lib/pragmater/formatters/main.rb
pragmater-15.6.0 lib/pragmater/formatters/main.rb
pragmater-15.5.0 lib/pragmater/formatters/main.rb
pragmater-15.4.0 lib/pragmater/formatters/main.rb
pragmater-15.3.0 lib/pragmater/formatters/main.rb
pragmater-15.2.0 lib/pragmater/formatters/main.rb
pragmater-15.1.0 lib/pragmater/formatters/main.rb
pragmater-15.0.0 lib/pragmater/formatters/main.rb
pragmater-14.6.0 lib/pragmater/formatters/main.rb
pragmater-14.4.0 lib/pragmater/formatters/main.rb
pragmater-14.3.0 lib/pragmater/formatters/main.rb
pragmater-14.2.0 lib/pragmater/formatters/main.rb
pragmater-14.1.1 lib/pragmater/formatters/main.rb
pragmater-14.1.0 lib/pragmater/formatters/main.rb
pragmater-14.0.0 lib/pragmater/formatters/main.rb
pragmater-13.2.1 lib/pragmater/formatters/main.rb
pragmater-13.2.0 lib/pragmater/formatters/main.rb
pragmater-13.1.0 lib/pragmater/formatters/main.rb
pragmater-13.0.3 lib/pragmater/formatters/main.rb