Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/geoffharcourt/vim-ruby-private-method-extract
https://github.com/geoffharcourt/vim-ruby-private-method-extract
Last synced: 19 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/geoffharcourt/vim-ruby-private-method-extract
- Owner: geoffharcourt
- License: mit
- Created: 2013-09-10T14:46:05.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-10T15:36:27.000Z (over 11 years ago)
- Last Synced: 2024-11-09T20:05:06.270Z (3 months ago)
- Language: VimL
- Size: 121 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.markdown
- License: LICENSE
Awesome Lists containing this project
README
# vim-ruby-private-method-extract
Experimental project to extract private methods out of longer existing methods.
* Creates a private section of the class if one doesn't exist.
* Takes a visual selection and names the method after the local variable before the equals sign.
* Makes the statement following the equals sign the method body.
* Trims whitespace and fixes indentation after call.This project is an initial effort in learning Vimscript. Contributions and suggestions for improvement are very welcome.
# How to use
1. In visual mode (I use visual-line mode), select a piece of a method that you want to extract to a private method.
2. Call ExtractPrivateMethod(). You can bind this to a shortcut for maximum efficiency.
3. If your class has a private section, a new private method is inserted with the statement selected. The method is named after the local variable before the equals sign, and the method body is the statement after the equals sign.
4. The original statement is deleted.Example:
Start with this:
```ruby
class MyClass
def too_long_method
temp_query = thing_to_call.method_to_calltemp_query.something_else_to_do
endend
```After highlighting the first line of ````too_long_method```` and calling ````ExtractPrivateMethod()````, the class looks like this:
```ruby
class MyClass
def too_long_method
temp_query.something_else_to_do
endprivate
def temp_query
thing_to_call.method_to_call
endend
```# Credits
vim-ruby-private-method-extract was created and is maintained by [Geoff Harcourt](http://github.com/geoffharcourt).The functionality was inspired by a macro run by [Ben Orenstein](http://github/com/r00k) during his "Refactoring From Good to Great" talks.
## License
vim-ruby-private-method-extract is free software, and may be redistributed under the terms specified in the [LICENSE](https://github.com/geoffharcourt/vim-ruby-private-method-extract/blob/master/LICENSE) file.