rbbt-util 5.5.68 → 5.6.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.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rbbt/association.rb +1 -1
  3. data/lib/rbbt/association/index.rb +2 -1
  4. data/lib/rbbt/entity.rb +2 -0
  5. data/lib/rbbt/persist/tsv.rb +46 -232
  6. data/lib/rbbt/persist/tsv/cdb.rb +139 -0
  7. data/lib/rbbt/persist/tsv/kyotocabinet.rb +168 -0
  8. data/lib/rbbt/persist/tsv/leveldb.rb +121 -0
  9. data/lib/rbbt/persist/tsv/lmdb.rb +148 -0
  10. data/lib/rbbt/persist/tsv/tokyocabinet.rb +158 -0
  11. data/lib/rbbt/resource/rake.rb +2 -1
  12. data/lib/rbbt/tsv/accessor.rb +74 -101
  13. data/lib/rbbt/tsv/parser.rb +2 -5
  14. data/lib/rbbt/tsv/serializers.rb +6 -0
  15. data/lib/rbbt/tsv/util.rb +8 -2
  16. data/lib/rbbt/util/R.rb +6 -0
  17. data/lib/rbbt/util/cmd.rb +7 -4
  18. data/lib/rbbt/util/misc.rb +10 -4
  19. data/lib/rbbt/util/open.rb +8 -6
  20. data/lib/rbbt/util/simpleopt.rb +1 -1
  21. data/lib/rbbt/workflow.rb +17 -3
  22. data/lib/rbbt/workflow/accessor.rb +5 -1
  23. data/lib/rbbt/workflow/definition.rb +6 -0
  24. data/lib/rbbt/workflow/step.rb +10 -4
  25. data/lib/rbbt/workflow/task.rb +1 -1
  26. data/share/rbbt_commands/tsv/json +37 -0
  27. data/share/rbbt_commands/workflow/task +8 -2
  28. data/test/rbbt/persist/test_tsv.rb +77 -0
  29. data/test/rbbt/persist/tsv/test_cdb.rb +23 -0
  30. data/test/rbbt/persist/tsv/test_kyotocabinet.rb +33 -0
  31. data/test/rbbt/persist/tsv/test_leveldb.rb +22 -0
  32. data/test/rbbt/persist/tsv/test_lmdb.rb +22 -0
  33. data/test/rbbt/persist/tsv/test_tokyocabinet.rb +242 -0
  34. data/test/rbbt/test_persist.rb +1 -225
  35. data/test/rbbt/test_workflow.rb +0 -1
  36. data/test/rbbt/workflow/test_step.rb +14 -12
  37. data/test/test_helper.rb +4 -2
  38. metadata +20 -4
  39. data/test/rbbt/workflow/test_soap.rb +0 -105
@@ -1,5 +1,6 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
  require 'rbbt/persist'
3
+ require 'rbbt/annotations'
3
4
  require 'rbbt/util/tmpfile'
4
5
  require 'test/unit'
5
6
 
@@ -11,231 +12,6 @@ end
11
12
 
12
13
  class TestPersist < Test::Unit::TestCase
13
14
 
