vcs 0.1 → 0.2.148

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. data/Rakefile +17 -3
  2. data/bin/vcs +57 -34
  3. data/doc/jamis.rb +564 -0
  4. data/ruby_ex/abstract.rb +254 -0
  5. data/ruby_ex/abstract_node.rb +85 -0
  6. data/ruby_ex/algorithms/simulated_annealing.rb +140 -0
  7. data/ruby_ex/array_each_pair.rb +18 -0
  8. data/ruby_ex/ask.rb +101 -0
  9. data/ruby_ex/attributed_class.rb +302 -0
  10. data/ruby_ex/cache.rb +373 -0
  11. data/ruby_ex/checkout.rb +12 -0
  12. data/ruby_ex/choose.rb +271 -0
  13. data/ruby_ex/commands.rb +18 -0
  14. data/ruby_ex/commands/command.rb +401 -0
  15. data/ruby_ex/commands/datas.rb +16 -0
  16. data/ruby_ex/commands/datas/data.rb +33 -0
  17. data/ruby_ex/commands/datas/factory.rb +66 -0
  18. data/ruby_ex/commands/factory.rb +66 -0
  19. data/ruby_ex/commands/helpers.rb +67 -0
  20. data/ruby_ex/commands/pipe.rb +64 -0
  21. data/ruby_ex/commands/runners.rb +17 -0
  22. data/ruby_ex/commands/runners/exec.rb +49 -0
  23. data/ruby_ex/commands/runners/fork.rb +97 -0
  24. data/ruby_ex/commands/runners/runner.rb +107 -0
  25. data/ruby_ex/commands/seq.rb +27 -0
  26. data/ruby_ex/config_file.rb +96 -0
  27. data/ruby_ex/const_regexp.rb +59 -0
  28. data/ruby_ex/daemon.rb +134 -0
  29. data/ruby_ex/diff.rb +667 -0
  30. data/ruby_ex/dlogger.rb +62 -0
  31. data/ruby_ex/drb/dispatcher.rb +252 -0
  32. data/ruby_ex/drb/dispatcher_server_test.rb +29 -0
  33. data/ruby_ex/drb/drb_observable.rb +97 -0
  34. data/ruby_ex/drb/drb_observable_pool.rb +27 -0
  35. data/ruby_ex/drb/drb_service.rb +43 -0
  36. data/ruby_ex/drb/drb_undumped_attributes.rb +55 -0
  37. data/ruby_ex/drb/drb_undumped_indexed_object.rb +54 -0
  38. data/ruby_ex/drb/insecure_protected_methods.rb +103 -0
  39. data/ruby_ex/drb/session_client_test.rb +40 -0
  40. data/ruby_ex/drb/session_manager.rb +246 -0
  41. data/ruby_ex/drb/session_server.rb +53 -0
  42. data/ruby_ex/dtime.rb +143 -0
  43. data/ruby_ex/dumpable_proc.rb +63 -0
  44. data/ruby_ex/exception.rb +32 -0
  45. data/ruby_ex/filetype.rb +229 -0
  46. data/ruby_ex/fileutils_ex.rb +44 -0
  47. data/ruby_ex/fold.rb +58 -0
  48. data/ruby_ex/generate_id.rb +44 -0
  49. data/ruby_ex/hookable.rb +262 -0
  50. data/ruby_ex/hooker.rb +54 -0
  51. data/ruby_ex/inactive_timeout.rb +137 -0
  52. data/ruby_ex/indexed_node.rb +66 -0
  53. data/ruby_ex/io_marshal.rb +100 -0
  54. data/ruby_ex/ioo.rb +194 -0
  55. data/ruby_ex/labeled_node.rb +63 -0
  56. data/ruby_ex/logger_observer.rb +23 -0
  57. data/ruby_ex/md5sum.rb +66 -0
  58. data/ruby_ex/mktemp.rb +208 -0
  59. data/ruby_ex/module/attr_once.rb +36 -0
  60. data/ruby_ex/module/autoload_tree.rb +75 -0
  61. data/ruby_ex/module/hierarchy.rb +335 -0
  62. data/ruby_ex/module/instance_method_visibility.rb +73 -0
  63. data/ruby_ex/module_ex.rb +11 -0
  64. data/ruby_ex/node.rb +80 -0
  65. data/ruby_ex/object_monitor.rb +145 -0
  66. data/ruby_ex/object_monitor_activity.rb +33 -0
  67. data/ruby_ex/observable.rb +140 -0
  68. data/ruby_ex/observable_pool.rb +293 -0
  69. data/ruby_ex/orderedhash.rb +252 -0
  70. data/ruby_ex/pathname_ex.rb +152 -0
  71. data/ruby_ex/pp_hierarchy.rb +29 -0
  72. data/ruby_ex/pseudo_cache.rb +190 -0
  73. data/ruby_ex/queue.rb +56 -0
  74. data/ruby_ex/random_generators.rb +25 -0
  75. data/ruby_ex/random_generators/random_generator.rb +31 -0
  76. data/ruby_ex/random_generators/ruby.rb +23 -0
  77. data/ruby_ex/safe_eval.rb +348 -0
  78. data/ruby_ex/sendmail.rb +215 -0
  79. data/ruby_ex/service_manager.rb +121 -0
  80. data/ruby_ex/session/administrable.rb +120 -0
  81. data/ruby_ex/session/client.rb +153 -0
  82. data/ruby_ex/session/const.rb +18 -0
  83. data/ruby_ex/session/dispatcher.rb +184 -0
  84. data/ruby_ex/session/error.rb +21 -0
  85. data/ruby_ex/session/fetchable.rb +57 -0
  86. data/ruby_ex/session/fetcher.rb +62 -0
  87. data/ruby_ex/session/hookable.rb +26 -0
  88. data/ruby_ex/session/profile.rb +110 -0
  89. data/ruby_ex/session/server.rb +582 -0
  90. data/ruby_ex/session/test/administrable_test.rb +337 -0
  91. data/ruby_ex/session/test/basic_test.rb +523 -0
  92. data/ruby_ex/session/test/dispatcher_test.rb +409 -0
  93. data/ruby_ex/session/test/fetchable_test.rb +119 -0
  94. data/ruby_ex/session/test/sub_server_test.rb +188 -0
  95. data/ruby_ex/shuffle.rb +30 -0
  96. data/ruby_ex/spring.rb +136 -0
  97. data/ruby_ex/spring_set.rb +137 -0
  98. data/ruby_ex/string_ex.rb +28 -0
  99. data/ruby_ex/symtbl.rb +106 -0
  100. data/ruby_ex/synflow.rb +474 -0
  101. data/ruby_ex/test/unit/ui/yaml/testrunner.rb +164 -0
  102. data/ruby_ex/thread_mutex.rb +10 -0
  103. data/ruby_ex/timeout_ex.rb +81 -0
  104. data/ruby_ex/top_down.rb +73 -0
  105. data/ruby_ex/trace.rb +26 -0
  106. data/ruby_ex/uri/druby.rb +81 -0
  107. data/ruby_ex/uri/file.rb +65 -0
  108. data/ruby_ex/uri/ftp_ex.rb +37 -0
  109. data/ruby_ex/uri/http_ex.rb +43 -0
  110. data/ruby_ex/uri/ssh.rb +92 -0
  111. data/ruby_ex/uri/svn.rb +118 -0
  112. data/ruby_ex/uri_ex.rb +45 -0
  113. data/ruby_ex/verbose_object.rb +30 -0
  114. data/ruby_ex/version.rb +66 -0
  115. data/ruby_ex/yaml/basenode_ext.rb +63 -0
  116. data/ruby_ex/yaml/chop_header.rb +23 -0
  117. data/ruby_ex/yaml/transform.rb +449 -0
  118. data/ruby_ex/yaml/yregexpath.rb +76 -0
  119. data/src/changelog.rb +28 -18
  120. data/src/conflict.rb +20 -0
  121. data/src/diff.rb +18 -0
  122. data/src/diffstat.rb +9 -3
  123. data/src/last_changed_date.rb +18 -0
  124. data/src/mail.rb +33 -65
  125. data/src/message.rb +15 -9
  126. data/src/mycommit.rb +29 -14
  127. data/src/news.rb +24 -3
  128. data/src/status.rb +17 -0
  129. data/src/svn.rb +2 -2
  130. data/src/vcs.rb +24 -3
  131. metadata +124 -5
  132. data/lrdetools.rb +0 -12
