GithubHelp home page GithubHelp logo

blaketidwell / rcodetools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from joshcheek/rcodetools

0.0 1.0 0.0 220 KB

Source code for rcodetools (http://rubygems.org/gems/rcodetools)

Ruby 86.56% Emacs Lisp 10.83% Vim Script 2.60%

rcodetools's Introduction

= This repo

I did not write rcodetools, nor do I maintain it.
The gem does not list an official repository,
and its website is down. I am purely hosting a version
of what is installed from `gem unpack rcodetools`,
so that I have a repository that I can reference back to.

This is version 0.8.5.0,
the changes I have made are only this change to the readme.

If you like rcodetool's xmpfilter, I maintain
SeeingIsBelieving[https://github.com/JoshCheek/seeing_is_believing#readme]
a tool intended to succeed it.

= Copyright info

 rcodetools  http://eigenclass.org/hiki.rb?rcodetools
 Copyright (c) 2005-2007 Mauricio Fernandez <[email protected]> http://eigenclass.org
 Copyright (c) 2006-2008 rubikitch <[email protected]> http://www.rubyist.net/~rubikitch/
Use and distribution subject to the terms of the Ruby license.

= Overview
rcodetools is a collection of Ruby code manipulation tools.
It includes xmpfilter and editor-independent Ruby development helper tools,
as well as emacs and vim interfaces.

Currently, rcodetools comprises:
* xmpfilter: Automagic Test::Unit assertions/RSpec expectations and code annotations
* rct-complete: Accurate method/class/constant etc. completions
* rct-doc: Document browsing and code navigator
* rct-meth-args: Precise method info (meta-prog. aware) and TAGS generation
* rct-fork: Pre-load heavy library(Rails etc) and speed up rct-complete/rct-doc (server)
* rct-fork-client: Run Ruby programs from state the rct-fork server has
* ruby-toggle-file: Toggle implementation file and test file
* rbtest: Embedded Test::Unit for small scripts

See also README.xmpfilter.

Originally rct-complete and rct-doc were subcommands of xmpfilter.
Actually they use xmpfilter's code heavily.
But the relationship between xmpfilter (annotation) and completion/doc is not
intuitive, so I (rubikitch) split it into separate executables.

= Usage
xmpfilter, rct-complete and rct-doc take its input from stdin and write to
stdout. They can run in several modes; see
 xmpfilter -h
 rct-complete -h
 rct-doc -h
 rct-meth-args -h
 rct-fork -h
 rct-fork-client -h
 ruby-toggle-file -h
 rbtest -h
README.emacs and README.vim describe how to use rcodetools from your editor.

= Accurate Completion Internal and Caveat
rct-complete and rct-doc use xmpfilter engine, ie they get runtime information by executing code.
In Ruby (dynamic languages), type of any expressions except literals cannot be known without actually executing code.
Moreover Ruby has open classes and singleton methods.
Rcodetools asks `ruby' run-time informations, so we can get very accurate informations.
Completion and document browsing are essentially identical operations,
they both need the object value in question.
Therefore we discuss completion.

rct-complete does:
(1) replaces target line with completion magic
    (it calculates methods the target object has).
(2) executes modified script.
(3) once the control reaches completion magic, modified script exits.
(4) outputs in specified format. (list candidates, EmacsLisp...)

But this methodology has two big drawbacks, side-effects and inability to get any informations of uncovered code!

An extreme side-effect example:
  File.unlink a_file
  File. <-

If you call rct-complete, it removes a_file (sends a mail, accesses DB ...).
So you must be careful to use, especially at TOPLEVEL.
I (rubikitch) often experiment at TOPLEVEL with rcodetools, I NEVER use irb(sh) since rcodetools!

An uncovered code example:
  def foo
    1. <-
  end

If the code does not call foo, we cannot do any completions.

Useless eh? But we already have a way to elude the drawbacks, test scripts (unit tests)!
Test scripts are self-enclosed and expected to be executed, so side-effects are not problem.
Moreover tests call methods we write.
Because Ruby's Test::Unit has an ability to test only one test method, we can do lightning-fast completion.
Let's call it Test-Driven Completion (TDC).

To support TDC, rct-complete has -t option.
With -t, it concatenate modified script and test/unit code.
If the control does not reach target line, test/unit code calls the line.

How do we select test script and test method?
The editor selects recently selected buffer of test script as test script of TDC,
because the test-infected tend to go and return between test script and implementation script.
It considers files matching /test.*\.rb/ as test script.
It selects test method at the cursor position.

TDC adds roles of test scripts.
Enjoy TDC magic!

See also README.TDC.


= License
rcodetools is licensed under the same terms as Ruby.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.