Permalink
Browse files

rcodetools-0.8.7.0

  • Loading branch information...
0 parents commit 24654f8ef1d2ee7a420b1bd2416a2a59dad22af9 Takahiro Noda committed Feb 25, 2012
Showing with 10,470 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +70 −0 CHANGES
  3. +98 −0 README
  4. +158 −0 README.TDC
  5. +75 −0 README.emacs
  6. +84 −0 README.ja
  7. +13 −0 README.method_analysis
  8. +111 −0 README.vim
  9. +287 −0 README.xmpfilter
  10. +121 −0 Rakefile
  11. +30 −0 Rakefile.method_analysis
  12. +11 −0 THANKS
  13. +151 −0 anything-rcodetools.el
  14. +266 −0 bin/rbtest
  15. +45 −0 bin/rct-complete
  16. +52 −0 bin/rct-doc
  17. +6 −0 bin/rct-fork
  18. +5 −0 bin/rct-fork-client
  19. +442 −0 bin/rct-meth-args
  20. +26 −0 bin/ruby-toggle-file
  21. +85 −0 bin/xmpfilter
  22. +35 −0 icicles-rcodetools.el
  23. +107 −0 lib/method_analyzer.rb
  24. +14 −0 lib/rcodetools/compat.rb
  25. +406 −0 lib/rcodetools/completion.rb
  26. +168 −0 lib/rcodetools/doc.rb
  27. +210 −0 lib/rcodetools/fork.rb
  28. +26 −0 lib/rcodetools/fork_config.rb
  29. +136 −0 lib/rcodetools/options.rb
  30. +379 −0 lib/rcodetools/xmpfilter.rb
  31. +314 −0 lib/rcodetools/xmptestunitfilter.rb
  32. +99 −0 lib/ruby_toggle_file.rb
  33. +430 −0 rcodetools.el
  34. BIN rcodetools.elc
  35. BIN rcodetools.gif
  36. BIN rcodetools.sxmp
  37. +173 −0 rcodetools.vim
  38. +1,585 −0 setup.rb
  39. +45 −0 test/attic/test_run.rb
  40. +2 −0 test/data/attic/add_markers-input.rb
  41. +2 −0 test/data/attic/add_markers-output.rb
  42. +26 −0 test/data/attic/bindings-input.rb
  43. +31 −0 test/data/attic/bindings-output.rb
  44. +1 −0 test/data/attic/completion-input.rb
  45. +2 −0 test/data/attic/completion-output.rb
  46. +1 −0 test/data/attic/completion_class_info-input.rb
  47. +10 −0 test/data/attic/completion_class_info-output.rb
  48. +1 −0 test/data/attic/completion_class_info_no_candidates-input.rb
  49. +1 −0 test/data/attic/completion_class_info_no_candidates-output.rb
  50. +7 −0 test/data/attic/completion_detect_rbtest-input.rb
  51. +2 −0 test/data/attic/completion_detect_rbtest-output.rb
  52. +1 −0 test/data/attic/completion_detect_rbtest2-input.rb
  53. +2 −0 test/data/attic/completion_detect_rbtest2-output.rb
  54. +1 −0 test/data/attic/completion_emacs-input.rb
  55. +6 −0 test/data/attic/completion_emacs-output.rb
  56. +1 −0 test/data/attic/completion_emacs_icicles-input.rb
  57. +6 −0 test/data/attic/completion_emacs_icicles-output.rb
  58. +3 −0 test/data/attic/completion_in_method-input.rb
  59. +1 −0 test/data/attic/completion_in_method-output.rb
  60. +6 −0 test/data/attic/completion_in_method-test.rb
  61. +7 −0 test/data/attic/completion_rbtest-input.rb
  62. +2 −0 test/data/attic/completion_rbtest-output.rb
  63. +1 −0 test/data/attic/doc-input.rb
  64. +1 −0 test/data/attic/doc-output.rb
  65. +1 −0 test/data/attic/doc_detect_rbtest-input.rb
  66. +1 −0 test/data/attic/doc_detect_rbtest-output.rb
  67. +7 −0 test/data/attic/doc_detect_rbtest2-input.rb
  68. +1 −0 test/data/attic/doc_detect_rbtest2-output.rb
  69. +7 −0 test/data/attic/doc_rbtest-input.rb
  70. +1 −0 test/data/attic/doc_rbtest-output.rb
  71. +3 −0 test/data/attic/no_warnings-input.rb
  72. +4 −0 test/data/attic/no_warnings-output.rb
  73. +1 −0 test/data/attic/refe-input.rb
  74. +1 −0 test/data/attic/refe-output.rb
  75. +1 −0 test/data/attic/ri-input.rb
  76. +1 −0 test/data/attic/ri-output.rb
  77. +1 −0 test/data/attic/ri_emacs-input.rb
  78. +1 −0 test/data/attic/ri_emacs-output.rb
  79. +1 −0 test/data/attic/ri_vim-input.rb
  80. +1 −0 test/data/attic/ri_vim-output.rb
  81. +48 −0 test/data/attic/rspec-input.rb
  82. +52 −0 test/data/attic/rspec-output.rb
  83. +48 −0 test/data/attic/rspec_poetry-input.rb
  84. +52 −0 test/data/attic/rspec_poetry-output.rb
  85. +8 −0 test/data/attic/simple_annotation-input.rb
  86. +8 −0 test/data/attic/simple_annotation-output.rb
  87. +50 −0 test/data/attic/unit_test-input.rb
  88. +52 −0 test/data/attic/unit_test-output.rb
  89. +50 −0 test/data/attic/unit_test_detect_rbtest-input.rb
  90. +52 −0 test/data/attic/unit_test_detect_rbtest-output.rb
  91. +6 −0 test/data/attic/unit_test_detect_rbtest2-input.rb
  92. +6 −0 test/data/attic/unit_test_detect_rbtest2-output.rb
  93. +50 −0 test/data/attic/unit_test_poetry-input.rb
  94. +52 −0 test/data/attic/unit_test_poetry-output.rb
  95. +6 −0 test/data/attic/unit_test_rbtest-input.rb
  96. +6 −0 test/data/attic/unit_test_rbtest-output.rb
  97. +33 −0 test/data/method_analyzer-data.rb
  98. +106 −0 test/data/method_args.data.rb
  99. +17 −0 test/data/rct-complete-TDC/completion_in_method__testmethod.taf
  100. +17 −0 test/data/rct-complete-TDC/completion_in_method__testscript.taf
  101. +17 −0 test/data/rct-complete-TDC/completion_in_method__wrong_testmethod.taf
  102. +9 −0 test/data/rct-complete/completion.taf
  103. +9 −0 test/data/rct-complete/completion_class_info.taf
  104. +8 −0 test/data/rct-complete/completion_class_info_no_candidates.taf
  105. +15 −0 test/data/rct-complete/completion_detect_rbtest.taf
  106. +9 −0 test/data/rct-complete/completion_detect_rbtest2.taf
  107. +13 −0 test/data/rct-complete/completion_emacs.taf
  108. +13 −0 test/data/rct-complete/completion_emacs_icicles.taf
  109. +15 −0 test/data/rct-complete/completion_rbtest.taf
  110. +8 −0 test/data/rct-doc/doc.taf
  111. +8 −0 test/data/rct-doc/doc_detect_rbtest.taf
  112. +14 −0 test/data/rct-doc/doc_detect_rbtest2.taf
  113. +14 −0 test/data/rct-doc/doc_rbtest.taf
  114. +8 −0 test/data/rct-doc/refe.taf
  115. +8 −0 test/data/rct-doc/ri.taf
  116. +8 −0 test/data/rct-doc/ri_emacs.taf
  117. +8 −0 test/data/rct-doc/ri_vim.taf
  118. +9 −0 test/data/sample_test_script.rb
  119. +10 −0 test/data/xmpfilter/add_markers.taf
  120. +63 −0 test/data/xmpfilter/bindings.taf
  121. +22 −0 test/data/xmpfilter/comment_out.taf
  122. +14 −0 test/data/xmpfilter/exception.taf
  123. +54 −0 test/data/xmpfilter/expectations.taf
  124. +18 −0 test/data/xmpfilter/last_match.taf
  125. +9 −0 test/data/xmpfilter/mult.rb
  126. +22 −0 test/data/xmpfilter/multi_line_annotation_1.taf
  127. +24 −0 test/data/xmpfilter/multi_line_annotation_2.taf
  128. +20 −0 test/data/xmpfilter/multi_line_annotation_3.taf
  129. +22 −0 test/data/xmpfilter/multi_line_annotation_4.taf
  130. +34 −0 test/data/xmpfilter/multi_line_annotation_5.taf
  131. +12 −0 test/data/xmpfilter/multi_line_annotation_6.taf
  132. +23 −0 test/data/xmpfilter/multi_line_annotation_7.taf
  133. +13 −0 test/data/xmpfilter/no_warnings.taf
  134. +16 −0 test/data/xmpfilter/nospace.taf
  135. +106 −0 test/data/xmpfilter/rspec.taf
  136. +106 −0 test/data/xmpfilter/rspec_poetry.taf
  137. +22 −0 test/data/xmpfilter/simple_annotation.taf
  138. +108 −0 test/data/xmpfilter/unit_test.taf
  139. +108 −0 test/data/xmpfilter/unit_test_detect_rbtest.taf
  140. +18 −0 test/data/xmpfilter/unit_test_detect_rbtest2.taf
  141. +108 −0 test/data/xmpfilter/unit_test_poetry.taf
  142. +18 −0 test/data/xmpfilter/unit_test_rbtest.taf
  143. +16 −0 test/data/xmpfilter/width.taf
  144. +674 −0 test/test_completion.rb
  145. +446 −0 test/test_doc.rb
  146. +47 −0 test/test_functional.rb
  147. +107 −0 test/test_method_analyzer.rb
  148. +134 −0 test/test_method_args.rb
  149. +33 −0 test/test_options.rb
  150. +174 −0 test/test_ruby_toggle_file.rb
  151. +221 −0 test/test_xmpfilter.rb
  152. +86 −0 test/test_xmptestunitfilter.rb
  153. +162 −0 test/tmp_functional.rb
  154. +66 −0 test/tmp_run.rb
