Sha256: c1e57b6701855078902c5975134e094dda4f54e30394482817d97b6d209afe95

Contents?: true

Size: 588 Bytes

Versions: 4

Compression:

Stored size: 588 Bytes

Contents

module Ahnnotate
  module Function
    class StripSchema
      attr_reader :comment

      def initialize(comment:)
        @comment = comment
      end

      def call(content)
        matches = pattern.match(content)

        if matches
          matches["post"]
        else
          content
        end
      end

      private

      def pattern
        @pattern ||=
          begin
            newline = /\r?\n\r?/

            /\A#{comment}\s==\sSchema\sInfo(?:rmation)?#{newline}?(?:^#{comment}[^\n]*$#{newline})*#{newline}(?<post>.*)/m
          end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ahnnotate-0.5.1 lib/ahnnotate/function/strip_schema.rb
ahnnotate-0.5.0 lib/ahnnotate/function/strip_schema.rb
ahnnotate-0.4.0 lib/ahnnotate/function/strip_schema.rb
ahnnotate-0.3.0 lib/ahnnotate/function/strip_schema.rb