Sha256: 6070941298a94b00bbdd48e09435e253d6670ae68254e86190501717120b53ca

Contents?: true

Size: 652 Bytes

Versions: 8

Compression:

Stored size: 652 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module Cop
    # Common functionality for working with heredoc strings.
    module Heredoc
      OPENING_DELIMITER = /(<<[~-]?)['"`]?([^'"`]+)['"`]?/

      def on_str(node)
        return unless node.heredoc?

        on_heredoc(node)
      end
      alias on_dstr on_str
      alias on_xstr on_str

      def on_heredoc(_node)
        raise NotImplementedError
      end

      private

      def delimiter_string(node)
        node.source.match(OPENING_DELIMITER).captures[1]
      end

      def heredoc_type(node)
        node.source.match(OPENING_DELIMITER).captures[0]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
rubocop-0.59.2 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.59.1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.59.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.58.2 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.58.1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.58.0 lib/rubocop/cop/mixin/heredoc.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/rubocop-0.57.2/lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.57.2 lib/rubocop/cop/mixin/heredoc.rb