<commit_before>;;; module-ruby.el

;; Silence the byte-compiler
(eval-when-compile (require 'defuns-quickrun))

(use-package ruby-mode
  :mode ("\\.r[bu]$" "\\.rake$" "\\.gemspec$" "\\.?pryrc$"
         "/\\(Gem\\|Cap\\|Vagrant\\|Rake\\)file$")
  :interpreter "ruby"
  :init
  (add-hook! ruby-mode 'narf|enable-tab-width-2)
  (build-for! ruby-mode "rake %s" "Rakefile")
  :config
  ;; Formatting
  (setq ruby-indent-level      2
        ruby-deep-indent-paren t)

  ;; Don't interfere with my custom RET behavior
  (define-key ruby-mode-map [?\n] nil)

  ;; Rakefiles ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (define-minor-mode rake-mode
    "Buffer local minor mode for rake files"
    :lighter " Rake" :keymap (make-sparse-keymap)
    (add-yas-minor-mode! 'rake-mode))
  (associate! rake-mode :match "\\(/Rakefile\\|\\.rake\\)$")

  ;; Vagrantfiles ;;;;;;;;;;;;;;;;;;;;;;;;
  (define-minor-mode vagrant-mode
    "Buffer local minor mode for vagrant files"
    :lighter " Va" :keymap (make-sparse-keymap)
    (add-yas-minor-mode! 'vagrant-mode))
  (associate! vagrant-mode :match "/Vagrantfile$"))

(use-package rspec-mode
  :defer t
  :mode ("/\\.rspec$" . text-mode)
  :init
  (associate! rspec-mode :match "\\(/spec_helper\\|_spec\\)\\.rb$")
  (associate! rspec-mode :match "/\\.rspec$")

  (defvar rspec-mode-verifiable-map (make-sparse-keymap))
  (defvar evilmi-ruby-match-tags
    '((("unless" "if") ("elsif" "else") "end")
      ("begin" ("rescue" "ensure") "end")
      ("case" ("when" "else") "end")
      (("class" "def" "while" "do" "module" "for" "until") () "end")
      ;; Rake
      (("task" "namespace") () "end")))
  :config
  (bind! (:prefix ","
           :n "tr" 'rspec-rerun
           :n "ta" 'rspec-verify-all
           :n "ts" 'rspec-verify-single
           :n "tv" 'rspec-verify)))

(use-package inf-ruby
  :commands (inf-ruby inf-ruby-console-auto)
  :config
  (evil-set-initial-state 'inf-ruby-mode 'insert)
  (after! company
    (require 'company-inf-ruby)
    (add-company-backend! inf-ruby-mode (inf-ruby))))

(use-package robe
  :commands (robe-mode robe-start ruby-load-file)
  :init
  (add-hook! after-save 'narf|ruby-load-file)
  (add-hook! ruby-mode 'narf|enable-robe-maybe)
  :config
  (after! company
    (require 'company-robe)
    (add-company-backend! ruby-mode (robe))))

(use-package ruby-refactor
  :after emr
  :init (add-hook! ruby-mode 'emr-initialize)
  :config
  (mapc (lambda (x)
          (let ((command-name (car x))
                (title (cadr x))
                (region-p (caddr x))
                predicate)
            (setq predicate (cond ((eq region-p 'both) nil)
                                  (t (if region-p
                                         (lambda () (use-region-p))
                                       (lambda () (not (use-region-p)))))))
            (emr-declare-command (intern (format "ruby-%s" (symbol-name command-name)))
              :title title :modes 'ruby-mode :predicate predicate)))
        '((toggle-block                     "toggle block"            nil)
          (refactor-extract-to-method       "extract method"          t)
          (refactor-extract-local-variable  "extract local variable"  t)
          (refactor-extract-constant        "extract constant"        t)
          (refactor-add-parameter           "add parameter"           nil)
          (refactor-extract-to-let          "extract to let"          t))))

(provide 'module-ruby)
;;; module-ruby.el ends here
<commit_msg>ruby-mode: adjust file ext regex<commit_after>;;; module-ruby.el

;; Silence the byte-compiler
(eval-when-compile (require 'defuns-quickrun))

(use-package ruby-mode
  :mode ("\\.rb$" "\\.rake$" "\\.gemspec$" "\\.?pryrc$"
         "/\\(Gem\\|Cap\\|Vagrant\\|Rake\\)file$")
  :interpreter "ruby"
  :init
  (add-hook! ruby-mode 'narf|enable-tab-width-2)
  (build-for! ruby-mode "rake %s" "Rakefile")
  :config
  ;; Formatting
  (setq ruby-indent-level      2
        ruby-deep-indent-paren t)

  ;; Don't interfere with my custom RET behavior
  (define-key ruby-mode-map [?\n] nil)

  ;; Rakefiles ;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (define-minor-mode rake-mode
    "Buffer local minor mode for rake files"
    :lighter " Rake" :keymap (make-sparse-keymap)
    (add-yas-minor-mode! 'rake-mode))
  (associate! rake-mode :match "\\(/Rakefile\\|\\.rake\\)$")

  ;; Vagrantfiles ;;;;;;;;;;;;;;;;;;;;;;;;
  (define-minor-mode vagrant-mode
    "Buffer local minor mode for vagrant files"
    :lighter " Va" :keymap (make-sparse-keymap)
    (add-yas-minor-mode! 'vagrant-mode))
  (associate! vagrant-mode :match "/Vagrantfile$"))

(use-package rspec-mode
  :defer t
  :mode ("/\\.rspec$" . text-mode)
  :init
  (associate! rspec-mode :match "\\(/spec_helper\\|_spec\\)\\.rb$")
  (associate! rspec-mode :match "/\\.rspec$")

  (defvar rspec-mode-verifiable-map (make-sparse-keymap))
  (defvar evilmi-ruby-match-tags
    '((("unless" "if") ("elsif" "else") "end")
      ("begin" ("rescue" "ensure") "end")
      ("case" ("when" "else") "end")
      (("class" "def" "while" "do" "module" "for" "until") () "end")
      ;; Rake
      (("task" "namespace") () "end")))
  :config
  (bind! (:prefix ","
           :n "tr" 'rspec-rerun
           :n "ta" 'rspec-verify-all
           :n "ts" 'rspec-verify-single
           :n "tv" 'rspec-verify)))

(use-package inf-ruby
  :commands (inf-ruby inf-ruby-console-auto)
  :config
  (evil-set-initial-state 'inf-ruby-mode 'insert)
  (after! company
    (require 'company-inf-ruby)
    (add-company-backend! inf-ruby-mode (inf-ruby))))

(use-package robe
  :commands (robe-mode robe-start ruby-load-file)
  :init
  (add-hook! after-save 'narf|ruby-load-file)
  (add-hook! ruby-mode 'narf|enable-robe-maybe)
  :config
  (after! company
    (require 'company-robe)
    (add-company-backend! ruby-mode (robe))))

(use-package ruby-refactor
  :after emr
  :init (add-hook! ruby-mode 'emr-initialize)
  :config
  (mapc (lambda (x)
          (let ((command-name (car x))
                (title (cadr x))
                (region-p (caddr x))
                predicate)
            (setq predicate (cond ((eq region-p 'both) nil)
                                  (t (if region-p
                                         (lambda () (use-region-p))
                                       (lambda () (not (use-region-p)))))))
            (emr-declare-command (intern (format "ruby-%s" (symbol-name command-name)))
              :title title :modes 'ruby-mode :predicate predicate)))
        '((toggle-block                     "toggle block"            nil)
          (refactor-extract-to-method       "extract method"          t)
          (refactor-extract-local-variable  "extract local variable"  t)
          (refactor-extract-constant        "extract constant"        t)
          (refactor-add-parameter           "add parameter"           nil)
          (refactor-extract-to-let          "extract to let"          t))))

(provide 'module-ruby)
;;; module-ruby.el ends here

{'fraction_non_alphanumeric': 0.18674698795180722, 'fraction_numerical': 0.0005737234652897303, 'mean_word_length': 2.2645131086142323, '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': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4189822', 'n_tokens_mistral': 2549, 'n_tokens_neox': 2401, 'n_words': 532}