14
- def test_annotation_persist
15
- TmpFile.with_file do |tmp|
16
- entity1 = "Entity 1"
17
- entity2 = "Entity 2"
18
-
19
- TestAnnotation.setup(entity1, :test_annotation => "1")
20
- TestAnnotation.setup(entity2, :test_annotation => "2")
21
-
22
- annotations = [entity1, entity2]
23
-
24
- persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
25
- annotations
26
- end
27
-
28
- assert_equal "Entity 1", persisted_annotations.first
29
- assert_equal "Entity 2", persisted_annotations.last
30
- assert_equal "1", persisted_annotations.first.test_annotation
31
- assert_equal "2", persisted_annotations.last.test_annotation
32
-
33
- persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
34
- annotations
35
- end
36
-
37
- assert_equal "Entity 1", persisted_annotations.sort.first
38
- assert_equal "Entity 2", persisted_annotations.sort.last
39
- assert_equal "1", persisted_annotations.sort.first.test_annotation
40
- assert_equal "2", persisted_annotations.sort.last.test_annotation
41
- end
42
- end
43
-
44
- def test_annotation_persist_with_repeitions
45
- TmpFile.with_file do |tmp|
46
- entity1 = "Entity 1"
47
- entity2 = "Entity 2"
48
- entity2bis = "Entity 2"
49
-
50
- TestAnnotation.setup(entity1, :test_annotation => "1")
51
- TestAnnotation.setup(entity2, :test_annotation => "2")
52
- TestAnnotation.setup(entity2bis, :test_annotation => "2")
53
-
54
- annotations = [entity1, entity2, entity2bis]
55
-
56
- persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
57
- annotations
58
- end
59
-
60
- assert_equal 3, persisted_annotations.length
61
-
62
- assert_equal "Entity 1", persisted_annotations.first
63
- assert_equal "Entity 2", persisted_annotations.last
64
- assert_equal "1", persisted_annotations.first.test_annotation
65
- assert_equal "2", persisted_annotations.last.test_annotation
66
-
67
- persisted_annotations = Persist.persist("Test", :annotations, :file => tmp) do
68
- annotations
69
- end
70
-
71
- assert_equal 3, persisted_annotations.length
72
-
73
- assert_equal "Entity 1", persisted_annotations.sort.first
74
- assert_equal "Entity 2", persisted_annotations.sort.last
75
- assert_equal "1", persisted_annotations.sort.first.test_annotation
76
- assert_equal "2", persisted_annotations.sort.last.test_annotation
77
- end
78
- end
79
-
80
-
81
- def test_bdb
82
- TmpFile.with_file do |tmp|
83
- repo = Persist.open_tokyocabinet(tmp, true, :double, TokyoCabinet::BDB)
84
- repo["test:string1"] = [["STR1"]]
85
- repo["test:string2"] = [["STR2"]]
86
- repo["other_test:string3"] = [["STR2"]]
87
-
88
- assert_equal ["test:string1", "test:string2"].sort, repo.range("test:" << 0.chr, false, "test:" << 255.chr, false).sort
89
- assert_equal ["other_test:string3"].sort, repo.range("other_test:" << 0.chr, false, "other_test:" << 255.chr, false).sort
90
- end
91
- end
92
-
93
- def test_annotation_persist_repo
94
- TmpFile.with_file do |tmp|
95
- repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
96
-
97
- entity1 = "Entity 1"
98
- entity2 = "Entity 2"
99
-
100
- TestAnnotation.setup(entity1, :test_annotation => "1")
101
- TestAnnotation.setup(entity2, :test_annotation => "2")
102
-
103
- annotations = [entity1, entity2]
104
-
105
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
106
- annotations
107
- end
108
-
109
- assert_equal "Entity 1", persisted_annotations.first
110
- assert_equal "Entity 2", persisted_annotations.last
111
- assert_equal "1", persisted_annotations.first.test_annotation
112
- assert_equal "2", persisted_annotations.last.test_annotation
113
-
114
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
115
- annotations
116
- end
117
-
118
- assert_equal "Entity 1", persisted_annotations.sort.first
119
- assert_equal "Entity 2", persisted_annotations.sort.last
120
- assert_equal "1", persisted_annotations.sort.first.test_annotation
121
- assert_equal "2", persisted_annotations.sort.last.test_annotation
122
- end
123
- end
124
-
125
- def test_annotation_persist_repo_annotated_array
126
- TmpFile.with_file do |tmp|
127
- repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
128
-
129
- entity1 = "Entity 1"
130
- entity2 = "Entity 2"
131
-
132
- annotations = [entity1, entity2]
133
- TestAnnotation.setup(annotations, :test_annotation => "1")
134
- annotations.extend AnnotatedArray
135
-
136
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
137
- annotations
138
- end
139
-
140
- assert_equal "Entity 1", persisted_annotations.first
141
- assert_equal "Entity 2", persisted_annotations.last
142
- assert_equal "1", persisted_annotations.first.test_annotation
143
- assert_equal "1", persisted_annotations.last.test_annotation
144
-
145
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
146
- annotations
147
- end
148
-
149
- persisted_annotations.extend AnnotatedArray
150
-
151
- assert_equal "Entity 1", persisted_annotations.sort.first
152
- assert_equal "Entity 2", persisted_annotations.sort.last
153
- assert_equal "1", persisted_annotations.sort.first.test_annotation
154
- assert_equal "1", persisted_annotations.sort.last.test_annotation
155
- end
156
- end
157
-
158
-
159
- def test_annotation_persist_repo_triple_array
160
- TmpFile.with_file do |tmp|
161
- repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
162
-
163
- entity1 = "Entity 1"
164
- entity2 = "Entity 2"
165
-
166
- annotations = [entity1, entity2]
167
- TestAnnotation.setup(annotations, :test_annotation => "1")
168
- annotations.extend AnnotatedArray
169
-
170
- annotations_ary = [annotations]
171
- TestAnnotation.setup(annotations_ary, :test_annotation => "1")
172
- annotations_ary.extend AnnotatedArray
173
-
174
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
175
- annotations_ary
176
- end
177
- assert AnnotatedArray === persisted_annotations
178
- ddd persisted_annotations.info
179
- ddd persisted_annotations
180
-
181
- assert_equal "Entity 1", persisted_annotations.first.first
182
- assert_equal "Entity 2", persisted_annotations.first.last
183
- assert_equal "1", persisted_annotations.first.first.test_annotation
184
- assert_equal "1", persisted_annotations.first.last.test_annotation
185
-
186
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
187
- annotations_ary
188
- end
189
-
190
- assert AnnotatedArray === persisted_annotations
191
-
192
- assert_equal "Entity 1", persisted_annotations.sort.first.first
193
- assert_equal "Entity 2", persisted_annotations.sort.first.last
194
- assert_equal "1", persisted_annotations.sort.first.first.test_annotation
195
- assert_equal "1", persisted_annotations.sort.first.last.test_annotation
196
-
197
- end
198
- end
199
-
200
- def test_annotation_persist_repo_with_repetitions
201
- TmpFile.with_file do |tmp|
202
- repo = Persist.open_tokyocabinet(tmp, true, :list, TokyoCabinet::BDB)
203
-
204
- entity1 = "Entity 1"
205
- entity2 = "Entity 2"
206
- entity2bis = "Entity 2"
207
-
208
- TestAnnotation.setup(entity1, :test_annotation => "1")
209
- TestAnnotation.setup(entity2, :test_annotation => "2")
210
- TestAnnotation.setup(entity2bis, :test_annotation => "2")
211
-
212
- annotations = [entity1, entity2, entity2bis]
213
-
214
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
215
- annotations
216
- end
217
-
218
- assert_equal 3, persisted_annotations.length
219
-
220
- assert_equal "Entity 1", persisted_annotations.first
221
- assert_equal "Entity 2", persisted_annotations.last
222
- assert_equal "1", persisted_annotations.first.test_annotation
223
- assert_equal "2", persisted_annotations.last.test_annotation
224
-
225
- persisted_annotations = Persist.persist("Test", :annotations, :annotation_repo => repo) do
226
- annotations
227
- end
228
-
229
- assert_equal 3, persisted_annotations.length
230
-
231
- assert_equal "Entity 1", persisted_annotations.sort.first
232
- assert_equal "Entity 2", persisted_annotations.sort.last
233
- assert_equal "1", persisted_annotations.sort.first.test_annotation
234
- assert_equal "2", persisted_annotations.sort.last.test_annotation
235
- end
236
- end
237
-
238
-
239
15
  def test_array_persist
