ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Simple Rails Navigator

by noklesta ST2

Sublime Text 2 plugin for navigating Ruby on Rails applications

Details

  • 2013.04.25.13.08.09
  • github.​com
  • github.​com
  • 12 years ago
  • 2 hours ago
  • 13 years ago

Installs

  • Total 10K
  • Win 2K
  • Mac 5K
  • Linux 3K
Dec 14 Dec 13 Dec 12 Dec 11 Dec 10 Dec 9 Dec 8 Dec 7 Dec 6 Dec 5 Dec 4 Dec 3 Dec 2 Dec 1 Nov 30 Nov 29 Nov 28 Nov 27 Nov 26 Nov 25 Nov 24 Nov 23 Nov 22 Nov 21 Nov 20 Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31
Windows 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mac 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Linux 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Readme

Source
raw.​githubusercontent.​com

Sublime Text 2 plugin: Simple Rails Navigator

Simple plugin for navigating Ruby on Rails applications.


NOTE: The master branch is not compatible with Sublime Text 3, but there is now a separate ST3 branch (thanks @doz!) that works with ST3 (and is incompatible with ST2). Until Package Control for ST3 is ready, the ST3 version can be installed by cloning the GitHub repo (see Clone from GitHub below) and running git checkout ST3.


This plugin provides commands for listing models, controllers, views, helpers, fixtures, tests/specs, javascript files, or stylesheets in a quick panel for easy selection.

Related files are located at the top of the list so that they can be selected simply by pressing Enter. For instance, if the active view is a Rails model and you request a list of controllers, the controller corresponding to the model will be listed at the top, provided that you follow normal Rails resource conventions with the controller name containing the pluralized version of the model name (e.g. post.rb and posts_controller.rb).

The same goes for tests or specs (in the example case, the test file should be called test/unit/post_test.rb or spec/models/post_spec.rb). If the application contains a spec directory, the plugin will search for specs and ignore the test directory; otherwise the test directory will be used.

The following table shows which related files will be put at the top of the list:

Active file Listing these file types will show related files at the top of the list
model controller; fixture; model unit test/model spec
controller model; views; helper; functional test/controller spec
view controller; functional test/view spec
helper controller; helper unit test/helper spec
fixture model; model unit test/model spec; functional test/controller spec
model unit test/model spec model; fixture
functional test controller; views; fixture
controller spec controller; fixture
view spec view
helper unit test/helper spec helper
routes.rb route specs

This plugin was inspired by Luqman Amjad's Rails Related Files plugin. The plugins have complementary functionality (Amjad's plugin shows related files of all types in a single list), and they can be used together.

Installation

Package Control

The easiest way to install this is with Package Control.

  • If you just went and installed Package Control, you probably need to restart Sublime Text 2 before doing this next bit.
  • Bring up the Command Palette (Command+Shift+p on OS X, Control+Shift+p on Linux/Windows).
  • Select “Package Control: Install Package” (it'll take a few seconds)
  • Select Simple Rails Navigator when the list appears.

Package Control will automatically keep the Simple Rails Navigator up to date with the latest version.

Clone from GitHub

Alternatively, you can clone the repository directly from GitHub into your Packages directory:

git clone http://github.com/noklesta/SublimeRailsNav

Key bindings

The plugin does not install any key bindings automatically. The following is an example of how you can set up your own key bindings. To make sure they don't conflict with existing commands, first run sublime.log_commands(True) in the console, try out the key combinations and see if anything is logged.

{ "keys": ["super+ctrl+m"], "command": "list_rails_models" },
{ "keys": ["super+ctrl+c"], "command": "list_rails_controllers" },
{ "keys": ["super+ctrl+v"], "command": "list_rails_views" },
{ "keys": ["super+ctrl+h"], "command": "list_rails_helpers" },
{ "keys": ["super+ctrl+x"], "command": "list_rails_fixtures" },
{ "keys": ["super+ctrl+t"], "command": "list_rails_tests" },
{ "keys": ["super+ctrl+i"], "command": "list_rails_javascripts" },
{ "keys": ["super+ctrl+y"], "command": "list_rails_stylesheets" }

If you are using Vintage mode and want to use sequences of non-modifier keys, you can restrict the key bindings to command mode like this:

{ "keys": [" ", "m"], "command": "list_rails_models", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "c"], "command": "list_rails_controllers", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "v"], "command": "list_rails_views", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "h"], "command": "list_rails_helpers", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "x"], "command": "list_rails_fixtures", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "t"], "command": "list_rails_tests", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "i"], "command": "list_rails_javascripts", "context": [{"key": "setting.command_mode"}] },
{ "keys": [" ", "y"], "command": "list_rails_stylesheets", "context": [{"key": "setting.command_mode"}] }

All commands are also available from the Command Palette (search for commands beginning with “Simple Rails Navigator”).

Settings

The settings in SublimeRailsNav.sublime-settings may be overridden either in Packages/User/SublimeRailsNav.sublime-settings or, for a particular project, in the project file under a top-level “settings” key. An example of the latter:

"settings":
{
  "SublimeRailsNav":
  {
    "javascript_locations": [
      ["app", "assets", "javascripts"]
    ],
    "stylesheet_locations": [
      ["app", "assets", "stylesheets"],
      ["lib", "assets", "stylesheets"]
    ]
  }
}

Credits

  • Inspiration from Luqman Amjad's Rails Related Files plugin for ST2 and from Tim Pope's rails.vim plugin for Vim (which contains sooo much more functionality than this one, of course :-)
  • Python version of the Rails inflector: https://bitbucket.org/ixmatus/inflector
  • Contains a modified version of a small code snippet from the Git package for ST2.

Licence

All of SublimeRailsNav is licensed under the MIT licence.

Copyright © 2012 Anders Nøklestad

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.