Sha256: f95a9a3bfcf78a786863e595bcf96bd79d20a59f02f1f9d2601e065a43050f34
Contents?: true
Size: 527 Bytes
Versions: 4
Compression:
Stored size: 527 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).freeze 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
4 entries across 4 versions & 1 rubygems