<commit_before>import sublime, sublime_plugin, re

class ToggleRspecFocusCommand(sublime_plugin.TextCommand):
    def run(self, edit, surplus=False):
        for region in self.view.sel():
            line = self.view.line(region)
            line_contents = self.view.substr(line)

            focus_regex = r'(?:it|describe|context)\s(?:.+?)(?:\"|\')(\,\s\:focus)(.+)do'
            focus_match = re.search(focus_regex, line_contents)

            # If :focus is found, remove it
            if focus_match:
                line_without_focus = re.sub(focus_match.group(1), "", line_contents)
                self.view.replace(edit, line, line_without_focus)

            # Otherwise, add it
            else:
                vanilla_regex = r'(\s*(?:it|describe|context)\s+(?:\"[^\"]+\"|\'[^\']+\'))(\,?.+)do'
                vanilla_match = re.search(vanilla_regex, line_contents)

                line_with_focus = vanilla_match.group(1) + ", :focus" + vanilla_match.group(2) + "do"

                self.view.replace(edit, line, line_with_focus)<commit_msg>Handle constants<commit_after>import sublime, sublime_plugin, re

class ToggleRspecFocusCommand(sublime_plugin.TextCommand):
    def run(self, edit, surplus=False):
        for region in self.view.sel():
            line = self.view.line(region)
            line_contents = self.view.substr(line)

            focus_regex = r'.*(?:it|describe|context)\s+(?:\"[^\"]+\"|\'[^\']+\'|.+)(\,\s\:focus)(.+)do'
            focus_match = re.search(focus_regex, line_contents)

            # If :focus is found, remove it
            if focus_match:
                line_without_focus = re.sub(focus_match.group(1), "", line_contents)
                self.view.replace(edit, line, line_without_focus)

            # Otherwise, add it
            else:
                vanilla_regex = r'(.*(?:it|describe|context)\s+(?:\"[^\"]+\"|\'[^\']+\'|.+))(\,?.+)do'
                vanilla_match = re.search(vanilla_regex, line_contents)

                line_with_focus = vanilla_match.group(1) + ", :focus" + vanilla_match.group(2) + "do"

                self.view.replace(edit, line, line_with_focus)
{'fraction_non_alphanumeric': 0.1668219944082013, 'fraction_numerical': 0.0027958993476234857, 'mean_word_length': 2.3864353312302837, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3704328', 'n_tokens_mistral': 707, 'n_tokens_neox': 663, 'n_words': 108}