<commit_before>module Unparser
  class Emitter
    class Literal

      # Emitter for dynamic bodies
      class DynamicBody < self

        OPEN = '#{'.freeze
        CLOSE = '}'.freeze

        # Emitter for interpolated nodes
        class Interpolation < self

          handle :interpolated

          children :subject

        private

          # Perform dispatch
          #
          # @return [undefined]
          #
          # @api private
          #
          def dispatch
            write(OPEN)
            visit(subject)
            write(CLOSE)
          end

        end

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          children.each do |node|
            emit_segment(node)
          end
        end

        # Emit segment
        #
        # @param [Parser::Node] node
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_segment(node)
          if node.type == :str
            emit_str_segment(node)
            return
          end
          emit_interpolated_segment(node)
        end

        ESCAPES = ::Hash[Parser::Lexer::ESCAPES.invert.map do |key, value|
          [key, "\\#{value}"]
        end.reject { |key, value| key == ' '}].freeze

        REPLACEMENTS = ::Regexp.union(ESCAPES.keys)

        # Emit str segment
        #
        # @param [Parser::Node] node
        #
        # @return [undefined]<commit_msg>Cleanup multiline block chain<commit_after>module Unparser
  class Emitter
    class Literal

      # Emitter for dynamic bodies
      class DynamicBody < self

        OPEN = '#{'.freeze
        CLOSE = '}'.freeze

        # Emitter for interpolated nodes
        class Interpolation < self

          handle :interpolated

          children :subject

        private

          # Perform dispatch
          #
          # @return [undefined]
          #
          # @api private
          #
          def dispatch
            write(OPEN)
            visit(subject)
            write(CLOSE)
          end

        end

      private

        # Perform dispatch
        #
        # @return [undefined]
        #
        # @api private
        #
        def dispatch
          children.each do |node|
            emit_segment(node)
          end
        end

        # Emit segment
        #
        # @param [Parser::Node] node
        #
        # @return [undefined]
        #
        # @api private
        #
        def emit_segment(node)
          if node.type == :str
            emit_str_segment(node)
            return
          end
          emit_interpolated_segment(node)
        end

        pairs = Parser::Lexer::ESCAPES.invert.map do |key, value|
          [key, "\\#{value}"] unless key == WS
        end.compact

        ESCAPES = ::Hash[pairs]

        REPLACEMENTS = ::Regexp.union(ESCAPES.keys)

        # Emit str segment
        #
        # @param [Parser::Node] node
        #
        # @return [undefined]
{'fraction_non_alphanumeric': 0.08533772652388798, 'fraction_numerical': 0.0, 'mean_word_length': 1.238938053097345, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1551437', 'n_tokens_mistral': 869, 'n_tokens_neox': 815, 'n_words': 199}