Sha256: 1837bc1ed69d32b0e72442b3eea891e7b17638751dc2c17f9d400e6f7b2d78be

Contents?: true

Size: 520 Bytes

Versions: 47

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

module Pragmater
  module Formatters
    # Formats shebang pragmas in a consistent manner.
    class Shebang
      PATTERN = %r(\A\#!\s?/.*ruby\Z)

      def initialize string, pattern: PATTERN
        @string = string
        @pattern = pattern
      end

      def call
        return string unless string.match? pattern

        string.split("!").then { |octothorpe, path| "#{octothorpe}! #{path.strip}" }
      end

      private

      attr_reader :string, :pattern
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

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