@@ -0,0 +1,56 @@
1
+ # Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
2
+ # Author: Nicolas Despres <polrop@lrde.epita.fr>.
3
+ # License: Gnu General Public License.
4
+
5
+ # $LastChangedBy: ertai $
6
+ # $Id: queue.rb 53 2004-12-02 22:24:03Z ertai $
7
+
8
+
9
+ require 'thread'
10
+
11
+
12
+ class Queue
13
+
14
+ alias put push
15
+ alias get pop
16
+
17
+ end # class Queue
18
+
19
+
20
+ #
21
+ # Unit test suite
22
+ #
23
+ if defined? TEST_MODE or $0 == __FILE__
24
+
25
+
26
+ require 'test/unit/ui/yaml/testrunner'
27
+
28
+
29
+ class QueueTest < Test::Unit::TestCase
30
+
31
+ #
32
+ # tests
33
+ #
34
+ def test_simple
35
+ q = Queue.new
36
+ thr1 = Thread.new do
37
+ while q.empty? do end
38
+ assert_equal(2, q.size)
39
+ assert_equal(2, q.length)
40
+ assert_equal('hello', q.get)
41
+ assert_equal('world', q.get)
42
+ assert(q.empty?)
43
+ end
44
+ thr2 = Thread.new do
45
+ sleep(0.2)
46
+ q.put('hello')
47
+ q.put('world')
48
+ end
49
+ thr1.join
50
+ thr2.join
51
+ end
52
+
53
+ end # class QueueTest
54
+
55
+
56
+ end
@@ -0,0 +1,25 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: random_generators.rb 218 2005-05-09 12:11:21Z ertai $
5
+
6
+ require 'module/autoload_tree'
7
+ require 'abstract'
8
+
9
+ module RandomGenerators
10
+
11
+ autoloaded_module(__FILE__)
12
+
13
+ @@default = Ruby.new
14
+
15
+ module_function
16
+
17
+ def default
18
+ @@default
19
+ end
20
+
21
+ def default= ( aClass )
22
+ @@default = aClass
23
+ end
24
+
25
+ end # module RandomGenerators
@@ -0,0 +1,31 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: random_generator.rb 218 2005-05-09 12:11:21Z ertai $
5
+
6
+ module RandomGenerators
7
+
8
+ class RandomGenerator
9
+ abstract
10
+
11
+ def check_choose_integer ( n )
12
+ unless n.is_a? Integer
13
+ raise ArgumentError, "Need an integer (not #{n})"
14
+ end
15
+ if n <= 0
16
+ raise ArgumentError, "Need an positive value (not #{n})"
17
+ end
18
+ end
19
+
20
+ def check_choose_float ( f )
21
+ unless f.is_a? Float
22
+ raise ArgumentError, "Need a float (not #{f})"
23
+ end
24
+ if f <= 0
25
+ raise ArgumentError, "Need an positive value (not #{f})"
26
+ end
27
+ end
28
+
29
+ end # class RandomGenerator
30
+
31
+ end # module RandomGenerators
@@ -0,0 +1,23 @@
1
+ # Author:: Nicolas Pouillard <ertai@lrde.epita.fr>.
2
+ # Copyright:: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
3
+ # License:: GNU General Public License (GPL).
4
+ # Revision:: $Id: ruby.rb 218 2005-05-09 12:11:21Z ertai $
5
+
6
+ module RandomGenerators
7
+
8
+ class Ruby < RandomGenerator
9
+ concrete
10
+
11
+ def choose_integer ( n )
12
+ check_choose_integer(n)
13
+ Kernel.rand(n)
14
+ end
15
+
16
+ def choose_float ( f=1.0 )
17
+ check_choose_float(f)
18
+ Kernel.rand() * f
19
+ end
20
+
21
+ end # class Ruby
22
+
23
+ end # module RandomGenerators
@@ -0,0 +1,348 @@
1
+ # Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
2
+ # Author: Nicolas Despres <polrop@lrde.epita.fr>.
3
+ # License: Gnu General Public License.
4
+
5
+ # $LastChangedBy: polrop $
6
+ # $Id: safe_eval.rb 91 2005-01-09 22:24:40Z polrop $
7
+
8
+
9
+ class SafeEval
10
+
11
+ attr_accessor :collect, :safe
12
+ attr_reader :output
13
+
14
+ def initialize(safe=3, collect=true)
15
+ @safe = safe
16
+ @collect = collect
17
+ end
18
+
19
+ def run(code_str='', binding=nil, filename='(SafeEval)', lineno=1)
20
+ binding = yield if block_given?
21
+ lineno -= 1
22
+ @output = nil
23
+ @output = [] if @collect
24
+ result = nil
25
+ code_str.strip!
26
+ return result if code_str.empty?
27
+ rd_result, wr_result = IO.pipe
28
+ open('|-') do |io|
29
+ if io.nil? then # son
30
+ status = 0
31
+ rd_result.close
32
+ set_environment
33
+ begin
34
+ code = "$SAFE = #@safe\n#{code_str}"
35
+ result = eval(code, binding, filename, lineno)
36
+ status = 0 # needed if the user change the status
37
+ rescue Exception => exception
38
+ status = 1
39
+ result = exception
40
+ ensure
41
+ Marshal.dump(result, wr_result)
42
+ wr_result.close
43
+ exit!(status)
44
+ end
45
+ else # father
46
+ wr_result.close
47
+ io.each_line { |l| @output << l.chomp } if @collect
48
+ result = Marshal.load(rd_result)
49
+ rd_result.close
50
+ Process.waitpid(io.pid)
51
+ end
52
+ end
53
+ raise result if $?.exitstatus == 1
54
+ @output = nil unless @collect
55
+ return result
56
+ end
57
+ public :run
58
+
59
+ # Can be overloaded to specify environment restriction.
60
+ def set_environment
61
+ end
62
+ protected :set_environment
63
+
64
+ end # class SafeEval
65
+
66
+
67
+ #
68
+ # Unit test suite
69
+ #
70
+ if defined? TEST_MODE or $0 == __FILE__
71
+
72
+
73
+ require 'test/unit/ui/yaml/testrunner'
74
+
75
+
76
+ class SafeEvalTest < Test::Unit::TestCase
77
+
78
+ #
79
+ # Tests
80
+ #
81
+ def test_interface
82
+ se = SafeEval.new
83
+ assert_respond_to(se, :run)
84
+ assert_respond_to(se, :output)
85
+ assert_respond_to(se, :safe)
86
+ assert_respond_to(se, :collect)
87
+ assert(se.protected_methods.include?('set_environment'),
88
+ "no protected method 'set_environment'")
89
+ end
90
+
91
+ def test_nil
92
+ se = SafeEval.new
93
+ assert_equal(nil, se.run)
94
+ assert_equal([], se.output)
95
+ end
96
+
97
+ def test_true
98
+ se = SafeEval.new
99
+ assert_equal(true, se.run('true'))
100
+ assert_equal([], se.output)
101
+ end
102
+
103
+ def test_false
104
+ se = SafeEval.new
105
+ assert_equal(false, se.run('false'))
106
+ assert_equal([], se.output)
107
+ end
108
+
109
+ def test_nil_no_collect
110
+ se = SafeEval.new(3, false)
111
+ assert_equal(nil, se.run)
112
+ assert_equal(nil, se.output)
113
+ end
114
+
115
+ def test_almost_empty_code
116
+ se = SafeEval.new
117
+ assert_equal(nil, se.run(' '))
118
+ assert_equal([], se.output)
119
+ end
120
+
121
+ def test_true_no_collect
122
+ se = SafeEval.new(3, false)
123
+ assert_equal(true, se.run('true'))
124
+ assert_equal(nil, se.output)
125
+ end
126
+
127
+ def test_binding_argument
128
+ def getBinding; a = 42; return binding; end
129
+ se = SafeEval.new
130
+ assert_equal(nil, se.run('puts a', getBinding))
131
+ assert_equal(['42'], se.output)
132
+ end
133
+
134
+ def test_binding_block
135
+ se = SafeEval.new
136
+ assert_equal(true, se.run('puts a; true') { a = 42; return binding })
137
+ assert_equal(['42'], se.output)
138
+ end
139
+
140
+ def test_binding_both
141
+ def getBinding2; a = 51; return binding; end
142
+ se = SafeEval.new
143
+ ret = se.run('puts a; true', getBinding2) { a = 42; return binding }
144
+ assert_equal(true, ret)
145
+ assert_equal(['42'], se.output)
146
+ end
147
+
148
+ def test_exception
149
+ mypid = $$
150
+ se = SafeEval.new
151
+ $tmp = 42
152
+ begin
153
+ $tmp = se.run('raise NoMethodError')
154
+ rescue NoMethodError
155
+ assert_equal(mypid, $$, "bad pid")
156
+ assert_equal(42, $tmp, "result must be nil")
157
+ assert_equal([], se.output)
158
+ ensure
159
+ assert_equal(mypid, $$, "bad pid")
160
+ end
161
+ end
162
+
163
+ def test_exception_collect
164
+ se = SafeEval.new
165
+ assert_raises(Exception) do
166
+ se.run('puts "toto"; raise Exception')
167
+ end
168
+ assert_equal(['toto'], se.output)
169
+ end
170
+
171
+ # FIXME: this test block if DRb::SessionManager test suite is executed before
172
+ # this test suite in check-ruby_ex.
173
+ # def test_exception_no_collect
174
+ # se = SafeEval.new(3, false)
175
+ # assert_raises(Exception) do
176
+ # se.run('puts "toto"; raise Exception')
177
+ # end
178
+ # assert_equal(nil, se.output)
179
+ # end
180
+
181
+ def test_require_forbidden
182
+ se = SafeEval.new
183
+ assert_raises(SecurityError) do
184
+ se.run("require 'foo'")
185
+ end
186
+ assert_equal([], se.output)
187
+ end
188
+
189
+ def test_File_chmod_forbidden
190
+ se = SafeEval.new
191
+ assert_raises(SecurityError) do
192
+ se.run("File.chmod('/tmp', 0755)")
193
+ end
194
+ assert_equal([], se.output)
195
+ end
196
+
197
+ def test_system_forbidden
198
+ se = SafeEval.new
199
+ assert_raises(SecurityError) do
200
+ se.run("system('rm /tmp/x')")
201
+ end
202
+ assert_equal([], se.output)
203
+ end
204
+
205
+ def test_system_allowed
206
+ se = SafeEval.new(2)
207
+ se.run("system(\"echo 'toto'\")")
208
+ assert_equal(['toto'], se.output)
209
+ end
210
+
211
+ def test_print
212
+ se = SafeEval.new
213
+ assert_equal(nil, se.run('print "hello"'))
214
+ assert_equal(['hello'], se.output)
215
+ end
216
+
217
+ def test_puts
218
+ se = SafeEval.new
219
+ assert_equal(nil, se.run('puts "hello"'))
220
+ assert_equal(['hello'], se.output)
221
+ end
222
+
223
+ def test_print_no_collect
224
+ se = SafeEval.new(3, false)
225
+ assert_equal(nil, se.run('print "hello"'))
226
+ assert_equal(nil, se.output)
227
+ end
228
+
229
+ def test_puts_several_lines
230
+ se = SafeEval.new
231
+ assert_equal(nil, se.run('puts "hello\nworld"'))
232
+ assert_equal(['hello', 'world'], se.output)
233
+ end
234
+
235
+ def test_syntax_error
236
+ se = SafeEval.new
237
+ assert_raises(SyntaxError) do
238
+ se.run('4syntaxerror')
239
+ end
240
+ assert_equal([], se.output)
241
+ end
242
+
243
+ def test_bad_identifier
244
+ se = SafeEval.new
245
+ assert_raises(NameError) do
246
+ se.run('bad_identifier.directory?')
247
+ end
248
+ assert_equal([], se.output)
249
+ end
250
+
251
+ def test_syntax_error_location
252
+ se = SafeEval.new
253
+ exc = assert_raises(SyntaxError) do
254
+ se.run('4syntaxerror', nil, 'toto.yml', 1)
255
+ end
256
+ expected_message = <<EOF
257
+ compile error
258
+ toto.yml:1: syntax error
259
+ 4syntaxerror
260
+ ^
261
+ EOF
262
+ expected_message.chomp!
263
+ assert_equal(expected_message, exc.message)
264
+ end
265
+
266
+ def test_syntax_error_location_several_line
267
+ code = <<EOF
268
+ puts "hello"
269
+ puts "world"
270
+ 4syntaxerror;
271
+ EOF
272
+ se = SafeEval.new
273
+ exc = assert_raises(SyntaxError) do
274
+ se.run(code, nil, 'toto.yml', 1)
275
+ end
276
+ expected_message = <<EOF
277
+ compile error
278
+ toto.yml:3: syntax error
279
+ 4syntaxerror;
280
+ ^
281
+ EOF
282
+ expected_message.chomp!
283
+ assert_equal(expected_message, exc.message)
284
+ end
285
+
286
+ def test_exit_forbidden
287
+ se = SafeEval.new(3, false)
288
+ assert_raises(SystemExit) do
289
+ se.run('exit(42)')
290
+ end
291
+ assert_equal(nil, se.output)
292
+ end
293
+
294
+ def test_exit_strong_forbidden
295
+ se = SafeEval.new
296
+ assert_raises(EOFError) do
297
+ se.run('exit!(42)')
298
+ end
299
+ assert_equal([], se.output)
300
+ end
301
+
302
+ def test_undef_me
303
+ se = SafeEval.new
304
+ assert_raises(NoMethodError) do
305
+ se.run('undef_method :run')
306
+ end
307
+ end
308
+
309
+ def test_read_my_var
310
+ se = SafeEval.new
311
+ str = 'puts code'
312
+ se.run(str)
313
+ assert_equal(str, se.output[-1])
314
+ end
315
+
316
+ def test_write_status
317
+ se = SafeEval.new
318
+ assert_equal(1, se.run('status = 1'))
319
+ end
320
+
321
+ def test_write_safe
322
+ se = SafeEval.new
323
+ assert_equal(1, se.run('@safe = 1'))
324
+ assert_equal(true, se.run('@safe == 3'))
325
+ end
326
+
327
+ def test_write_output
328
+ se = SafeEval.new
329
+ assert_equal(['foo'], se.run('@output << "foo"'))
330
+ assert_equal([], se.output)
331
+ end
332
+
333
+ def test_write_output_and_print
334
+ se = SafeEval.new
335
+ assert_equal(nil, se.run('@output << "foo"; p @output'))
336
+ assert_equal(["[\"foo\"]"], se.output)
337
+ end
338
+
339
+ def test_sleep
340
+ se = SafeEval.new
341
+ assert(se.run('sleep(1)') >= 1)
342
+ assert_equal([], se.output)
343
+ end
344
+
345
+ end # class SafeEvalTest
346
+
347
+
348
+ end