240
16
  TmpFile.with_file do |tmp|
241
17
  10.times do
@@ -1,6 +1,5 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
2
2
  require 'rbbt/workflow'
3
- require 'rbbt/workflow/soap'
4
3
  require 'rbbt/util/tmpfile'
5
4
  require 'test/unit'
6
5
 
@@ -6,7 +6,7 @@ require 'rbbt'
6
6
 
7
7
  class TestStep < Test::Unit::TestCase
8
8
 
9
- def _test_step
9
+ def test_step
10
10
  task = Task.setup do "TEST" end
11
11
  task2 = Task.setup do raise "Persistence ignored" end
12
12
  TmpFile.with_file do |tmp|
@@ -18,7 +18,7 @@ class TestStep < Test::Unit::TestCase
18
18
  end
19
19
  end
20
20
 
21
- def _test_dependency
21
+ def test_dependency
22
22
  str = "TEST"
23
23
  str2 = "TEST2"
24
24
  TmpFile.with_file do |tmpfile|
@@ -47,7 +47,7 @@ class TestStep < Test::Unit::TestCase
47
47
  end
48
48
  end
49
49
 
50
- def _test_dependency_log_relay
50
+ def test_dependency_log_relay
51
51
  str = "TEST"
52
52
  TmpFile.with_file do |tmpfile|
