rcodetools 0.8.4.0 → 0.8.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGES CHANGED
@@ -1,5 +1,9 @@
1
1
  rcodetools history
2
2
  ==================
3
+ User-visible changes since 0.8.4
4
+ --------------------------------
5
+ * OOPS, added missing files.
6
+
3
7
  User-visible changes since 0.8.0
4
8
  --------------------------------
5
9
  * xmpfilter: fixed multi-line annotation bugs
data/Rakefile CHANGED
@@ -34,7 +34,7 @@ task :default => :test
34
34
 
35
35
  #{{{ Package tasks
36
36
  PKG_FILES = FileList[
37
- "bin/rct-complete", "bin/rct-doc", "bin/xmpfilter", "bin/rct-meth-args",
37
+ "bin/xmpfilter", "bin/rct-*", "bin/ruby-toggle-file", "bin/rbtest",
38
38
  "lib/**/*.rb",
39
39
  "CHANGES", "rcodetools.*", "icicles-rcodetools.el", "anything-rcodetools.el",
40
40
  "README", "README.*", "THANKS",
@@ -1,5 +1,5 @@
1
1
  ;;; anything-rcodetools.el --- accurate Ruby method completion with anything
2
- ;; $Id: anything-rcodetools.el,v 1.12 2009/04/18 10:12:02 rubikitch Exp $
2
+ ;; $Id: anything-rcodetools.el,v 1.13 2009/04/20 16:25:37 rubikitch Exp $
3
3
 
4
4
  ;;; Copyright (c) 2007 rubikitch
5
5
 
@@ -33,6 +33,9 @@
33
33
  ;;; History:
34
34
 
35
35
  ;; $Log: anything-rcodetools.el,v $
36
+ ;; Revision 1.13 2009/04/20 16:25:37 rubikitch
37
+ ;; Set anything-samewindow to nil
38
+ ;;
36
39
  ;; Revision 1.12 2009/04/18 10:12:02 rubikitch
37
40
  ;; Adjust to change of `use-anything-show-completion'
38
41
  ;;
@@ -136,7 +139,8 @@
136
139
 
137
140
  (defun rct-complete-symbol--anything ()
138
141
  (interactive)
139
- (let ((anything-execute-action-at-once-if-one t))
142
+ (let ((anything-execute-action-at-once-if-one t)
143
+ anything-samewindow)
140
144
  (anything '(anything-c-source-complete-ruby
141
145
  anything-c-source-complete-ruby-all))))
142
146
 
@@ -0,0 +1,266 @@
1
+ #! /usr/local/bin/ruby18
2
+ # Copyright (c) 2006-2007 rubikitch <rubikitch@ruby-lang.org>
3
+ #
4
+ # Use and distribution subject to the terms of the Ruby license.
5
+
6
+ USAGE = <<'XXX'
7
+ Usage: rbtest SCRIPT [-S RUBY_INTERPRETER] [Test::Unit OPTIONS]
8
+ Usage: rbtest [-h] [--help] [--example]
9
+
10
+ I am rbtest, embedded Test::Unit executor for one-file scripts.
11
+ Splitting a small script into many files (executables, libraries and tests) is cumbersome.
12
+ And it is handy to put unit tests near implementations like D language, which has
13
+ built-in unittest keyword.
14
+
15
+ Embedded Test::Unit is simpler than vanilla Test::Unit.
16
+ You do not have to define a Test::Unit::TestCase subclass,
17
+ it is automagically defined and executed by me.
18
+ Embedded Test::Unit uses =begin/=end comment blocks.
19
+
20
+ "=begin TEST_METHOD_NAME" blocks define test methods, eg. "=begin test_foo".
21
+ "=begin rbtest" blocks define utility methods and setup/teardown methods.
22
+
23
+ Of course, you MUST use "if __FILE__ ==$0" idiom to split executable and class/method/function.
24
+
25
+ I am also an real-life example of rbtest usage.
26
+ Issue:
27
+ rbtest --example
28
+ to show me.
29
+
30
+
31
+ options:
32
+ -h, --help Print usage.
33
+ -S RUBY_INTERPRETER Use Ruby interpreter RUBY_INTERPRETER.
34
+ --example Print this file.
35
+ --output Print internally-generated test script (for debug).
36
+ XXX
37
+
38
+
39
+ def first_test(script_filename)
40
+ "require 'test/unit';" +
41
+ "load '#{script_filename}';" +
42
+ "class TestByRbtest < Test::Unit::TestCase;"
43
+ end
44
+
45
+ =begin rbtest
46
+ def setup
47
+ end
48
+
49
+ def unindent(s)
50
+ s.map{|x| x[1..-1]}.join
51
+ end
52
+ =end
53
+
54
+ =begin test_script_to_test_script
55
+ # indent is needed to avoid syntax error.
56
+ script = <<XXX
57
+ #!/usr/bin/env ruby
58
+ =begin test0
59
+ assert_equal(10, f(1))
60
+ =end
61
+ def f(x) x*10 end
62
+ =begin
63
+ other block is skipped
64
+ =end
65
+ =begin test1
66
+ assert_equal(100, f(10))
67
+ =end
68
+ puts f(99) if __FILE__==$0
69
+ XXX
70
+
71
+ test_script = <<'XXX'
72
+ #!/usr/bin/env ruby
73
+ require 'test/unit';load 'f.rb';class TestByRbtest < Test::Unit::TestCase;def test0
74
+ assert_equal(10, f(1))
75
+ end
76
+
77
+
78
+
79
+
80
+ def test1
81
+ assert_equal(100, f(10))
82
+ end
83
+
84
+ end
85
+ XXX
86
+ assert_equal unindent(test_script), script_to_test_script(unindent(script), "f.rb")
87
+
88
+ script = <<XXX
89
+ =begin rbtest
90
+ def setup() end
91
+ =end
92
+ def f(x) x*10 end
93
+ =begin test1
94
+ assert_equal(100, f(10))
95
+ =end
96
+ puts f(99) if __FILE__==$0
97
+ XXX
98
+
99
+ test_script = <<XXX
100
+ require 'test/unit';load 'f.rb';class TestByRbtest < Test::Unit::TestCase;
101
+ def setup() end
102
+
103
+
104
+ def test1
105
+ assert_equal(100, f(10))
106
+ end
107
+
108
+ end
109
+ XXX
110
+
111
+ assert_equal unindent(test_script), script_to_test_script(unindent(script), "f.rb")
112
+ =end
113
+
114
+ def script_to_test_script(ruby_source, script_filename)
115
+ _SKIP = "\n"
116
+ state = :start
117
+ ruby_source.map do |line|
118
+ case line
119
+ when /^#!/
120
+ line
121
+ when "=begin rbtest\n"
122
+ preamble = (state == :start) ? first_test(script_filename) : ""
123
+ state = :rbtest_block
124
+ preamble + "\n"
125
+ when /^=begin (test\S*)$/ # test method block
126
+ preamble = (state == :start) ? first_test(script_filename) : ""
127
+ state = :test_method
128
+ preamble + "def #{$1}\n"
129
+ when /^=begin/ # other block
130
+ state = :begin
131
+ _SKIP
132
+ when /^=end$/
133
+ begin
134
+ if state == :test_method
135
+ "end\n" # /def test_xxx
136
+ else
137
+ _SKIP
138
+ end
139
+ ensure
140
+ state = :script
141
+ end
142
+ else
143
+ if state == :test_method or state == :rbtest_block
144
+ line
145
+ else
146
+ _SKIP
147
+ end
148
+ end
149
+ end.join + "end\n" # /class TestByRbtest
150
+ end
151
+
152
+ =begin test_execute_test_script_command
153
+ require 'tempfile'
154
+ temp = Tempfile.new "rbtest"
155
+ test_script_filename = temp.path
156
+
157
+ temp.puts "#!/usr/bin/ruby18"
158
+ temp.flush
159
+ assert_equal "/usr/bin/ruby18 #{test_script_filename} -v", execute_test_script_command(test_script_filename, parse_argv!(["a0.rb", "-v"]))
160
+
161
+ temp.rewind
162
+ temp.puts "class XX"
163
+ temp.flush
164
+ assert_equal "ruby #{test_script_filename} ", execute_test_script_command(test_script_filename, parse_argv!(["a0.rb"]))
165
+ assert_equal "ruby18 #{test_script_filename} ", execute_test_script_command(test_script_filename, parse_argv!(["-S", "ruby18", "a0.rb"]))
166
+
167
+ =end
168
+
169
+ def shebang(filename)
170
+ open(filename) {|f| line = f.gets.chomp; line[0,2] == "#!" and line[2..-1] }
171
+ end
172
+
173
+ def execute_test_script_command(test_script_filename, args)
174
+ ruby = args.interpreter || shebang(test_script_filename) || "ruby"
175
+ "#{ruby} #{test_script_filename} #{args.opts.join ' '}"
176
+ end
177
+
178
+ def execute_test_script(test_script_filename, args)
179
+ output = `#{execute_test_script_command test_script_filename, args}`
180
+ print output.gsub(Regexp.union(test_script_filename), args.script_filename)
181
+ end
182
+
183
+ def generate_test_script(script_filename, test_script_filename)
184
+ open(test_script_filename, "w") do |f|
185
+ f.write(script_to_test_script(File.read(script_filename), script_filename))
186
+ f.chmod 0755 # executable
187
+ end
188
+ end
189
+
190
+ ################
191
+ def do_test(args)
192
+ begin
193
+ test_script_filename = "#{args.script_filename}__test__.rb"
194
+ generate_test_script(args.script_filename, test_script_filename)
195
+ execute_test_script(test_script_filename, args)
196
+ ensure
197
+ File.unlink test_script_filename
198
+ end
199
+ end
200
+
201
+ def output_test_script(args)
202
+ print(script_to_test_script(File.read(args.script_filename), args.script_filename))
203
+ end
204
+
205
+ def example(args)
206
+ print File.read($0)
207
+ end
208
+
209
+ def help(args)
210
+ print USAGE
211
+ end
212
+
213
+ =begin test_parse_argv_bang
214
+ args = parse_argv!(["a.rb", "-S", "ruby19"])
215
+ assert_equal "a.rb", args.script_filename
216
+ assert_equal "ruby19", args.interpreter
217
+ assert_equal [], args.opts
218
+ assert_equal :do_test, args.action
219
+
220
+ args = parse_argv!(["-S", "ruby19", "a.rb", "-v"])
221
+ assert_equal "a.rb", args.script_filename
222
+ assert_equal "ruby19", args.interpreter
223
+ assert_equal ["-v"], args.opts
224
+ assert_equal :do_test, args.action
225
+
226
+ args = parse_argv!(["a.rb", "-n", "test_0"])
227
+ assert_equal "a.rb", args.script_filename
228
+ assert_equal nil, args.interpreter
229
+ assert_equal ["-n", "test_0"], args.opts
230
+ assert_equal :do_test, args.action
231
+
232
+ assert_equal :help , parse_argv!([]).action
233
+ assert_equal :help , parse_argv!(["--help"]).action
234
+ assert_equal :help , parse_argv!(["-h"]).action
235
+
236
+ args = parse_argv!(["--output", "a.rb"])
237
+ assert_equal "a.rb", args.script_filename
238
+ assert_equal :output_test_script, args.action
239
+
240
+ assert_equal :example, parse_argv!(["--example"]).action
241
+
242
+ =end
243
+
244
+ Args = Struct.new :script_filename, :interpreter, :opts, :action
245
+ def parse_argv!(argv)
246
+ args = Args.new
247
+ args.action = :do_test
248
+ argv.delete '--output' and args.action = :output_test_script
249
+ argv.delete '--example' and args.action = :example and return args
250
+ (argv.delete '-h' or argv.delete '--help') and args.action = :help
251
+ i = argv.index "-S"
252
+ if i and args.interpreter=argv[i+1]
253
+ argv.delete_at i+1
254
+ argv.delete_at i
255
+ end
256
+ args.script_filename = argv.shift
257
+ args.opts = argv
258
+ args.script_filename or args.action = :help
259
+ args
260
+ end
261
+
262
+ if __FILE__ ==$0
263
+ args = parse_argv! ARGV
264
+ __send__(args.action, args)
265
+ end
266
+
@@ -0,0 +1,6 @@
1
+ #! /usr/local/bin/ruby18
2
+
3
+ require 'rcodetools/fork'
4
+
5
+ Rcodetools::Fork.start_server ARGV
6
+
@@ -0,0 +1,5 @@
1
+ #! /usr/local/bin/ruby18
2
+
3
+ require 'rcodetools/fork'
4
+
5
+ Rcodetools::Fork.start_client ARGV
@@ -0,0 +1,26 @@
1
+ #! /usr/local/bin/ruby18
2
+ require 'ruby_toggle_file'
3
+ require 'optparse'
4
+
5
+ USAGE = <<XXX
6
+ Usage: ruby-toggle-file RUBY_SCRIPT
7
+
8
+ I (ruby-toggle-file) accept one Ruby script filename and prints
9
+ corresponding file. If RUBY_SCRIPT is implementation script
10
+ (library), then returns test script and vice versa. It is recommended
11
+ that implementation scripts are located in lib/ directory and test
12
+ scripts are located in test/ directory. This command supports Ruby on
13
+ Rails file layout.
14
+
15
+ I infer corresponding file if it does not exist.
16
+
17
+ If you are curious about behavior, see test/test_ruby_toggle_file.rb.
18
+
19
+ I am meant to be used in text editors or IDEs.
20
+ XXX
21
+
22
+ ARGV.options {|o|
23
+ o.banner = USAGE
24
+ o.parse!
25
+ }
26
+ print RubyToggleFile.new.ruby_toggle_file(ARGV.first)
@@ -15,7 +15,7 @@ require 'tmpdir'
15
15
  module Rcodetools
16
16
 
17
17
  class XMPFilter
18
- VERSION = "0.8.4"
18
+ VERSION = "0.8.5"
19
19
 
20
20
  MARKER = "!XMP#{Time.new.to_i}_#{Process.pid}_#{rand(1000000)}!"
21
21
  XMP_RE = Regexp.new("^" + Regexp.escape(MARKER) + '\[([0-9]+)\] (=>|~>|==>) (.*)')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcodetools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.4.0
4
+ version: 0.8.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rubikitch and Mauricio Fernandez
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-18 00:00:00 +09:00
12
+ date: 2009-04-24 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -35,10 +35,14 @@ extensions: []
35
35
  extra_rdoc_files:
36
36
  - README
37
37
  files:
38
- - bin/rct-complete
39
- - bin/rct-doc
40
38
  - bin/xmpfilter
39
+ - bin/rct-fork-client
41
40
  - bin/rct-meth-args
41
+ - bin/rct-doc
42
+ - bin/rct-complete
43
+ - bin/rct-fork
44
+ - bin/ruby-toggle-file
45
+ - bin/rbtest
42
46
  - lib/method_analyzer.rb
43
47
  - lib/rcodetools/xmptestunitfilter.rb
44
48
  - lib/rcodetools/completion.rb