Sha256: 59e3360107fe069c31575ca1985641d35a1324c4b7f2645947529d24186c4ceb

Contents?: true

Size: 659 Bytes

Versions: 6991

Compression:

Stored size: 659 Bytes

Contents

# frozen_string_literal: true

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

      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

6,991 entries across 6,965 versions & 32 rubygems

Version Path
rbhint-0.8.5.rc1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.85.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.84.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.83.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.82.0 lib/rubocop/cop/mixin/heredoc.rb
talon_one-2.0.0 vendor/bundle/ruby/2.7.0/gems/rubocop-0.66.0/lib/rubocop/cop/mixin/heredoc.rb
talon_one-2.0.0 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.81.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.80.1 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.80.0 lib/rubocop/cop/mixin/heredoc.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/rubocop-0.79.0/lib/rubocop/cop/mixin/heredoc.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.6.0/gems/rubocop-0.79.0/lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.79.0 lib/rubocop/cop/mixin/heredoc.rb
rubocop-0.78.0 lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.77.0/lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/cop/mixin/heredoc.rb
zuora_connect_ui-0.10.0 vendor/ruby/2.6.0/gems/rubocop-0.76.0/lib/rubocop/cop/mixin/heredoc.rb