<commit_before># define ruby language

unless RBeautify::Language.language(:ruby)

  ruby = RBeautify::Language.add_language(:ruby)

  pre_keyword_boundary = '(^|[^a-z0-9A-Z:._])' # like \b but with : , . _ all added to list of exceptions
  start_statement_boundary = '(^|(;|=)\s*)'
  continue_statement_boundary = '(^|;\s*)'
  ruby.indent_size ||= 2

  ruby.add_matcher(:program_end, /^__END__$/, false, :format_content => false, :parse_content => false)

  ruby.add_matcher(:multiline_comment, /^=begin/, /^=end/, :format_content => false, :parse_content => false)

  ruby.add_matcher(:double_quote,
                   /"/,
                   /"/,
                   :parse_content => true,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  # NEED TO MODIFY DOUBLE QUOTE TO BE FORMATTED to get this to work
  ruby.add_matcher(:interpolation,
                   /#\{/,
                   /\}/,
                   :nest_only => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:single_quote,
                   /'/,
                   /'/,
                   :parse_content => false,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:regex,
                   /(^|((,|=|~)\s*))\//, # Try to distinguish it from division sign
                   /\//,
                   :format_content => false,
                   :escape_character => true,
                   :end_can_also_be_start => false,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:back_tick,
                   /`/,
                   /`/,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:percent,
                   /%\w\[/,
                   /\]/,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:standard,
                   /((#{start_statement_boundary}(module|class|def))|#{pre_keyword_boundary}do)\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:more,
                   /#{start_statement_boundary}(until|for|while)\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:begin,
                   /((#{start_statement_boundary}begin)|(#{continue_statement_boundary}(ensure|rescue)))\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure|else))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:if,
                   /((#{start_statement_boundary}(if|unless))|#{continue_statement_boundary}(then|elsif|else))\b/,
                   /(((^|;|\s)end)|(#{continue_statement_boundary}(then|elsif|else)))\b/,
                   :nest_except => [:case, :double_quote, :regex, :backtick])

  ruby.add_matcher(:case,
                   /#{pre_keyword_boundary}case\b/,<commit_msg>Don't match class with class:<commit_after># define ruby language

unless RBeautify::Language.language(:ruby)

  ruby = RBeautify::Language.add_language(:ruby)

  pre_keyword_boundary = '(^|[^a-z0-9A-Z:._])' # like \b but with : , . _ all added to list of exceptions
  start_statement_boundary = '(^|(;|=)\s*)'
  continue_statement_boundary = '(^|;\s*)'
  ruby.indent_size ||= 2

  ruby.add_matcher(:program_end, /^__END__$/, false, :format_content => false, :parse_content => false)

  ruby.add_matcher(:multiline_comment, /^=begin/, /^=end/, :format_content => false, :parse_content => false)

  ruby.add_matcher(:double_quote,
                   /"/,
                   /"/,
                   :parse_content => true,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  # NEED TO MODIFY DOUBLE QUOTE TO BE FORMATTED to get this to work
  ruby.add_matcher(:interpolation,
                   /#\{/,
                   /\}/,
                   :nest_only => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:single_quote,
                   /'/,
                   /'/,
                   :parse_content => false,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:regex,
                   /(^|((,|=|~)\s*))\//, # Try to distinguish it from division sign
                   /\//,
                   :format_content => false,
                   :escape_character => true,
                   :end_can_also_be_start => false,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:back_tick,
                   /`/,
                   /`/,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:percent,
                   /%\w\[/,
                   /\]/,
                   :format_content => false,
                   :escape_character => true,
                   :nest_except => [:double_quote, :single_quote, :regex, :back_tick, :percent])

  ruby.add_matcher(:standard,
                   /((#{start_statement_boundary}(module|class(?!:)|def))|#{pre_keyword_boundary}do)\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:more,
                   /#{start_statement_boundary}(until|for|while)\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:begin,
                   /((#{start_statement_boundary}begin)|(#{continue_statement_boundary}(ensure|rescue)))\b/,
                   /(((^|;|\s)end)|#{continue_statement_boundary}(rescue|ensure|else))\b/,
                   :nest_except => [:double_quote, :regex, :backtick])

  ruby.add_matcher(:if,
                   /((#{start_statement_boundary}(if|unless))|#{continue_statement_boundary}(then|elsif|else))\b/,
                   /(((^|;|\s)end)|(#{continue_statement_boundary}(then|elsif|else)))\b/,
                   :nest_except => [:case, :double_quote, :regex, :backtick])

  ruby.add_matcher(:case,
                   /#{pre_keyword_boundary}case\b/,
{'fraction_non_alphanumeric': 0.16222625191798018, 'fraction_numerical': 0.0008369368112707491, 'mean_word_length': 2.0012557555462536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 57, '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': '333114', 'n_tokens_mistral': 2333, 'n_tokens_neox': 2093, 'n_words': 321}