Function: ruby-flymake-simple

ruby-flymake-simple is a byte-compiled function defined in ruby-mode.el.gz.

Signature

(ruby-flymake-simple REPORT-FN &rest ARGS)

Documentation

ruby -wc backend for Flymake.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/ruby-mode.el.gz
(defun ruby-flymake-simple (report-fn &rest _args)
  "`ruby -wc' backend for Flymake."
  (unless (executable-find "ruby")
    (error "Cannot find the ruby executable"))

  (ruby-flymake--helper
   "ruby-flymake"
   '("ruby" "-w" "-c")
   (lambda (_proc source)
     (goto-char (point-min))
     (cl-loop
      while (search-forward-regexp
             "^\\(?:.*.rb\\|-\\):\\([0-9]+\\): \\(.*\\)$"
             nil t)
      for msg = (match-string 2)
      for (beg . end) = (flymake-diag-region
                         source
                         (string-to-number (match-string 1)))
      for type = (if (string-match "^warning" msg)
                     :warning
                   :error)
      collect (flymake-make-diagnostic source
                                       beg
                                       end
                                       type
                                       msg)
      into diags
      finally (funcall report-fn diags)))))