spacemacs/layers/+lang/ruby
Muneeb Shaikh 4ce11551ec Fixed undefined (ruby-)mode which key prefix declaration
* layers/+lang/ruby/config.el (ruby-mode): Fix
2015-11-27 12:33:40 +05:30
..
img Use + instead of ! for layer categories 2015-09-11 00:13:51 -04:00
README.org ruby: replace ruby-use-ruby-test by ruby-test-runner 2015-11-27 00:28:38 -05:00
config.el Fixed undefined (ruby-)mode which key prefix declaration 2015-11-27 12:33:40 +05:30
packages.el ruby: replace ruby-use-ruby-test by ruby-test-runner 2015-11-27 00:28:38 -05:00

README.org

Ruby contribution layer for Spacemacs

/TakeV/spacemacs/media/commit/2d17a08138d9fdab01ae8bfbbaabffa7be6a40d7/layers/+lang/ruby/img/ruby.png

Description

This layer provides support for the Ruby language with enh-ruby-mode and robe-mode. Optionally Enh Ruby Mode can be replaced with the built-in Emacs Ruby Mode.

Install

To use this contribution add it to your ~/.spacemacs

  (setq-default dotspacemacs-configuration-layers '(ruby))

This layer supports two different Ruby modes: Emacs' built-in Ruby Mode and enh-ruby-mode. By default the built-in Ruby mode is enabled. To switch to the enh-ruby-mode set ruby-enable-enh-ruby-mode to t:

  (defun dotspacemacs-configuration-layers ()
     '((ruby :variables ruby-enable-enh-ruby-mode t)))

Prerequisites

Some of the advanced features supported by this layer depend on external gems that need to be installed in the context of your project (see below for guidance based on your version manager):

  • pry and pry-doc are required for jump to definition and code documentation (robe-mode)
  • ruby_parser is required for goto-step_definition in feature-mode
  • rubocop is required for rubocop integration

You can install the gems in the context of your current project by adding them to the Gemfile, e.g.:

  gem 'pry'

or on the command line (please refer to your ruby version manager specific documentation for details and caveats):

  gem install pry

Ruby version management

This layer supports the use of RVM and Rbenv. To enable it, set the ruby-version-manager var in your ~/.spacemacs:

  (defun dotspacemacs-configuration-layers ()
     '((ruby :variables ruby-version-manager 'rbenv)))

Possible values are rbenv and rvm.

Test runner

This layer supports both RSpec and ruby-test test runners (frameworks). By default ruby-test is used, to change to another frameworks set the layer variable ruby-test-runner.

Example to set the test runner to RSpec:

  (defun dotspacemacs-configuration-layers ()
     '((ruby :variables ruby-test-runner 'rspec)))

Tip: You can enable different test runners for different projects by using directory local variables.

Key bindings

Ruby (enh-ruby-mode, robe, inf-ruby, ruby-tools)

Key binding Description
SPC m ' toggle quotes of current string (only built-in mode)
SPC m { toggle style of current block (only built-in mode)
SPC m g g go to definition (robe-jump)
SPC m h d go to Documentation
SPC m s f send function definition
SPC m s F send function definition and switch to REPL
SPC m s i start REPL
SPC m s r send region
SPC m s R send region and switch to REPL
SPC m s s switch to REPL
SPC m x ' Change symbol or " string to '
SPC m x " Change symbol or ' string to "
SPC m x : Change string to symbol
% evil-matchit jumps between blocks

RuboCop

Key binding Description
SPC m r r f Runs RuboCop on the currently visited file
SPC m r r F Runs auto-correct on the currently visited file
SPC m r r d Prompts from a directory on which to run RuboCop
SPC m r r D Prompts for a directory on which to run auto-correct
SPC m r r p Runs RuboCop on the entire project
SPC m r r P Runs auto-correct on the project

Tests

RSpec-mode

When ruby-test-runner equals rspec.

Key binding Description
SPC m t a run all specs
SPC m t l run last failed spec
SPC m t r re-run last spec
SPC m t t run spec at pointer

Ruby-test-mode

When ruby-test-runner equals ruby-test.

Key binding Description
SPC m t b run test file
SPC m t t run test at pointer