Skip to content

Commit

Permalink
Update rcodetools from 0.7.0 to 0.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
infininight committed Aug 21, 2011
1 parent a9affff commit 5eff72f
Show file tree
Hide file tree
Showing 145 changed files with 4,351 additions and 485 deletions.
24 changes: 24 additions & 0 deletions Support/vendor/rcodetools/CHANGES
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
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)
Expand Down
2 changes: 1 addition & 1 deletion Support/vendor/rcodetools/README
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

rcodetools http://eigenclass.org/hiki.rb?rcodetools
Copyright (c) 2005-2007 Mauricio Fernandez <mfp@acm.org> http://eigenclass.org
Copyright (c) 2006-2007 rubikitch <rubikitch@ruby-lang.org> http://www.rubyist.net/~rubikitch/
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
Expand Down
158 changes: 158 additions & 0 deletions Support/vendor/rcodetools/README.TDC
Original file line number Diff line number Diff line change
@@ -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.
29 changes: 25 additions & 4 deletions Support/vendor/rcodetools/README.emacs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,19 @@ If you use icicles copy <tt>icicles-rcodetools.el</tt> too.
Then require it.
(require 'icicles-rcodetools)
It provides wonderful `help on candidate' feature, RI document on each candidate during completion.
I'm addicted to icicles!
http://www.emacswiki.org/cgi-bin/wiki/Icicles

If you use anything.el copy <tt>anything-rcodetools.el</tt> too.
Then require it.
(require 'anything-rcodetools)
RI document on each candidate during completion.

anything-show-completion.el shows selection (mehod) in buffer for completion.
It is available in:
http://www.emacswiki.org/cgi-bin/wiki/download/anything-show-completion.el

I think anything-rcodetools is more convenient than icicles-rcodetools.
I'm addicted to anything!
http://www.emacswiki.org/cgi-bin/wiki/Anything

xmpfilter on buffer
===================
Expand All @@ -38,8 +49,9 @@ method/class/constant completion

# [EVAL IT] (describe-function 'rct-complete-symbol)

If you use icicles-rcodetools, you can browse RI document for selected candidate
by typing C-M-RET. It is wonderful icicles feature!!
If you use icicles-rcodetools or anything-rcodetools, you can browse RI document
for selected candidate by typing C-M-RET (icicles) or C-z (anything.
It is wonderful icicles and anything feature!!

show RI document / jump to the definition
=========================================
Expand All @@ -52,3 +64,12 @@ If use do not use this feature, evaluate:
(setq rct-find-tag-if-available nil)

# [EVAL IT] (describe-variable 'rct-find-tag-if-available)

speed-up xmpfilter and completion
=================================

# [EVAL IT] (describe-function 'rct-fork)
# [EVAL IT] (describe-function 'rct-fork-kill)

M-x rct-fork pre-loads heavy libraries (like rails).
You need not every time wait for loading them anymore!
84 changes: 84 additions & 0 deletions Support/vendor/rcodetools/README.ja
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

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.

= ����
rcodetools �� Ruby �Υ����ɤ򰷤��ġ��뷲�Ǥ���
rcodetools �ˤ� xmpfilter �ȥ��ǥ����˰�¸���ʤ���ȯ�ٱ�ġ��뤬�ޤޤ�Ƥ��ޤ���
Emacs �� Vim �Υ��󥿡��ե��������Ѱդ��Ƥ��ޤ���

* xmpfilter: Test::Unit assert* / RSpec should* ��ư����������������
* rct-complete: �����٥᥽�å�̾�����饹̾�����̾���䴰
* rct-doc: �ɥ�����Ȼ��ȡ������ɥʥӥ�������
* rct-meth-args: �����٥᥽�åɾ���ꥹ�ȡ�TAGS �ե��������
* rct-fork: Rails ���Ť��饤�֥���ͽ������ɤ����䴰���®������ʥ����С�
* rct-fork-client: rct-fork �����Ф��ݻ�������֤��� Ruby ������ץȤ�¹Ԥ���
* ruby-toggle-file: �ƥ��ȥ�����ץȤȼ���������ץȤ��ڤ괹����
* rbtest: �����ϥ�����ץȤΤ���������� Test::Unit


= �Ȥ���

== ����������
�����ͤ�ɽ���������Ԥ� # => ��ä��ޤ���

a, b = "foo", "baz"
a + b # =>
a.size # =>

xmpfilter ���̤��Ȳ��Τ褦�˼����ͤ�ɽ�����Ƥ���ޤ���

a, b = "foo", "baz"
a + b # => "foobaz"
a.size # => 3


== Test::Unit assert ʸ����

���ǤˤǤ������äƤ���ץ������Υƥ��ȥ�����ץȤ�񤯤Τ����ݤǤ��͡�

def test_insertion
@o.insert "bar"
@o.insert "baz"
@o.size # =>
@o.last # =>
@o.first # =>
@o.complex_computation # =>
@o.last(2) # =>
end

xmpfilter��-u ���ץ����ˤ���֤�ڸ����Ƥ���ޤ���

def test_insertion
@o.insert "bar"
@o.insert "baz"
assert_equal(2, @o.size)
assert_equal("baz", @o.last)
assert_equal("bar", @o.first)
assert_in_delta(3.14159265358979, @o.complex_computation, 0.0001)
assert_equal(["baz", "bar"], @o.last(2))
end

RSpec �ˤĤ��Ƥ�Ʊ�ͤΤ��Ȥ��Ǥ��ޤ�����-s ���ץ�����

== �䴰���ɥ�����Ȼ���

ư��ˤ�륹���꡼�󥷥�åȤ򸫤Ƥ���������

http://eigenclass.org/hiki.rb?rcodetools-screenshots

== �ܤ����Ȥ���
-h ���ץ�����Ĥ���Ȼ��Ѳ�ǽ�ʥ��ץ����ɽ������ޤ���

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 �� README.vim �˥��ǥ�����ǤλȤ������ܤ����񤤤Ƥ���ޤ���
Loading

0 comments on commit 5eff72f

Please sign in to comment.