53
53
  task1 = Task.setup :result_type => nil, :name => :task1 do
@@ -66,7 +66,7 @@ class TestStep < Test::Unit::TestCase
66
66
  end
67
67
  end
68
68
 
69
- def _test_log_relay_step
69
+ def test_log_relay_step
70
70
  str = "TEST"
71
71
  TmpFile.with_file do |tmpfile|
72
72
  task1 = Task.setup :result_type => nil, :name => :task1 do
@@ -88,7 +88,7 @@ class TestStep < Test::Unit::TestCase
88
88
  end
89
89
 
90
90
 
91
- def _test_exec
91
+ def test_exec
92
92
  TmpFile.with_file do |lock|
93
93
  task = Task.setup do "TEST" end
94
94
  TmpFile.with_file do |tmp|
@@ -99,7 +99,7 @@ class TestStep < Test::Unit::TestCase
99
99
  end
100
100
 
101
101
 
102
- def _test_fork
102
+ def test_fork
103
103
  TmpFile.with_file do |lock|
104
104
  task = Task.setup do while not File.exists?(lock) do sleep 1; end; "TEST" end
105
105
  TmpFile.with_file do |tmp|
@@ -115,7 +115,7 @@ class TestStep < Test::Unit::TestCase
115
115
  end
116
116
  end
117
117
 
118
- def _test_abort
118
+ def test_abort
119
119
  TmpFile.with_file do |lock|
120
120
  task = Task.setup do while not File.exists?(lock) do sleep 1; end; "TEST" end
121
121
  TmpFile.with_file do |tmp|
@@ -132,7 +132,7 @@ class TestStep < Test::Unit::TestCase
132
132
  end
133
133
  end
134
134
 
135
- def _test_files
135
+ def test_files
136
136
  TmpFile.with_file do |lock|
137
137
  task = Task.setup do
138
138
  Open.write(file("test"),"TEST")
@@ -146,15 +146,17 @@ class TestStep < Test::Unit::TestCase
146
146
  end
147
147
  end
148
148
 
149
- def _test_messages
149
+ def test_messages
150
150
  TmpFile.with_file do |lock|
151
151
  task = Task.setup do
152
152
  message "WRITE"
153
153
  Open.write(file("test"),"TEST")
154
154
  end
155
+
155
156
  TmpFile.with_file do |tmp|
156
157
  step = Step.new tmp, task
157
- job = step.fork
158
+ job = step
159
+ step.run
158
160
  while not job.done? do sleep 1 end
159
161
  assert_equal "TEST", Open.read(job.file("test"))
160
162
  assert_equal "WRITE", job.messages.last
@@ -162,7 +164,7 @@ class TestStep < Test::Unit::TestCase
162
164
  end
163
165
  end
164
166
 
165
- def _test_subdir
167
+ def test_subdir
166
168
  TmpFile.with_file do |lock|
167
169
  task = Task.setup do
168
170
  message "WRITE"
@@ -179,7 +181,7 @@ class TestStep < Test::Unit::TestCase
179
181
  end
180
182
  end
181
183
 
182
- def _test_semaphore
184
+ def test_semaphore
183
185
  TmpFile.with_file do |semaphore|
184
186
  begin
185
187
  semaphore = "/" << semaphore.gsub('/','_')
data/test/test_helper.rb CHANGED
@@ -8,10 +8,12 @@ require 'rubygems'
8
8
  require 'rbbt'
9
9
  require 'rbbt/resource/path'
10
10
 
11
+
11
12
  class Test::Unit::TestCase
12
13
  include FileUtils
13
14
 
14
15
  def setup
16
+ Random.new
15
17
  if defined? Persist
16
18
  Persist.cachedir = Rbbt.tmp.test.persistence.find :user
