2016-06-07 02:19:14 +00:00
|
|
|
|
;;; funcs.el --- Ruby Layer functions File
|
|
|
|
|
;;
|
|
|
|
|
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
|
|
|
|
|
;;
|
|
|
|
|
;; Author: Sylvain Benner <sylvain.benner@gmail.com>
|
|
|
|
|
;; URL: https://github.com/syl20bnr/spacemacs
|
|
|
|
|
;;
|
|
|
|
|
;; This file is not part of GNU Emacs.
|
|
|
|
|
;;
|
|
|
|
|
;;; License: GPLv3
|
|
|
|
|
|
2016-06-07 02:24:47 +00:00
|
|
|
|
|
|
|
|
|
;; rbenv
|
2016-06-07 02:52:19 +00:00
|
|
|
|
|
2016-06-07 02:24:47 +00:00
|
|
|
|
(defun spacemacs//enable-rbenv ()
|
|
|
|
|
"Enable rbenv, use .ruby-version if exists."
|
|
|
|
|
(require 'rbenv)
|
|
|
|
|
(let ((version-file-path (rbenv--locate-file ".ruby-version")))
|
|
|
|
|
(global-rbenv-mode)
|
|
|
|
|
;; try to use the ruby defined in .ruby-version
|
|
|
|
|
(if version-file-path
|
|
|
|
|
(progn
|
|
|
|
|
(rbenv-use (rbenv--read-version-from-file
|
|
|
|
|
version-file-path))
|
|
|
|
|
(message (concat "[rbenv] Using ruby version "
|
|
|
|
|
"from .ruby-version file.")))
|
|
|
|
|
(message "[rbenv] Using the currently activated ruby."))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; rspec
|
|
|
|
|
|
2016-06-07 02:52:19 +00:00
|
|
|
|
(defun spacemacs//ruby-enable-rspec-mode ()
|
|
|
|
|
"Conditionally enable `rspec-mode'"
|
|
|
|
|
(when (eq 'rspec ruby-test-runner)
|
|
|
|
|
(rspec-enable-appropriate-mode)))
|
|
|
|
|
|
2016-06-07 02:19:14 +00:00
|
|
|
|
(defun ruby/rspec-verify-directory (dir)
|
|
|
|
|
"Launch tests in DIR directory.
|
|
|
|
|
Called interactively it prompts for a directory."
|
|
|
|
|
(interactive "Drspec directory: ")
|
|
|
|
|
(rspec-run-single-file dir (rspec-core-options)))
|
2016-06-07 02:24:47 +00:00
|
|
|
|
|
2016-06-07 02:28:38 +00:00
|
|
|
|
(defun spacemacs//inf-ruby-auto-enter ()
|
|
|
|
|
"Automatically enters inf-ruby-mode in ruby modes' debugger breakpoints."
|
|
|
|
|
(add-hook 'compilation-filter-hook 'inf-ruby-auto-enter nil t))
|
|
|
|
|
|
2016-06-07 02:24:47 +00:00
|
|
|
|
|
|
|
|
|
;; ruby-test
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//ruby-enable-ruby-test-mode ()
|
|
|
|
|
"Conditionally enable `ruby-test-mode'"
|
|
|
|
|
(when (eq 'ruby-test ruby-test-runner)
|
|
|
|
|
(ruby-test-mode)))
|
2016-09-07 21:33:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;; minitest
|
|
|
|
|
|
|
|
|
|
(defun spacemacs//ruby-enable-minitest-mode ()
|
|
|
|
|
"Conditionally enable `minitest-mode'"
|
|
|
|
|
(when (eq 'minitest ruby-test-runner)
|
|
|
|
|
(minitest-enable-appropriate-mode)))
|