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-13.0.2 lib/pragmater/formatters/main.rb
pragmater-13.0.1 lib/pragmater/formatters/main.rb
pragmater-13.0.0 lib/pragmater/formatters/main.rb
pragmater-12.2.0 lib/pragmater/formatters/main.rb
pragmater-12.1.2 lib/pragmater/formatters/main.rb
pragmater-12.1.1 lib/pragmater/formatters/main.rb
pragmater-12.1.0 lib/pragmater/formatters/main.rb
pragmater-12.0.0 lib/pragmater/formatters/main.rb
pragmater-11.5.0 lib/pragmater/formatters/main.rb
pragmater-11.4.0 lib/pragmater/formatters/main.rb
pragmater-11.3.0 lib/pragmater/formatters/main.rb
pragmater-11.2.0 lib/pragmater/formatters/main.rb
pragmater-11.1.0 lib/pragmater/formatters/main.rb
pragmater-11.0.1 lib/pragmater/formatters/main.rb
pragmater-11.0.0 lib/pragmater/formatters/main.rb
pragmater-10.3.1 lib/pragmater/formatters/main.rb
pragmater-10.3.0 lib/pragmater/formatters/main.rb
pragmater-10.2.0 lib/pragmater/formatters/main.rb
pragmater-10.1.0 lib/pragmater/formatters/main.rb
pragmater-10.0.1 lib/pragmater/formatters/main.rb