io_shuten 0.1.0.dev6 → 0.1.0.dev7
Sign up to get free protection for your applications and to get access to all the features.
- data/doc/IO_shuten/Base.html +78 -99
- data/doc/IO_shuten/Buffer.html +130 -150
- data/doc/IO_shuten/Errors/FileAccessError.html +4 -5
- data/doc/IO_shuten/Errors/FileNotFoundError.html +4 -5
- data/doc/IO_shuten/Errors/NodeExistsError.html +4 -5
- data/doc/IO_shuten/Errors/NodeNameError.html +4 -5
- data/doc/IO_shuten/Errors/NodeNotFoundError.html +4 -5
- data/doc/IO_shuten/Errors/NotYetImplemented.html +4 -5
- data/doc/IO_shuten/Errors.html +4 -5
- data/doc/IO_shuten/Memory.html +127 -147
- data/doc/IO_shuten/Mongo.html +6 -8
- data/doc/IO_shuten/Redis.html +164 -263
- data/doc/IO_shuten/Stores/BaseContainer.html +377 -0
- data/doc/IO_shuten/Stores/Mongo/Collection.html +4 -5
- data/doc/IO_shuten/Stores/Mongo/GridFS.html +4 -5
- data/doc/IO_shuten/Stores/Mongo.html +4 -5
- data/doc/IO_shuten/Stores/Redis/Container.html +778 -0
- data/doc/IO_shuten/Stores/Redis/KeyValue/Collection.html +504 -0
- data/doc/IO_shuten/Stores/Redis/KeyValue/Single.html +438 -0
- data/doc/IO_shuten/Stores/Redis/KeyValue.html +176 -7
- data/doc/IO_shuten/Stores/Redis/PubSub.html +140 -5
- data/doc/IO_shuten/Stores/Redis.html +7 -6
- data/doc/IO_shuten/Stores.html +6 -7
- data/doc/IO_shuten/Zmq.html +166 -0
- data/doc/IO_shuten.html +6 -7
- data/doc/_index.html +49 -6
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +10 -3
- data/doc/index.html +10 -3
- data/doc/method_list.html +160 -24
- data/doc/top-level-namespace.html +2 -2
- data/io_shuten.gemspec +6 -1
- data/lib/io_shuten/buffer.rb +8 -6
- data/lib/io_shuten/memory.rb +8 -5
- data/lib/io_shuten/version.rb +1 -1
- data/spec/lib/buffer_spec.rb +43 -0
- data/spec/lib/memory_spec.rb +49 -0
- data/spec/lib/redis_spec.rb +15 -1
- metadata +49 -44
data/doc/index.html
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
4
|
<head>
|
5
|
-
<meta http-equiv="Content-Type" content="text/html; charset=
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
6
6
|
<title>
|
7
7
|
File: README
|
8
8
|
|
@@ -113,6 +113,13 @@ A logger only needs write and close methods of an IO object.</p>
|
|
113
113
|
<p>Provides basic methods like <code>#read</code>, <code>#write</code> and <code>#close</code>.
|
114
114
|
A logger only needs write and close methods of an IO object.</p>
|
115
115
|
|
116
|
+
<h3>IO_shuten::Zmq</h3>
|
117
|
+
|
118
|
+
<p>"Stores" content in a zmq socket.</p>
|
119
|
+
|
120
|
+
<p>Provides basic methods like <code>#read</code>, <code>#write</code> and <code>#close</code>.
|
121
|
+
A logger only needs write and close methods of an IO object.</p>
|
122
|
+
|
116
123
|
<h2>Not for production!</h2>
|
117
124
|
|
118
125
|
<p>This project is freshly started and currently not usable.</p>
|
@@ -142,9 +149,9 @@ A logger only needs write and close methods of an IO object.</p>
|
|
142
149
|
</div></div>
|
143
150
|
|
144
151
|
<div id="footer">
|
145
|
-
Generated on
|
152
|
+
Generated on Mon Jan 30 01:52:35 2012 by
|
146
153
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
147
|
-
0.7.4 (ruby-1.
|
154
|
+
0.7.4 (ruby-1.9.3).
|
148
155
|
</div>
|
149
156
|
|
150
157
|
</body>
|
data/doc/method_list.html
CHANGED
@@ -41,9 +41,41 @@
|
|
41
41
|
|
42
42
|
|
43
43
|
<li class="r1 ">
|
44
|
-
<span class='object_link'><a href="IO_shuten/Redis.html#
|
44
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#backend-instance_method" title="IO_shuten::Stores::Redis::Container#backend (method)">#backend</a></span>
|
45
45
|
|
46
|
-
<small>IO_shuten::Redis</small>
|
46
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
47
|
+
|
48
|
+
</li>
|
49
|
+
|
50
|
+
|
51
|
+
<li class="r2 ">
|
52
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#backend_spec-instance_method" title="IO_shuten::Stores::Redis::Container#backend_spec (method)">#backend_spec</a></span>
|
53
|
+
|
54
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
55
|
+
|
56
|
+
</li>
|
57
|
+
|
58
|
+
|
59
|
+
<li class="r1 ">
|
60
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Single.html#clear%21-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Single#clear! (method)">#clear!</a></span>
|
61
|
+
|
62
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Single</small>
|
63
|
+
|
64
|
+
</li>
|
65
|
+
|
66
|
+
|
67
|
+
<li class="r2 ">
|
68
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Collection.html#clear%21-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Collection#clear! (method)">#clear!</a></span>
|
69
|
+
|
70
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Collection</small>
|
71
|
+
|
72
|
+
</li>
|
73
|
+
|
74
|
+
|
75
|
+
<li class="r1 ">
|
76
|
+
<span class='object_link'><a href="IO_shuten/Stores/BaseContainer.html#close-instance_method" title="IO_shuten::Stores::BaseContainer#close (method)">#close</a></span>
|
77
|
+
|
78
|
+
<small>IO_shuten::Stores::BaseContainer</small>
|
47
79
|
|
48
80
|
</li>
|
49
81
|
|
@@ -81,17 +113,17 @@
|
|
81
113
|
|
82
114
|
|
83
115
|
<li class="r2 ">
|
84
|
-
<span class='object_link'><a href="IO_shuten/
|
116
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#initialize-instance_method" title="IO_shuten::Stores::Redis::Container#initialize (method)">#initialize</a></span>
|
85
117
|
|
86
|
-
<small>IO_shuten::
|
118
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
87
119
|
|
88
120
|
</li>
|
89
121
|
|
90
122
|
|
91
123
|
<li class="r1 ">
|
92
|
-
<span class='object_link'><a href="IO_shuten/
|
124
|
+
<span class='object_link'><a href="IO_shuten/Buffer.html#initialize-instance_method" title="IO_shuten::Buffer#initialize (method)">#initialize</a></span>
|
93
125
|
|
94
|
-
<small>IO_shuten::
|
126
|
+
<small>IO_shuten::Buffer</small>
|
95
127
|
|
96
128
|
</li>
|
97
129
|
|
@@ -105,15 +137,15 @@
|
|
105
137
|
|
106
138
|
|
107
139
|
<li class="r1 ">
|
108
|
-
<span class='object_link'><a href="IO_shuten/
|
140
|
+
<span class='object_link'><a href="IO_shuten/Memory.html#initialize-instance_method" title="IO_shuten::Memory#initialize (method)">#initialize</a></span>
|
109
141
|
|
110
|
-
<small>IO_shuten::
|
142
|
+
<small>IO_shuten::Memory</small>
|
111
143
|
|
112
144
|
</li>
|
113
145
|
|
114
146
|
|
115
147
|
<li class="r2 ">
|
116
|
-
<span class='object_link'><a href="IO_shuten/Base.html#
|
148
|
+
<span class='object_link'><a href="IO_shuten/Base.html#instance_exists%3F-class_method" title="IO_shuten::Base.instance_exists? (method)">instance_exists?</a></span>
|
117
149
|
|
118
150
|
<small>IO_shuten::Base</small>
|
119
151
|
|
@@ -121,23 +153,23 @@
|
|
121
153
|
|
122
154
|
|
123
155
|
<li class="r1 ">
|
124
|
-
<span class='object_link'><a href="IO_shuten/
|
156
|
+
<span class='object_link'><a href="IO_shuten/Base.html#instances-class_method" title="IO_shuten::Base.instances (method)">instances</a></span>
|
125
157
|
|
126
|
-
<small>IO_shuten::
|
158
|
+
<small>IO_shuten::Base</small>
|
127
159
|
|
128
160
|
</li>
|
129
161
|
|
130
162
|
|
131
163
|
<li class="r2 ">
|
132
|
-
<span class='object_link'><a href="IO_shuten/
|
164
|
+
<span class='object_link'><a href="IO_shuten/Buffer.html#load_from_file-instance_method" title="IO_shuten::Buffer#load_from_file (method)">#load_from_file</a></span>
|
133
165
|
|
134
|
-
<small>IO_shuten::
|
166
|
+
<small>IO_shuten::Buffer</small>
|
135
167
|
|
136
168
|
</li>
|
137
169
|
|
138
170
|
|
139
171
|
<li class="r1 ">
|
140
|
-
<span class='object_link'><a href="IO_shuten/Memory.html#
|
172
|
+
<span class='object_link'><a href="IO_shuten/Memory.html#load_from_file-instance_method" title="IO_shuten::Memory#load_from_file (method)">#load_from_file</a></span>
|
141
173
|
|
142
174
|
<small>IO_shuten::Memory</small>
|
143
175
|
|
@@ -153,6 +185,14 @@
|
|
153
185
|
|
154
186
|
|
155
187
|
<li class="r1 ">
|
188
|
+
<span class='object_link'><a href="IO_shuten/Memory.html#load_instances-class_method" title="IO_shuten::Memory.load_instances (method)">load_instances</a></span>
|
189
|
+
|
190
|
+
<small>IO_shuten::Memory</small>
|
191
|
+
|
192
|
+
</li>
|
193
|
+
|
194
|
+
|
195
|
+
<li class="r2 ">
|
156
196
|
<span class='object_link'><a href="IO_shuten/Base.html#node_name-instance_method" title="IO_shuten::Base#node_name (method)">#node_name</a></span>
|
157
197
|
|
158
198
|
<small>IO_shuten::Base</small>
|
@@ -160,7 +200,7 @@
|
|
160
200
|
</li>
|
161
201
|
|
162
202
|
|
163
|
-
<li class="
|
203
|
+
<li class="r1 ">
|
164
204
|
<span class='object_link'><a href="IO_shuten/Buffer.html#open-class_method" title="IO_shuten::Buffer.open (method)">open</a></span>
|
165
205
|
|
166
206
|
<small>IO_shuten::Buffer</small>
|
@@ -168,7 +208,7 @@
|
|
168
208
|
</li>
|
169
209
|
|
170
210
|
|
171
|
-
<li class="
|
211
|
+
<li class="r2 ">
|
172
212
|
<span class='object_link'><a href="IO_shuten/Memory.html#open-class_method" title="IO_shuten::Memory.open (method)">open</a></span>
|
173
213
|
|
174
214
|
<small>IO_shuten::Memory</small>
|
@@ -176,7 +216,7 @@
|
|
176
216
|
</li>
|
177
217
|
|
178
218
|
|
179
|
-
<li class="
|
219
|
+
<li class="r1 ">
|
180
220
|
<span class='object_link'><a href="IO_shuten/Base.html#purge_instances%21-class_method" title="IO_shuten::Base.purge_instances! (method)">purge_instances!</a></span>
|
181
221
|
|
182
222
|
<small>IO_shuten::Base</small>
|
@@ -184,15 +224,47 @@
|
|
184
224
|
</li>
|
185
225
|
|
186
226
|
|
227
|
+
<li class="r2 ">
|
228
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Collection.html#read-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Collection#read (method)">#read</a></span>
|
229
|
+
|
230
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Collection</small>
|
231
|
+
|
232
|
+
</li>
|
233
|
+
|
234
|
+
|
187
235
|
<li class="r1 ">
|
188
|
-
<span class='object_link'><a href="IO_shuten/Redis.html#read-instance_method" title="IO_shuten::Redis#read (method)">#read</a></span>
|
236
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Single.html#read-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Single#read (method)">#read</a></span>
|
189
237
|
|
190
|
-
<small>IO_shuten::Redis</small>
|
238
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Single</small>
|
239
|
+
|
240
|
+
</li>
|
241
|
+
|
242
|
+
|
243
|
+
<li class="r2 ">
|
244
|
+
<span class='object_link'><a href="IO_shuten/Stores/BaseContainer.html#read-instance_method" title="IO_shuten::Stores::BaseContainer#read (method)">#read</a></span>
|
245
|
+
|
246
|
+
<small>IO_shuten::Stores::BaseContainer</small>
|
247
|
+
|
248
|
+
</li>
|
249
|
+
|
250
|
+
|
251
|
+
<li class="r1 ">
|
252
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Collection.html#read_collection-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Collection#read_collection (method)">#read_collection</a></span>
|
253
|
+
|
254
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Collection</small>
|
191
255
|
|
192
256
|
</li>
|
193
257
|
|
194
258
|
|
195
259
|
<li class="r2 ">
|
260
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Single.html#read_raw-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Single#read_raw (method)">#read_raw</a></span>
|
261
|
+
|
262
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Single</small>
|
263
|
+
|
264
|
+
</li>
|
265
|
+
|
266
|
+
|
267
|
+
<li class="r1 ">
|
196
268
|
<span class='object_link'><a href="IO_shuten/Redis.html#redis-class_method" title="IO_shuten::Redis.redis (method)">redis</a></span>
|
197
269
|
|
198
270
|
<small>IO_shuten::Redis</small>
|
@@ -200,6 +272,14 @@
|
|
200
272
|
</li>
|
201
273
|
|
202
274
|
|
275
|
+
<li class="r2 ">
|
276
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#redis-instance_method" title="IO_shuten::Stores::Redis::Container#redis (method)">#redis</a></span>
|
277
|
+
|
278
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
279
|
+
|
280
|
+
</li>
|
281
|
+
|
282
|
+
|
203
283
|
<li class="r1 ">
|
204
284
|
<span class='object_link'><a href="IO_shuten/Redis.html#redis%3D-class_method" title="IO_shuten::Redis.redis= (method)">redis=</a></span>
|
205
285
|
|
@@ -209,6 +289,14 @@
|
|
209
289
|
|
210
290
|
|
211
291
|
<li class="r2 ">
|
292
|
+
<span class='object_link'><a href="IO_shuten/Redis.html#redis_clear%21-class_method" title="IO_shuten::Redis.redis_clear! (method)">redis_clear!</a></span>
|
293
|
+
|
294
|
+
<small>IO_shuten::Redis</small>
|
295
|
+
|
296
|
+
</li>
|
297
|
+
|
298
|
+
|
299
|
+
<li class="r1 ">
|
212
300
|
<span class='object_link'><a href="IO_shuten/Buffer.html#save_instances-class_method" title="IO_shuten::Buffer.save_instances (method)">save_instances</a></span>
|
213
301
|
|
214
302
|
<small>IO_shuten::Buffer</small>
|
@@ -216,7 +304,7 @@
|
|
216
304
|
</li>
|
217
305
|
|
218
306
|
|
219
|
-
<li class="
|
307
|
+
<li class="r2 ">
|
220
308
|
<span class='object_link'><a href="IO_shuten/Memory.html#save_instances-class_method" title="IO_shuten::Memory.save_instances (method)">save_instances</a></span>
|
221
309
|
|
222
310
|
<small>IO_shuten::Memory</small>
|
@@ -224,7 +312,7 @@
|
|
224
312
|
</li>
|
225
313
|
|
226
314
|
|
227
|
-
<li class="
|
315
|
+
<li class="r1 ">
|
228
316
|
<span class='object_link'><a href="IO_shuten/Memory.html#save_to_file-instance_method" title="IO_shuten::Memory#save_to_file (method)">#save_to_file</a></span>
|
229
317
|
|
230
318
|
<small>IO_shuten::Memory</small>
|
@@ -232,7 +320,7 @@
|
|
232
320
|
</li>
|
233
321
|
|
234
322
|
|
235
|
-
<li class="
|
323
|
+
<li class="r2 ">
|
236
324
|
<span class='object_link'><a href="IO_shuten/Buffer.html#save_to_file-instance_method" title="IO_shuten::Buffer#save_to_file (method)">#save_to_file</a></span>
|
237
325
|
|
238
326
|
<small>IO_shuten::Buffer</small>
|
@@ -240,10 +328,58 @@
|
|
240
328
|
</li>
|
241
329
|
|
242
330
|
|
331
|
+
<li class="r1 ">
|
332
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#use_backend-instance_method" title="IO_shuten::Stores::Redis::Container#use_backend (method)">#use_backend</a></span>
|
333
|
+
|
334
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
335
|
+
|
336
|
+
</li>
|
337
|
+
|
338
|
+
|
243
339
|
<li class="r2 ">
|
244
|
-
<span class='object_link'><a href="IO_shuten/Redis.html#
|
340
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/Container.html#use_redis-instance_method" title="IO_shuten::Stores::Redis::Container#use_redis (method)">#use_redis</a></span>
|
245
341
|
|
246
|
-
<small>IO_shuten::Redis</small>
|
342
|
+
<small>IO_shuten::Stores::Redis::Container</small>
|
343
|
+
|
344
|
+
</li>
|
345
|
+
|
346
|
+
|
347
|
+
<li class="r1 ">
|
348
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/PubSub.html#use_type-instance_method" title="IO_shuten::Stores::Redis::PubSub#use_type (method)">#use_type</a></span>
|
349
|
+
|
350
|
+
<small>IO_shuten::Stores::Redis::PubSub</small>
|
351
|
+
|
352
|
+
</li>
|
353
|
+
|
354
|
+
|
355
|
+
<li class="r2 ">
|
356
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue.html#use_type-instance_method" title="IO_shuten::Stores::Redis::KeyValue#use_type (method)">#use_type</a></span>
|
357
|
+
|
358
|
+
<small>IO_shuten::Stores::Redis::KeyValue</small>
|
359
|
+
|
360
|
+
</li>
|
361
|
+
|
362
|
+
|
363
|
+
<li class="r1 ">
|
364
|
+
<span class='object_link'><a href="IO_shuten/Stores/BaseContainer.html#write-instance_method" title="IO_shuten::Stores::BaseContainer#write (method)">#write</a></span>
|
365
|
+
|
366
|
+
<small>IO_shuten::Stores::BaseContainer</small>
|
367
|
+
|
368
|
+
</li>
|
369
|
+
|
370
|
+
|
371
|
+
<li class="r2 ">
|
372
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Collection.html#write-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Collection#write (method)">#write</a></span>
|
373
|
+
|
374
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Collection</small>
|
375
|
+
|
376
|
+
</li>
|
377
|
+
|
378
|
+
|
379
|
+
<li class="r1 ">
|
380
|
+
<span class='object_link'><a href="IO_shuten/Stores/Redis/KeyValue/Single.html#write-instance_method" title="IO_shuten::Stores::Redis::KeyValue::Single#write (method)">#write</a></span>
|
381
|
+
|
382
|
+
<small>IO_shuten::Stores::Redis::KeyValue::Single</small>
|
247
383
|
|
248
384
|
</li>
|
249
385
|
|
@@ -96,9 +96,9 @@
|
|
96
96
|
</div>
|
97
97
|
|
98
98
|
<div id="footer">
|
99
|
-
Generated on
|
99
|
+
Generated on Mon Jan 30 01:52:37 2012 by
|
100
100
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
101
|
-
0.7.4 (ruby-1.
|
101
|
+
0.7.4 (ruby-1.9.3).
|
102
102
|
</div>
|
103
103
|
|
104
104
|
</body>
|
data/io_shuten.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "io_shuten"
|
8
|
-
s.version = "0.1.0.
|
8
|
+
s.version = "0.1.0.dev7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Christoph Grabo"]
|
@@ -54,12 +54,17 @@ Gem::Specification.new do |s|
|
|
54
54
|
"doc/IO_shuten/Mongo.html",
|
55
55
|
"doc/IO_shuten/Redis.html",
|
56
56
|
"doc/IO_shuten/Stores.html",
|
57
|
+
"doc/IO_shuten/Stores/BaseContainer.html",
|
57
58
|
"doc/IO_shuten/Stores/Mongo.html",
|
58
59
|
"doc/IO_shuten/Stores/Mongo/Collection.html",
|
59
60
|
"doc/IO_shuten/Stores/Mongo/GridFS.html",
|
60
61
|
"doc/IO_shuten/Stores/Redis.html",
|
62
|
+
"doc/IO_shuten/Stores/Redis/Container.html",
|
61
63
|
"doc/IO_shuten/Stores/Redis/KeyValue.html",
|
64
|
+
"doc/IO_shuten/Stores/Redis/KeyValue/Collection.html",
|
65
|
+
"doc/IO_shuten/Stores/Redis/KeyValue/Single.html",
|
62
66
|
"doc/IO_shuten/Stores/Redis/PubSub.html",
|
67
|
+
"doc/IO_shuten/Zmq.html",
|
63
68
|
"doc/_index.html",
|
64
69
|
"doc/class_list.html",
|
65
70
|
"doc/css/blame.css",
|
data/lib/io_shuten/buffer.rb
CHANGED
@@ -69,13 +69,16 @@ module IO_shuten
|
|
69
69
|
# @return [Boolean]
|
70
70
|
def save_instances
|
71
71
|
results = instances.inject({}) do |result, node|
|
72
|
-
|
73
|
-
node.
|
72
|
+
begin
|
73
|
+
File.open(node.node_name.to_s,"w") do |fh|
|
74
|
+
node.write_to(fh)
|
75
|
+
end
|
76
|
+
rescue
|
77
|
+
result[node.node_name] = :failed unless File.exists?(node.node_name.to_s)
|
74
78
|
end
|
75
|
-
|
76
|
-
result[node.node_name] = :failed unless File.exists?(node.node_name)
|
79
|
+
result
|
77
80
|
end
|
78
|
-
|
81
|
+
unless results.empty?
|
79
82
|
false
|
80
83
|
else
|
81
84
|
true
|
@@ -153,4 +156,3 @@ module IO_shuten
|
|
153
156
|
|
154
157
|
end
|
155
158
|
end
|
156
|
-
|
data/lib/io_shuten/memory.rb
CHANGED
@@ -58,12 +58,16 @@ module IO_shuten
|
|
58
58
|
# @return [Boolean]
|
59
59
|
def save_instances
|
60
60
|
results = instances.inject({}) do |result, node|
|
61
|
-
|
62
|
-
|
61
|
+
begin
|
62
|
+
File.open(node.node_name.to_s,"w") do |fh|
|
63
|
+
fh.puts node.string
|
64
|
+
end
|
65
|
+
rescue
|
66
|
+
result[node.node_name] = :failed unless File.exists?(node.node_name.to_s)
|
63
67
|
end
|
64
|
-
result
|
68
|
+
result
|
65
69
|
end
|
66
|
-
|
70
|
+
unless results.empty?
|
67
71
|
false
|
68
72
|
else
|
69
73
|
true
|
@@ -142,4 +146,3 @@ module IO_shuten
|
|
142
146
|
|
143
147
|
end
|
144
148
|
end
|
145
|
-
|
data/lib/io_shuten/version.rb
CHANGED
data/spec/lib/buffer_spec.rb
CHANGED
@@ -11,12 +11,15 @@ describe Buffer do
|
|
11
11
|
describe :new do
|
12
12
|
|
13
13
|
context "without node_name" do
|
14
|
+
|
14
15
|
it "raises Errors::NodeNameError" do
|
15
16
|
expect { Buffer.new }.to raise_error(Errors::NodeNameError)
|
16
17
|
end
|
18
|
+
|
17
19
|
end
|
18
20
|
|
19
21
|
context "with node_name" do
|
22
|
+
|
20
23
|
it "creates a new node with name as String" do
|
21
24
|
node_name = "foo bar"
|
22
25
|
iob = Buffer.new(node_name)
|
@@ -41,19 +44,24 @@ describe Buffer do
|
|
41
44
|
expect { Buffer.new(node_name) }.to_not raise_error
|
42
45
|
expect { Buffer.new(node_name) }.to raise_error(Errors::NodeExistsError)
|
43
46
|
end
|
47
|
+
|
44
48
|
end
|
45
49
|
|
46
50
|
end
|
47
51
|
|
48
52
|
describe "class based Buffer storage" do
|
53
|
+
|
49
54
|
describe :purge_instances! do
|
55
|
+
|
50
56
|
it "purges all instances" do
|
51
57
|
Buffer.purge_instances!
|
52
58
|
Buffer.instances.should have(0).items
|
53
59
|
end
|
60
|
+
|
54
61
|
end
|
55
62
|
|
56
63
|
describe :instances do
|
64
|
+
|
57
65
|
it "retrieves all @@instances" do
|
58
66
|
Buffer.purge_instances!
|
59
67
|
nodes = %w[first second last]
|
@@ -63,9 +71,11 @@ describe Buffer do
|
|
63
71
|
|
64
72
|
Buffer.instances.should have(3).items
|
65
73
|
end
|
74
|
+
|
66
75
|
end
|
67
76
|
|
68
77
|
describe :delete_instance do
|
78
|
+
|
69
79
|
before do
|
70
80
|
Buffer.purge_instances!
|
71
81
|
@node_names = %w[first second last]
|
@@ -93,6 +103,7 @@ describe Buffer do
|
|
93
103
|
store
|
94
104
|
end
|
95
105
|
Buffer.delete_instance(@node_names.first)
|
106
|
+
|
96
107
|
Buffer.instances.should_not include(@nodes.first)
|
97
108
|
end
|
98
109
|
|
@@ -127,6 +138,7 @@ describe Buffer do
|
|
127
138
|
end
|
128
139
|
|
129
140
|
describe :save_instances do
|
141
|
+
|
130
142
|
before do
|
131
143
|
@file_names2 = %w[file4 file5 file6]
|
132
144
|
end
|
@@ -145,9 +157,21 @@ describe Buffer do
|
|
145
157
|
|
146
158
|
Buffer.save_instances.should be_true
|
147
159
|
end
|
160
|
+
|
161
|
+
it "writes only nodes with valid file names" do
|
162
|
+
@file_names2.each do |file_name|
|
163
|
+
node = Buffer.new("#{@tmp_path}/#{file_name}")
|
164
|
+
node.<< "content of file: #{file_name}"
|
165
|
+
end
|
166
|
+
Buffer.new("/invalid_file")
|
167
|
+
|
168
|
+
Buffer.save_instances.should be_false
|
169
|
+
end
|
170
|
+
|
148
171
|
end
|
149
172
|
|
150
173
|
describe :load_instances do
|
174
|
+
|
151
175
|
it "loads an array of files" do
|
152
176
|
absolute_files = @file_names.inject([]) do |store, file_name|
|
153
177
|
store << "#{@tmp_path}/#{file_name}"
|
@@ -165,6 +189,11 @@ describe Buffer do
|
|
165
189
|
Buffer.load_instances @tmp_path
|
166
190
|
Buffer.pool.should have(3).items
|
167
191
|
end
|
192
|
+
|
193
|
+
it "raises error if input is of wrong type" do
|
194
|
+
expect { Buffer.load_instances :wrong_type }.to raise_error(ArgumentError)
|
195
|
+
end
|
196
|
+
|
168
197
|
end
|
169
198
|
|
170
199
|
end
|
@@ -179,9 +208,11 @@ describe Buffer do
|
|
179
208
|
end
|
180
209
|
|
181
210
|
context "without any args" do
|
211
|
+
|
182
212
|
it "raises ArgumentError" do
|
183
213
|
expect { Buffer.open }.to raise_error(::ArgumentError)
|
184
214
|
end
|
215
|
+
|
185
216
|
end
|
186
217
|
|
187
218
|
context "with name only" do
|
@@ -202,6 +233,7 @@ describe Buffer do
|
|
202
233
|
end
|
203
234
|
|
204
235
|
end
|
236
|
+
|
205
237
|
end
|
206
238
|
|
207
239
|
context "with name and block" do
|
@@ -248,6 +280,7 @@ describe Buffer do
|
|
248
280
|
end
|
249
281
|
|
250
282
|
describe "IO::Buffer method wrapper (for: #{RUBY_VERSION})" do
|
283
|
+
|
251
284
|
method_list = %w[
|
252
285
|
<<
|
253
286
|
append
|
@@ -265,9 +298,11 @@ describe Buffer do
|
|
265
298
|
Buffer.new(:string_io_test).should respond_to(method_name)
|
266
299
|
end
|
267
300
|
end
|
301
|
+
|
268
302
|
end
|
269
303
|
|
270
304
|
describe "method stub with #not_yet_implemented! call" do
|
305
|
+
|
271
306
|
it "raises NotYetImplemented" do
|
272
307
|
iob = Buffer.new(:not_implemented)
|
273
308
|
iob.instance_eval do
|
@@ -282,6 +317,7 @@ describe Buffer do
|
|
282
317
|
expect { iob.not_implemented_method_b }.to raise_error(Errors::NotYetImplemented)
|
283
318
|
expect { iob.not_implemented_method_c }.to raise_error(Errors::NotYetImplemented)
|
284
319
|
end
|
320
|
+
|
285
321
|
end
|
286
322
|
|
287
323
|
describe "loading and writing" do
|
@@ -354,30 +390,37 @@ describe Buffer do
|
|
354
390
|
describe :save_to_file do
|
355
391
|
|
356
392
|
context "file path accessible" do
|
393
|
+
|
357
394
|
context "with container name as default" do
|
395
|
+
|
358
396
|
it "writes container into the file" do
|
359
397
|
iob = Buffer.new(@tmp_save_file)
|
360
398
|
iob.write "Test string"
|
361
399
|
iob.save_to_file.should be_true
|
362
400
|
end
|
401
|
+
|
363
402
|
end
|
364
403
|
|
365
404
|
context "with custom name" do
|
405
|
+
|
366
406
|
it "writes container into the file" do
|
367
407
|
iob = Buffer.new(:different_name)
|
368
408
|
iob.write "Test string"
|
369
409
|
iob.save_to_file(@tmp_save_file).should be_true
|
370
410
|
end
|
411
|
+
|
371
412
|
end
|
372
413
|
|
373
414
|
end
|
374
415
|
|
375
416
|
context "path not accessible" do
|
417
|
+
|
376
418
|
it "raises FileAccessError with corresponding reason" do
|
377
419
|
iob = Buffer.new(@denied_path)
|
378
420
|
iob.write "Test string"
|
379
421
|
expect { iob.save_to_file }.to raise_error(Errors::FileAccessError, /Reason/)
|
380
422
|
end
|
423
|
+
|
381
424
|
end
|
382
425
|
|
383
426
|
end
|