@@ -0,0 +1,2 @@
+pkg
+
70 CHANGES
@@ -0,0 +1,70 @@
+rcodetools history
+==================
+User-visible changes since 0.8.5
+--------------------------------
+* Fix DATA and __END__ handling in xmpfilter --tempfile (windows)
+
+User-visible changes since 0.8.4
+--------------------------------
+* OOPS, added missing files.
+
+User-visible changes since 0.8.0
+--------------------------------
+* xmpfilter: fixed multi-line annotation bugs
+
+User-visible changes since 0.7.0
+--------------------------------
+* Support Ruby 1.9!
+* xmpfilter: multi-line annotation
+* xmpfilter --expectations generates expectations by Jay Fields
+* anything-rcodetools.el: new elisp
+* --tmpfile, --tempfile: use temporary file instead of open3 on un*x
+* rcodetools.el: smarter xmpfilter-command
+* rcodetools.el: rct-fork interface
+* rct-fork: require 'rubygems' initially
+* rct-fork: more stable
+
+User-visible changes since 0.5.0
+--------------------------------
+* "test-driven completion" (TDC) support for Emacs and vim (see README.TDC)
+* --test (-t), --filename options for rct-complete and rct-doc, allowing to
+ specify the test to be run for 100% accurate completion/documentation in the
+ corresponding implementation
+* ruby-toggle-file: finds the test file corresponding to a given
+ implementation and vice versa
+* rct-fork, rct-fork-client: allow to eliminate the overhead due to library
+ loading (esp. useful for Rails)
+* rbtest: executes unit tests in a single Ruby script
+* --fork, --rbtest, --detect-rbtest supported by several commands
+* xmpfilter's --spec now autodetects the RSpec version and generates
+ specifications with the appropriate syntax
+
+User-visible changes since 0.4.1
+--------------------------------
+* --dev: adds project directories to $:
+* --completion-class-info: list completion candidates and class info
+* display completion candidates with description, both in emacs
+ and vim (using the menu+preview window).
+
+User-visible changes since 0.4.0
+--------------------------------
+* rct-meth-args: implemented -I
+* many bug fixes
+
+xmpfilter was integrated into rcodetools as of 0.4.0.
+
+xmpfilter history
+=================
+User-visible changes since 0.3.1 (2006-10-17)
+* implemented --debug
+* --[no]-warnings
+* --cd working_dir
+* --rails
+* --no-poetry
+* more intelligent assertions: try to find which local variables hold the
+ values compared against in assertions/expectations
+* editor-independent completion (-C, --completion-emacs, --completion-vim)
+* quick method/class reference with -D (--refe, --ri*)
+
+User-visible changes since 0.3.0 (2006-10-16)
+* xmpfilter.rb --spec works on win32 too
98 README
@@ -0,0 +1,98 @@
+
+ rcodetools http://eigenclass.org/hiki.rb?rcodetools
+ Copyright (c) 2005-2007 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
+ Copyright (c) 2006-2008 rubikitch <rubikitch@ruby-lang.org> 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.
@@ -0,0 +1,158 @@
+
+= Overview
+
+Ruby is very dynamic language, therefore it is impossible to do
+accurate completion without executing script. While executing script
+from start to cursor point is often dangerous, executing unit test
+script covering current point is SAFE. I call this methodology
+`Test-Driven Completion' (TDC).
+
+As I have already stated in README, browsing documentation of method
+(rct-doc) is almost identical operation to completion. This
+discussion is applicable to rct-doc.
+
+= Why TDD Is Needed
+
+In the following code snippet:
+
+ File.unlink a_file
+ File. <-
+
+If you complete after `File.', rct-complete actually deletes a_file.
+Normally it is unpleasant.
+In real-life development, side-effect is inevitable.
+
+In the foo method which are not called:
+
+ def foo
+ 1. <-
+ end
+
+If the code does not call foo, rct-complete cannot do any completions.
+Before TDC, if you want to do completion in methods, you have to write
+method call and remove it after completion. Too useless!!
+
+= Messianic Unit Test Script
+
+Recently Test-Driven Development (TDD) is widespread. Many developers
+write unit tests. Fortunately Ruby's unit tester, Test::Unit, is
+sophisticated enough to test one test method. Unit tests are
+self-enclosed: they must tear down resources, so executing unit tests
+are SAFE. TDC uses unit test to do completion.
+
+= TDC Methodology
+
+(1) Switch to unit test script.
+(2) Write a test for target method.
+(3) Switch to implementation script.
+(4) You can write target method WITH COMPLETION!
+(5) Back to (1)
+
+TDC methodology is almost identical to TDD. TDC is very easy for TDDers.
+
+= TDC With Example
+
+For simplicity, suppose that you are unfamiliar with Time class and
+you want to write a method to format date string.
+
+The directory structure and file contents is following:
+
+ /tmp/mylib0/
+ /tmp/mylib0/lib/
+ mylib0.rb
+ /tmp/mylib0/test/
+ test_mylib0.rb
+
+ List: mylib0.rb
+ # contrived example of long-runtime method
+ def mysleep(x)
+ sleep x
+ end
+
+ def mytime(tm)
+
+ end
+
+
+ List: test_mylib0.rb
+ require 'test/unit'
+ require 'mylib0'
+ class TestMylib0 < Test::Unit::TestCase
+ def test_0_mysleep
+ s = Time.now
+ mysleep 3.0
+ e = Time.now
+ assert_in_delta 3.0, e-s, 0.01
+ end
+
+ def test_1_mytime
+
+ end
+ end
+
+These sample files are in demo/ directory.
+
+
+== Switch to unit test script.
+
+TDC starts with writing unit test as TDD does.
+Open test_mylib0.rb.
+
+== Write a test for target method.
+
+Suppose that you want to write mytime method and test_1_mytime test
+method, and that you want to experiment Time class first (before
+forming an assertion).
+
+In TDC, you do not have to write an assertion first: just write only a
+method call. If you are familiar with Time class, you are free to
+write an assertion, of course.
+
+ def test_1_mytime
+ mytime(Time.now)
+ end
+
+At this time, the cursor position is in test_1_mytime test method.
+
+== Switch to implementation script.
+
+Open mylib0.rb with the `ruby-toggle-file' script. For example, in Emacs use
+the `ruby-toggle-buffer' command, and in vim the <localleader>t (by default
+\t) binding. Since in TDD/TDC you often switch between the test and the
+implementation, it is much handier than typing the filename manually.
+
+The rct-complete uses latest-selected test script as TDC test script
+and test method at cursor position as TDC test method. In this case,
+test_mylib0.rb is TDC test script and test_1_mytime is TDC test
+method. If the cursor position of test_mylib0.rb is at the top,
+rct-complete executes whole test methods in test_mylib0.rb. Therefore
+latency of completion is longer.
+
+== You can write target method WITH COMPLETION!
+
+Fill mytime method.
+
+ def mytime(tm)
+ tm.
+ end
+
+Do completion after `tm.'. Here! Your editor is listing methods `tm'
+accepts!! If your editor has help-on-candidate mechanism (eg. Emacs +
+Icicles), you would see documentation of each listed method.
+
+Then you find `Time#strftime' method. Type `str' and do completion.
+
+ def mytime(tm)
+ tm.strftime
+ end
+
+Usage is... use `rct-doc' (in Emacs, `rct-ri') after `strftime'.
+
+After you are familiar with Time class, switch to test script and write assertions.
+
+= When Modifying Another Method
+
+If you want to modify already-written method, setting cursor position
+of corresponding test script to corresponding test method is better.
+It tells rct-complete new test script and test method, so you can do
+completion in the new method.
Oops, something went wrong.

0 comments on commit 24654f8

Please sign in to comment.