17
19
  end
@@ -20,8 +22,8 @@ class Test::Unit::TestCase
20
22
  def teardown
21
23
  if defined? Persist
22
24
  FileUtils.rm_rf Path.setup("", 'rbbt').tmp.test.find :user
23
- Persist::TC_CONNECTIONS.values.each do |c| c.close end
24
- Persist::TC_CONNECTIONS.clear
25
+ Persist::CONNECTIONS.values.each do |c| c.close end
26
+ Persist::CONNECTIONS.clear
25
27
  end
26
28
  end
27
29
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.5.68
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -160,6 +160,11 @@ files:
160
160
  - lib/rbbt/knowledge_base.rb
161
161
  - lib/rbbt/persist.rb
162
162
  - lib/rbbt/persist/tsv.rb
163
+ - lib/rbbt/persist/tsv/cdb.rb
164
+ - lib/rbbt/persist/tsv/kyotocabinet.rb
165
+ - lib/rbbt/persist/tsv/leveldb.rb
166
+ - lib/rbbt/persist/tsv/lmdb.rb
167
+ - lib/rbbt/persist/tsv/tokyocabinet.rb
163
168
  - lib/rbbt/resource.rb
164
169
  - lib/rbbt/resource/path.rb
165
170
  - lib/rbbt/resource/rake.rb
@@ -225,6 +230,7 @@ files:
225
230
  - share/rbbt_commands/tsv/change_id
226
231
  - share/rbbt_commands/tsv/get
227
232
  - share/rbbt_commands/tsv/info
233
+ - share/rbbt_commands/tsv/json
228
234
  - share/rbbt_commands/workflow/cmd
229
235
  - share/rbbt_commands/workflow/install
230
236
  - share/rbbt_commands/workflow/monitor
@@ -236,6 +242,12 @@ files:
236
242
  - share/unicorn.rb
237
243
  - test/rbbt/association/test_index.rb
238
244
  - test/rbbt/association/test_item.rb
245
+ - test/rbbt/persist/test_tsv.rb
246
+ - test/rbbt/persist/tsv/test_cdb.rb
247
+ - test/rbbt/persist/tsv/test_kyotocabinet.rb
248
+ - test/rbbt/persist/tsv/test_leveldb.rb
249
+ - test/rbbt/persist/tsv/test_lmdb.rb
250
+ - test/rbbt/persist/tsv/test_tokyocabinet.rb
239
251
  - test/rbbt/resource/test_path.rb
240
252
  - test/rbbt/test_annotations.rb
241
253
  - test/rbbt/test_association.rb
@@ -264,7 +276,6 @@ files:
264
276
  - test/rbbt/util/test_simpleDSL.rb
265
277
  - test/rbbt/util/test_simpleopt.rb
266
278
  - test/rbbt/util/test_tmpfile.rb
267
- - test/rbbt/workflow/test_soap.rb
268
279
  - test/rbbt/workflow/test_step.rb
269
280
  - test/rbbt/workflow/test_task.rb
270
281
  - test/test_helper.rb
@@ -313,11 +324,16 @@ test_files:
313
324
  - test/rbbt/association/test_index.rb
314
325
  - test/rbbt/association/test_item.rb
315
326
  - test/rbbt/test_tsv.rb
316
- - test/rbbt/workflow/test_soap.rb
317
327
  - test/rbbt/workflow/test_task.rb
318
328
  - test/rbbt/workflow/test_step.rb
319
329
  - test/rbbt/test_persist.rb
320
330
  - test/rbbt/test_annotations.rb
331
+ - test/rbbt/persist/test_tsv.rb
332
+ - test/rbbt/persist/tsv/test_lmdb.rb
333
+ - test/rbbt/persist/tsv/test_kyotocabinet.rb
334
+ - test/rbbt/persist/tsv/test_cdb.rb
335
+ - test/rbbt/persist/tsv/test_tokyocabinet.rb
336
+ - test/rbbt/persist/tsv/test_leveldb.rb
321
337
  - test/rbbt/tsv/test_index.rb
322
338
  - test/rbbt/tsv/test_change_id.rb
323
339
  - test/rbbt/tsv/test_util.rb