hmatsuda / rails-transporter Goto Github PK
View Code? Open in Web Editor NEWAtomEditor package that to open related Rails files on current context
Home Page: https://atom.io/packages/rails-transporter
License: MIT License
AtomEditor package that to open related Rails files on current context
Home Page: https://atom.io/packages/rails-transporter
License: MIT License
I have a model called QueryDoc.rb, which links to a controller called query_doc_controller.rb.
Expected behavior #1:
From QueryDoc.rb, type 'Ctrl-r, c'. Expect to reach query_doc_controller.rb.
Expected behavior #2:
After #1 fails the first time, I specify that I wanted query_doc_controller.rb manually. In subsequent rounds, expect QueryDoc.rb 'Ctrl-r, c' to go to query_doc_controller.rb. It asks again because it didn't remember the custom path from the first attempt.
It would be really great if rails-transporter could implement #1, or failing that, #2. Thanks!
Hi, any idea why Transporter can't find app/views/error_mailer/outside_outlines.text.erb
?
I set my View File Extension to: html.erb, text.erb, html.slim, html.haml
Then I navigate to my mailer's action and ask Transporter to navigate to the view. Transporter claims "no target file found" and suggests app/views/error_mailer/outside_outlines.html.erb
.
I change the html
to text
and hit return. The file opens! Shouldn't Transporter have found it?
This gif might illustrate what I'm doing.
If editing app/models/foo.rb
, what about if Open Factory checked for either spec/factories/foo.rb
or spec/factories/foos.rb
- Singluar/pluraziation of those files seems a lot less consistent across a lot of projects I've come on that models/etc..
rails-transporter:open-model
looks for models under the same namespace as the view or controller. It does not find models that are not in the same namespace as the controller or view.
For example, I have a controller app/controllers/admin/members_controller.rb. My model is in app/models/member.rb. Launching rails-transporter:open-model
does not find the model, but instead brings up a dialog like the following:
Like this Sublime package behavior.
https://sublime.wbond.net/packages/Rails%20Migrations%20List
[Enter steps to reproduce below:]
Crashes every time.
Switching between model and spec, or controller and views, works just fine.
Atom Version: 1.3.3
System: Mac OS X 10.11.2
Thrown From: rails-transporter package, v1.6.0
Uncaught TypeError: Cannot read property 'split' of undefined
At /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:803
TypeError: Cannot read property 'split' of undefined
at Function.module.exports.Range.fromText (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/range.js:47:19)
at TextBuffer.module.exports.TextBuffer.setTextInRange (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:562:24)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:550:26
at TextBuffer.module.exports.TextBuffer.transact (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:798:18)
at TextBuffer.module.exports.TextBuffer.setTextInRange (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:548:21)
at TextBuffer.module.exports.TextBuffer.setText (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:488:19)
at TextEditor.module.exports.TextEditor.setText (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/text-editor.js:752:26)
at TextEditorView.module.exports.TextEditorView.setText (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/text-editor-view.js:56:25)
at DialogView.module.exports.DialogView.setTargetFile (/Users/bronson/.atom/packages/rails-transporter/lib/dialog-view.coffee:43:17)
at DialogView.setTargetFile (/Users/bronson/.atom/packages/rails-transporter/lib/dialog-view.coffee:1:1)
at FileOpener.module.exports.FileOpener.openDialog (/Users/bronson/.atom/packages/rails-transporter/lib/file-opener.coffee:296:17)
at FileOpener.module.exports.FileOpener.openController (/Users/bronson/.atom/packages/rails-transporter/lib/file-opener.coffee:76:8)
at atom-workspace.atom.commands.add.rails-transporter:open-controller (/Users/bronson/.atom/packages/rails-transporter/lib/rails-transporter.coffee:42:29)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
at CommandPaletteView.module.exports.CommandPaletteView.confirmed (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/command-palette/lib/command-palette-view.js:183:32)
at CommandPaletteView.module.exports.SelectListView.confirmSelection (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:338:21)
at space-pen-div.atom.commands.add.core:confirm (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-space-pen-views/lib/select-list-view.js:109:19)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:260:29)
at /opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/command-registry.js:3:61
at KeymapManager.module.exports.KeymapManager.dispatchCommandEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:536:16)
at KeymapManager.module.exports.KeymapManager.handleKeyboardEvent (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/node_modules/atom-keymap/lib/keymap-manager.js:359:22)
at WindowEventHandler.module.exports.WindowEventHandler.handleDocumentKeydown (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:97:36)
at HTMLDocument.<anonymous> (/opt/homebrew-cask/Caskroom/atom/latest/Atom.app/Contents/Resources/app.asar/src/window-event-handler.js:3:61)
2x -0:20.7.0 vim-mode-plus:move-down (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:12.9.0 command-palette:toggle (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:12.7.0 blur (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:10.2.0 editor:consolidate-selections (atom-text-editor.editor.mini.is-focused)
-0:10.2.0 core:cancel (atom-text-editor.editor.mini.is-focused)
-0:10.2.0 blur (atom-text-editor.editor.mini.is-focused)
-0:09.7.0 fuzzy-finder:toggle-file-finder (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:09.6.0 blur (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:06.9.0 core:move-down (atom-text-editor.editor.mini.is-focused)
-0:05.7.0 core:confirm (atom-text-editor.editor.mini.is-focused)
4x -0:05.7.0 blur (atom-text-editor.editor.mini.is-focused)
-0:02.5.0 command-palette:toggle (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:02.3.0 blur (atom-text-editor.editor.vim-mode-plus.normal-mode.is-focused)
-0:01.0 core:confirm (atom-text-editor.editor.mini.is-focused)
-0:01.0 blur (atom-text-editor.editor.mini.is-focused)
-0:01.0 rails-transporter:open-controller (atom-text-editor.editor.vim-mode-plus.normal-mode)
{
"core": {
"disabledPackages": [
"metrics",
"exception-reporting",
"welcome",
"background-tips"
],
"themes": [
"one-dark-ui",
"oceanic-reef-syntax"
],
"audioBeep": false,
"packagesWithKeymapsDisabled": [
"rspec",
"ruby-test-switcher",
"rails-transporter"
]
},
"rails-transporter": {}
}
# User
cursor-history, v0.5.9
file-icons, v1.6.13
linter, v1.11.3
linter-eslint, v5.2.7
linter-haml, v1.1.0
linter-ruby, v1.2.1
linter-tidy, v1.0.1
rails-transporter, v1.6.0
react, v0.12.10
ruby-test-switcher, v1.2.0
vim-mode-plus, v0.14.1
white-cursor, v0.6.0
# Dev
No dev packages
xUncaught TypeError: Cannot read property 'getPath' of undefined
Atom Version: 0.157.0
System: linux 3.13.0-43-generic
Thrown From: rails-transporter package, v0.7.0
At /home/likewise-open/ZANECDEV1/karthikeyan.ak/.atom/packages/rails-transporter/lib/file-opener.coffee:174
TypeError: Cannot read property 'getPath' of undefined
at FileOpener.module.exports.FileOpener.reloadCurrentEditor (/home/likewise-open/ZANECDEV1/karthikeyan.ak/.atom/packages/rails-transporter/lib/file-opener.coffee:174:27)
at FileOpener.module.exports.FileOpener.openModel (/home/likewise-open/ZANECDEV1/karthikeyan.ak/.atom/packages/rails-transporter/lib/file-opener.coffee:62:6)
at atom-workspace.<anonymous> (/home/likewise-open/ZANECDEV1/karthikeyan.ak/.atom/packages/rails-transporter/lib/rails-transporter.coffee:18:27)
at atom-workspace.handler (/opt/atom/resources/app/src/space-pen-extensions.js:115:32)
at atom-workspace.jQuery.event.dispatch (/opt/atom/resources/app/node_modules/space-pen/vendor/jquery.js:4681:9)
at atom-workspace.elemData.handle (/opt/atom/resources/app/node_modules/space-pen/vendor/jquery.js:4359:46)
at CommandRegistry.module.exports.CommandRegistry.handleCommandEvent (/opt/atom/resources/app/src/command-registry.js:243:29)
at CommandRegistry.handleCommandEvent (/opt/atom/resources/app/src/command-registry.js:3:61)
at CommandRegistry.module.exports.CommandRegistry.dispatch (/opt/atom/resources/app/src/command-registry.js:156:19)
at Ipc.<anonymous> (/opt/atom/resources/app/src/window-event-handler.js:65:30)
at Ipc.emit (events.js:107:17)
at process.<anonymous> (/opt/atom/resources/atom/renderer/api/lib/ipc.js:22:29)
at process.emit (events.js:110:17)
/cc @atom/core
I almost always want to open the most recent migration. Even if not, it'll probably be one of the last two or three.
Would it be easy to sort the migrations in reverse order so the most recent ones are right at the top?
ctrl-r
is by default taken by symbols-view:toggle-file-symbols
.
After installing this extension going to symbol dialog is slowed down (waiting for keystrokes from this extension for a second).
My suggestion is to change ctrl-r
to ctrl-t
.
ctr-t
is taken by fuzzy-finder:toggle-file-finder
, but this is also mapped to ctrl-p
which most people use (imho).
As a quick workaround for this issue put this in your ~/.atom/keymap.cson
'.platform-linux':
'ctrl-t': 'unset!'
'atom-workspace':
'ctrl-r c': 'unset!'
'ctrl-r v f': 'unset!'
'ctrl-r v': 'unset!'
'ctrl-r l': 'unset!'
'ctrl-r m': 'unset!'
'ctrl-r h': 'unset!'
'ctrl-r s': 'unset!'
'ctrl-r p': 'unset!'
'ctrl-r a': 'unset!'
'ctrl-r d m': 'unset!'
'ctrl-r f': 'unset!'
'ctrl-t c': 'rails-transporter:open-controller'
'ctrl-t v f': 'rails-transporter:open-view-finder'
'ctrl-t v': 'rails-transporter:open-view'
'ctrl-t l': 'rails-transporter:open-layout'
'ctrl-t m': 'rails-transporter:open-model'
'ctrl-t h': 'rails-transporter:open-helper'
'ctrl-t s': 'rails-transporter:open-spec'
'ctrl-t p': 'rails-transporter:open-partial-template'
'ctrl-t a': 'rails-transporter:open-asset'
'ctrl-t d m': 'rails-transporter:open-migration-finder'
'ctrl-t f': 'rails-transporter:open-factory'
When active editor opens apps/views/blogs/show.html.erb
and cursor is on the below line, if I invoke open-partial-template command, atom open new editor as apps/views/blogs/_sidebar.html.erb
.
= render :partial => 'sidebar'
Open helper from:
Right now the package seems to be opinionated towards using rspec. the default in rails is still minitest with _test.rb
files. do you think you can add support for jumping to a unit test from a model and controller test from a controller?
Reproduction steps:
For example, I have an imaginary app named "potatoapp". If I try to open the spec file for my Potato model, it suggests the path like this:
but it should be like this:
This only happens if the spec file does not already exist.
This behavior confused me for longer than I would like to admit. I couldn't figure out why the heck guard wasn't seeing my spec files.
The current implementation of the open-spec command basically mirrors the "app/" directory into the "spec/" directory.
However, in my Rails application I have some files in "lib/" instead "of app/lib/" to prevent autoloading and open-spec does obviously not work for it.
I would like to be able to define a directory mirroring "lib/" for specs.
I might implement that myself and create a pull request for it.
Hi,
I have an action only available via ajax with a javascript file associated no html.erb
file but a js.haml
file and of course rails-transporter
is trying to open html.erb
but fail.
If html.erb
is not found we should try html.haml
etc...
A priority list should be configurable and a default should be like :
html.erb
html.haml
js.erb
js.haml
...
Regards
My project mostly has .html.haml views, but some are .html.erb.
Any chance you could allow multiple View File Extensions? I would set my prefs to html.erb, html.slim, html.haml
. If rails-transporter opened the first view it finds then, like Rails, it would prefer .erb over all others.
This would work for all my projects.
Hi, I am rails noob, this package amazing, it save my life, and make my finger faster.
When I order open controller
in file model/broadcaster_info.rb
it just notify me:
No /app/controllers/broadcaster_infoes_controller.rb found
But in rails console:
DEVELOPMENT [5] live-frontend(main)> 'broadcaster_info'.pluralize
"broadcaster_infos"
Which plural is correct?
For example, when triggering the open command on a scaffolded controller, if you call the method inside a def create
or a def update
method, it ask you to create a new file for that method, but those methods usually render other view, (new and edit respectively), is it possible to prompt to open rendered method or to create the new file? something like this prompt.
I don't know if I'm clear enough
Right now you need to know a lot of shortcuts to open related files. It would be great if the user experience could be made a bit easier.
For example my main uses cases right now (90% of the time) are switching between a controller and its tests or a model and its test. So you're focussing on two files and want to switch between them quickly. Right now I have to press know 3 keyboard shortcuts for this work flow.
Optimally you could use the same keyboard shortcut to switch between the test and implementation back and forth.
There could be a new quick command e.g. 'ctrl-alt-r': 'rails-transporter:toggle-test
that detects your current context and brings you to the most likely file you want to go (imho it should switch between test and implementation, but maybe that's not true for everyone, not sure if it should be configurable).
toggleTest: ->
if @isTest(@currentFile)
# not trivial right now to call either @openModel(), @openController() or @openHelper()
else
@openTest()
e.g.
Manifest file is below.
RAILS_ROOT/app/assets/javascripts/application.js
//= require home
//= require moovinator
//= require slider
//= require phonebox
If cursor is on the //= require home
and execute open-asset command, open RAILS_ROOT/app/assets/javascripts/home.js.coffee
.
When cursor is on gem name on Gemfile, open gem's website.
Manifest file is below.
RAILS_ROOT/app/assets/javascripts/application.js
//= require_tree common
//= require_directory shared
If cursor is on the //= require_tree common
or //= require_directory shared
and execute open-asset command, open SprocketsFinder.
The default keyboard shortcuts are two-step, to e.g. switch from model to test you first press ctrl-r
and then t
. Now if the file does not exist a modal pops up asking if you want to create it. It then switches you to the newly created test file.
But in the model file it inserted the character t
into your current cursor position. This is sometimes hard to catch and causes syntax errors
Either make sure extra characters don't get inserted or move to different keybindings that are not two-step, e.g. ctrl-option-t
or similar.
I've just noticed that when I press ctrl + R + V
(expecting to open view for controller action) atom is actually waiting if the next key pressed will be F
which would then open up View Finder. Opening view from a controller now requires additional key to be pressed - anything that's not mapped (a space, return, arrow...).
If you did this intentionally maybe you could rethink and maybe use some of transporter's keymaps that are less often used (maybe ctrl + r + a + a
for "Rails transporter all ") or use a new/different keymap.
I hope I got the message across.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.