rumai 3.2.0 → 3.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/CREDITS +4 -3
  2. data/HISTORY +327 -0
  3. data/INSTALL +31 -0
  4. data/README +92 -0
  5. data/USAGE +297 -0
  6. data/bin/rumai +9 -22
  7. data/doc/api/IO.html +119 -0
  8. data/doc/api/Integer.html +171 -0
  9. data/doc/api/Rumai.html +1270 -0
  10. data/doc/api/Rumai/Area.html +1485 -0
  11. data/doc/api/Rumai/Chain.html +301 -0
  12. data/doc/api/Rumai/Client.html +2451 -0
  13. data/doc/api/Rumai/ClientContainer.html +301 -0
  14. data/doc/api/Rumai/ExportInstanceMethods.html +103 -0
  15. data/doc/api/Rumai/IXP.html +94 -0
  16. data/doc/api/Rumai/IXP/Agent.html +1625 -0
  17. data/doc/api/Rumai/IXP/Agent/FidStream.html +959 -0
  18. data/doc/api/Rumai/IXP/Agent/RangedPool.html +381 -0
  19. data/doc/api/Rumai/IXP/Error.html +110 -0
  20. data/doc/api/Rumai/IXP/Fcall.html +503 -0
  21. data/doc/api/Rumai/IXP/Qid.html +207 -0
  22. data/doc/api/Rumai/IXP/Rattach.html +148 -0
  23. data/doc/api/Rumai/IXP/Rauth.html +148 -0
  24. data/doc/api/Rumai/IXP/Rclunk.html +148 -0
  25. data/doc/api/Rumai/IXP/Rcreate.html +148 -0
  26. data/doc/api/Rumai/IXP/Rerror.html +148 -0
  27. data/doc/api/Rumai/IXP/Rflush.html +148 -0
  28. data/doc/api/Rumai/IXP/Ropen.html +148 -0
  29. data/doc/api/Rumai/IXP/Rread.html +148 -0
  30. data/doc/api/Rumai/IXP/Rremove.html +148 -0
  31. data/doc/api/Rumai/IXP/Rstat.html +148 -0
  32. data/doc/api/Rumai/IXP/Rversion.html +148 -0
  33. data/doc/api/Rumai/IXP/Rwalk.html +148 -0
  34. data/doc/api/Rumai/IXP/Rwrite.html +148 -0
  35. data/doc/api/Rumai/IXP/Rwstat.html +148 -0
  36. data/doc/api/Rumai/IXP/Stat.html +335 -0
  37. data/doc/api/Rumai/IXP/Stream.html +194 -0
  38. data/doc/api/Rumai/IXP/Struct.html +586 -0
  39. data/doc/api/Rumai/IXP/Struct/ClassField.html +242 -0
  40. data/doc/api/Rumai/IXP/Struct/Field.html +782 -0
  41. data/doc/api/Rumai/IXP/Struct/Field/CounteeField.html +227 -0
  42. data/doc/api/Rumai/IXP/Struct/Field/CounterField.html +153 -0
  43. data/doc/api/Rumai/IXP/Struct/Integer8Field.html +242 -0
  44. data/doc/api/Rumai/IXP/Struct/StringField.html +206 -0
  45. data/doc/api/Rumai/IXP/Tattach.html +148 -0
  46. data/doc/api/Rumai/IXP/Tauth.html +148 -0
  47. data/doc/api/Rumai/IXP/Tclunk.html +148 -0
  48. data/doc/api/Rumai/IXP/Tcreate.html +148 -0
  49. data/doc/api/Rumai/IXP/Terror.html +231 -0
  50. data/doc/api/Rumai/IXP/Tflush.html +148 -0
  51. data/doc/api/Rumai/IXP/Topen.html +240 -0
  52. data/doc/api/Rumai/IXP/Tread.html +148 -0
  53. data/doc/api/Rumai/IXP/Tremove.html +148 -0
  54. data/doc/api/Rumai/IXP/Tstat.html +148 -0
  55. data/doc/api/Rumai/IXP/Tversion.html +162 -0
  56. data/doc/api/Rumai/IXP/Twalk.html +148 -0
  57. data/doc/api/Rumai/IXP/Twrite.html +148 -0
  58. data/doc/api/Rumai/IXP/Twstat.html +148 -0
  59. data/doc/api/Rumai/Node.html +1406 -0
  60. data/doc/api/Rumai/View.html +1587 -0
  61. data/doc/api/Rumai/WidgetImpl.html +333 -0
  62. data/doc/api/Rumai/WidgetNode.html +246 -0
  63. data/doc/api/String.html +258 -0
  64. data/doc/api/StringIO.html +119 -0
  65. data/doc/api/Time.html +247 -0
  66. data/doc/api/_index.html +581 -0
  67. data/doc/api/class_list.html +36 -0
  68. data/doc/api/css/common.css +1 -0
  69. data/doc/api/css/full_list.css +50 -0
  70. data/doc/api/css/style.css +273 -0
  71. data/doc/api/file.LICENSE.html +73 -0
  72. data/doc/api/file_list.html +38 -0
  73. data/doc/api/frames.html +13 -0
  74. data/doc/api/index.html +72 -13
  75. data/doc/api/js/app.js +111 -0
  76. data/doc/api/js/full_list.js +117 -0
  77. data/doc/api/js/{jquery-1.3.2.min.js → jquery.js} +0 -0
  78. data/doc/api/method_list.html +1483 -0
  79. data/doc/api/top-level-namespace.html +89 -0
  80. data/doc/index.erb +18 -13
  81. data/doc/index.html +331 -386
  82. data/lib/rumai.rb +1 -18
  83. data/lib/rumai/fs.rb +11 -11
  84. data/lib/rumai/inochi.rb +48 -0
  85. data/lib/rumai/inochi.yaml +94 -0
  86. data/lib/rumai/ixp.rb +0 -4
  87. data/lib/rumai/ixp/message.rb +6 -17
  88. data/lib/rumai/ixp/transport.rb +39 -30
  89. data/lib/rumai/wm.rb +35 -37
  90. data/test/rumai/inochi_test.rb +17 -0
  91. data/test/rumai/ixp/message_test.rb +245 -0
  92. data/test/runner +25 -0
  93. data/test/test_helper.rb +1 -0
  94. metadata +107 -125
  95. data/doc/api/apple-touch-icon.png +0 -0
  96. data/doc/api/classes/IO.html +0 -72
  97. data/doc/api/classes/Integer.html +0 -110
  98. data/doc/api/classes/Object.html +0 -60
  99. data/doc/api/classes/Rumai.html +0 -837
  100. data/doc/api/classes/Rumai/Area.html +0 -909
  101. data/doc/api/classes/Rumai/Chain.html +0 -197
  102. data/doc/api/classes/Rumai/Client.html +0 -1526
  103. data/doc/api/classes/Rumai/ClientContainer.html +0 -191
  104. data/doc/api/classes/Rumai/ExportInstanceMethods.html +0 -69
  105. data/doc/api/classes/Rumai/IXP.html +0 -131
  106. data/doc/api/classes/Rumai/IXP/Agent.html +0 -941
  107. data/doc/api/classes/Rumai/IXP/Agent/FidStream.html +0 -456
  108. data/doc/api/classes/Rumai/IXP/Agent/MODES.html +0 -108
  109. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.html +0 -241
  110. data/doc/api/classes/Rumai/IXP/Error.html +0 -67
  111. data/doc/api/classes/Rumai/IXP/Fcall.html +0 -323
  112. data/doc/api/classes/Rumai/IXP/Qid.html +0 -153
  113. data/doc/api/classes/Rumai/IXP/Rattach.html +0 -67
  114. data/doc/api/classes/Rumai/IXP/Rauth.html +0 -67
  115. data/doc/api/classes/Rumai/IXP/Rclunk.html +0 -67
  116. data/doc/api/classes/Rumai/IXP/Rcreate.html +0 -67
  117. data/doc/api/classes/Rumai/IXP/Rerror.html +0 -67
  118. data/doc/api/classes/Rumai/IXP/Rflush.html +0 -67
  119. data/doc/api/classes/Rumai/IXP/Ropen.html +0 -67
  120. data/doc/api/classes/Rumai/IXP/Rread.html +0 -67
  121. data/doc/api/classes/Rumai/IXP/Rremove.html +0 -67
  122. data/doc/api/classes/Rumai/IXP/Rstat.html +0 -67
  123. data/doc/api/classes/Rumai/IXP/Rversion.html +0 -67
  124. data/doc/api/classes/Rumai/IXP/Rwalk.html +0 -67
  125. data/doc/api/classes/Rumai/IXP/Rwrite.html +0 -67
  126. data/doc/api/classes/Rumai/IXP/Rwstat.html +0 -67
  127. data/doc/api/classes/Rumai/IXP/Stat.html +0 -252
  128. data/doc/api/classes/Rumai/IXP/Stream.html +0 -131
  129. data/doc/api/classes/Rumai/IXP/Struct.html +0 -311
  130. data/doc/api/classes/Rumai/IXP/Struct/Field.html +0 -415
  131. data/doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.html +0 -153
  132. data/doc/api/classes/Rumai/IXP/Struct/Field/CounterField.html +0 -104
  133. data/doc/api/classes/Rumai/IXP/Tattach.html +0 -68
  134. data/doc/api/classes/Rumai/IXP/Tauth.html +0 -67
  135. data/doc/api/classes/Rumai/IXP/Tclunk.html +0 -67
  136. data/doc/api/classes/Rumai/IXP/Tcreate.html +0 -68
  137. data/doc/api/classes/Rumai/IXP/Terror.html +0 -110
  138. data/doc/api/classes/Rumai/IXP/Tflush.html +0 -67
  139. data/doc/api/classes/Rumai/IXP/Topen.html +0 -165
  140. data/doc/api/classes/Rumai/IXP/Tread.html +0 -67
  141. data/doc/api/classes/Rumai/IXP/Tremove.html +0 -67
  142. data/doc/api/classes/Rumai/IXP/Tstat.html +0 -67
  143. data/doc/api/classes/Rumai/IXP/Tversion.html +0 -86
  144. data/doc/api/classes/Rumai/IXP/Twalk.html +0 -68
  145. data/doc/api/classes/Rumai/IXP/Twrite.html +0 -68
  146. data/doc/api/classes/Rumai/IXP/Twstat.html +0 -67
  147. data/doc/api/classes/Rumai/Node.html +0 -821
  148. data/doc/api/classes/Rumai/View.html +0 -967
  149. data/doc/api/classes/Rumai/WidgetImpl.html +0 -65
  150. data/doc/api/classes/Rumai/WidgetNode.html +0 -68
  151. data/doc/api/classes/String.html +0 -163
  152. data/doc/api/classes/StringIO.html +0 -72
  153. data/doc/api/classes/Time.html +0 -156
  154. data/doc/api/created.rid +0 -1
  155. data/doc/api/css/main.css +0 -263
  156. data/doc/api/css/panel.css +0 -383
  157. data/doc/api/css/reset.css +0 -53
  158. data/doc/api/favicon.ico +0 -0
  159. data/doc/api/files/CREDITS.html +0 -67
  160. data/doc/api/files/LICENSE.html +0 -76
  161. data/doc/api/files/lib/rumai/fs_rb.html +0 -75
  162. data/doc/api/files/lib/rumai/ixp/message_rb.html +0 -91
  163. data/doc/api/files/lib/rumai/ixp/transport_rb.html +0 -75
  164. data/doc/api/files/lib/rumai/ixp_rb.html +0 -69
  165. data/doc/api/files/lib/rumai/wm_rb.html +0 -77
  166. data/doc/api/files/lib/rumai_rb.html +0 -65
  167. data/doc/api/i/arrows.png +0 -0
  168. data/doc/api/i/results_bg.png +0 -0
  169. data/doc/api/i/tree_bg.png +0 -0
  170. data/doc/api/js/jquery-effect.js +0 -593
  171. data/doc/api/js/main.js +0 -22
  172. data/doc/api/js/searchdoc.js +0 -628
  173. data/doc/api/panel/index.html +0 -71
  174. data/doc/api/panel/search_index.js +0 -1
  175. data/doc/api/panel/tree.js +0 -1
  176. data/doc/history.erb +0 -233
  177. data/doc/intro.erb +0 -70
  178. data/doc/setup.erb +0 -144
  179. data/doc/usage.erb +0 -308
  180. data/rakefile +0 -14
  181. data/test/rumai/ixp/message.rb +0 -237
@@ -1,308 +0,0 @@
1
- %#--
2
- %# Copyright protects this work.
3
- %# See LICENSE file for details.
4
- %#++
5
-
6
-
7
- %|chapter "Usage"
8
-
9
-
10
- %|section "Concepts"
11
-
12
- Client
13
- : Any graphical program (a "window") that is running in your X session.
14
-
15
- Tag
16
- : An arbitrary label that can be associated with one or more clients.
17
-
18
- View
19
- : A visualization of a particular tag. A "workspace".
20
-
21
- Area
22
- : A region inside a view. It can contain clients.
23
-
24
- Managed area, column
25
- : An area whose clients cannot overlap each other.
26
-
27
- Floating area
28
- : An area whose clients:
29
-
30
- * can overlap each other
31
- * float above clients in the managed areas
32
-
33
-
34
- %|section "Command-line interface"
35
-
36
- When you run this command:
37
-
38
- <%= $program %> --help
39
-
40
- You will see this output:
41
-
42
- %|text
43
- %= verbatim `ruby bin/#{$program} --help`
44
-
45
-
46
- %|paragraph "Interactive shell", "shell"
47
-
48
- When you run this command:
49
-
50
- %= $program
51
-
52
- An IRB session will begin, showing you a command prompt like this:
53
-
54
- irb(Rumai):001:0>
55
-
56
- The <tt>irb(Rumai)</tt> token in the command prompt indicates that commands will be evaluated _inside_ the `Rumai` module. As a result, you can omit the "Rumai" prefix from your commands if you wish.
57
-
58
- For example, to get the current client object, you can type `curr_client` instead of having to type `Rumai.curr_client` at the prompt. Both commands achieve the same effect.
59
-
60
- The next thing to note is that **tab completion** is enabled by default. So you can type part of a command and press the TAB key to see a list of possible completions.
61
-
62
-
63
- %|section "Tutorial"
64
-
65
- Now that you know <%= xref "shell", "how to start the interactive shell" %>, let us walk through a quick demonstration that highlights the main features of <%= $project %>. You can follow along by copying & pasting the presented commands into the interactive shell.
66
-
67
- %|open_terms = lambda do
68
- Launch a few terminals so that we have something to work with:
69
-
70
- %|code :ruby
71
- colors = %w[ red green blue black orange brown gray navy gold ]
72
- colors.each {|c| system "xterm -bg #{c} -title #{c} -e sh -c read &" }
73
-
74
- %|close_terms = lambda do
75
- Close the terminals we launched earlier:
76
-
77
- %|code :ruby
78
- terms = curr_view.clients.select {|c| colors.include? c.label.read }
79
- terms.each {|c| c.kill }
80
-
81
-
82
- %|section "Automated client arrangement"
83
-
84
- % open_terms.call
85
-
86
- Arrange all clients in a grid:
87
-
88
- %|code :ruby
89
- curr_view.arrange_in_grid
90
-
91
- Arrange all clients in a diamond shape:
92
-
93
- %|code :ruby
94
- curr_view.arrange_in_diamond
95
-
96
- Arrange all clients like LarsWM does:
97
-
98
- %|code :ruby
99
- curr_view.arrange_as_larswm
100
-
101
- % close_terms.call
102
-
103
-
104
- %|section "Multiple client grouping"
105
-
106
- % open_terms.call
107
-
108
- Add the red, green, and blue terminals into the "grouping":
109
-
110
- %|code :ruby
111
- terms = curr_view.clients.select {|c| %w[red green blue].include? c.label.read }
112
- terms.each {|c| c.group }
113
-
114
- You should now see a new button labelled as "@" on the left-hand side of wmii's bar, indicating that there is now a new view labelled "@" in wmii. Let us inspect what clients this mysterious view contains:
115
-
116
- %|code :ruby
117
- v = View.new "@"
118
- puts v.clients.map {|c| c.label.read }
119
-
120
- Aha! The mysterious view contains the red, green, and blue clients we recently "grouped". Thus, by adding a client to the "grouping", we are simply tagging the client with the "@" token.
121
-
122
- Now that we have put some clients into the "grouping", let us move all clients in the grouping to the floating area in the current view:
123
-
124
- %|code :ruby
125
- grouping.each {|c| c.send "toggle" }
126
-
127
- Neat! Let us bring them back into the managed area:
128
-
129
- %|code :ruby
130
- grouping.each {|c| c.send "toggle" }
131
-
132
- % close_terms.call
133
-
134
- In summary, you can select multiple clients (by adding them to the "grouping") and perform operations on them. This is useful when you want to do something with a group of clients but do not want to manually focus one, perform the action, focus the next one, and so on.
135
-
136
- Another important aspect is that selected clients stay selected until they are unselected. This allows you to continue performing tasks on the selection without having to reselect the same clients after every operation.
137
-
138
-
139
- %|section "Easy column manipulation"
140
-
141
- % open_terms.call
142
-
143
- You can insert a group of clients to the top, bottom, or after the currently focused client of _any_ column using Array-like methods.
144
-
145
- Give each client its own column (one client per column):
146
-
147
- %|code :ruby
148
- curr_view.each_column {|c| c.length = 1 }
149
-
150
- Put (at most) three clients in every column:
151
-
152
- %|code :ruby
153
- curr_view.each_column {|c| c.length = 3 }
154
-
155
- Move the red, green, and blue clients into the floating area:
156
-
157
- %|code :ruby
158
- rgb = %w[red green blue]
159
- terms = curr_view.clients.select {|c| rgb.include? c.label.read }
160
- curr_view.areas[0].push terms
161
-
162
- Slurp all floating clients into the last column:
163
-
164
- %|code :ruby
165
- list = curr_view.areas
166
- a, b = list.first, list.last
167
- b.concat a
168
-
169
- Set the last column's layout to stacking mode:
170
-
171
- %|code :ruby
172
- b.layout = 'stack'
173
-
174
- Move the red, green, and blue clients to the top of the second column:
175
-
176
- %|code :ruby
177
- curr_view.areas[2].unshift terms
178
-
179
- Move the red, green, and blue clients to the bottom of the third column:
180
-
181
- %|code :ruby
182
- curr_view.areas[3].push terms
183
-
184
- % close_terms.call
185
-
186
-
187
- %|section "Easy client manipulation"
188
-
189
- % open_terms.call
190
-
191
- Obtain a reference to the red client:
192
-
193
- %|code :ruby
194
- red = curr_view.clients.find {|c| c.label.read == "red" }
195
-
196
- Show the red client's current tags:
197
-
198
- %|code :ruby
199
- red.tags
200
-
201
- Add the "foo" and "bar" tags to the red client:
202
-
203
- %|code :ruby
204
- red.tag "foo", "bar"
205
-
206
- Remove the "bar" tag from the red client:
207
-
208
- %|code :ruby
209
- red.untag "bar"
210
-
211
- Do complex operations on the red client's tags:
212
-
213
- %|code :ruby
214
- red.with_tags { concat %w[a b c]; push 'z'; delete 'c' }
215
-
216
- Focus the next client after the red client:
217
-
218
- %|code :ruby
219
- red.next.focus
220
- curr_client == red.next #=> true
221
-
222
- Notice that by focusing a client, we make it the current client.
223
-
224
- Focus the red client on a different view:
225
-
226
- %|code :ruby
227
- orig = curr_view
228
- v = red.views.last
229
- red.focus v
230
-
231
- Return to the original view:
232
-
233
- %|code :ruby
234
- orig.focus
235
-
236
- Send the red client to the last column:
237
-
238
- %|code :ruby
239
- red.send curr_view.areas.last
240
-
241
- % close_terms.call
242
-
243
-
244
- %|section "Traversing the file system"
245
-
246
- Show the root node of wmii's IXP file system:
247
-
248
- %|code :ruby
249
- fs
250
-
251
- Show the names of all files at the root level:
252
-
253
- %|code :ruby
254
- fs.entries
255
-
256
- Show the parent of the root node:
257
-
258
- %|code :ruby
259
- fs.parent
260
-
261
- Show the children of the root node:
262
-
263
- %|code :ruby
264
- fs.children
265
-
266
- Navigate into to the <tt>/lbar/</tt> directory:
267
-
268
- %|code :ruby
269
- n1 = fs.lbar
270
- n2 = fs['lbar']
271
- n1 == n2 #=> true
272
- left_bar = n1
273
-
274
- Notice that you can traverse the file system hierarchy by simply calling methods on node objects. Alternatively, you can traverse by specifying an arbitrary sub-path (relative path) using the `[]` operator on a node.
275
-
276
- Create a new temporary button:
277
-
278
- %|code :ruby
279
- b = left_bar.rumai_example # path of new button
280
- b.exist? #=> false
281
- b.create
282
- b.exist? #=> true
283
-
284
- You should now see an empty button on the left-hand side of the wmii bar.
285
-
286
- Color the button black-on-white and label it as "hello world":
287
-
288
- %|code :ruby
289
- content = "#000000 #ffffff #000000 hello world"
290
- b.write content
291
- b.read == content #=> true
292
-
293
- Remove the temporary button:
294
-
295
- %|code :ruby
296
- b.remove
297
- b.exist? #=> false
298
-
299
-
300
- %|section "Available commands"
301
-
302
- Refer to the `Rumai` module in the [API documentation](api/index.html) for a complete list of commands (method calls, really) and their documentation.
303
-
304
-
305
- %|section "Scripting your wmiirc", 'wmiirc'
306
-
307
- One important application of <%= $project %> is the support of Ruby-based <tt>wmiirc</tt> configuration files. For a solid example of such application, take a look at [my personal <tt>wmiirc</tt>](http://github.com/sunaku/wmiirc/).
308
-
data/rakefile DELETED
@@ -1,14 +0,0 @@
1
- #--
2
- # Copyright protects this work.
3
- # See LICENSE file for details.
4
- #++
5
-
6
- require 'rubygems'
7
- gem 'inochi', '~> 1'
8
- require 'inochi'
9
-
10
- Inochi.rake :Rumai,
11
- :rubyforge_project => 'sunaku',
12
- :upload_target => File.expand_path('~/www/lib/rumai/'),
13
- :upload_delete => true,
14
- :test_with => :dfect
@@ -1,237 +0,0 @@
1
- #--
2
- # Copyright protects this work.
3
- # See LICENSE file for details.
4
- #++
5
-
6
- require 'pp' if $DEBUG
7
-
8
- class << Object.new
9
- include Rumai::IXP
10
-
11
- D .< do
12
- unless defined? @conn
13
- # connect to the wmii IXP server
14
- require 'socket'
15
- @conn = UNIXSocket.new(Rumai::IXP_SOCK_ADDR)
16
- end
17
-
18
- # at_exit do
19
- # puts "just making sure there is no more data in the pipe"
20
- # while c = @conn.getc
21
- # puts c
22
- # end
23
- # end
24
-
25
- transaction 'establish a new session', Tversion.new(
26
- :tag => Fcall::NOTAG,
27
- :msize => Tversion::MSIZE,
28
- :version => Tversion::VERSION
29
- ) do |req, rsp|
30
- T { rsp.type == Rversion.type }
31
- T { rsp.version == req.version }
32
- end
33
- end
34
-
35
- D 'can read a directory' do
36
- transaction 'attach to FS root', Tattach.new(
37
- :tag => 0,
38
- :fid => 0,
39
- :afid => Fcall::NOFID,
40
- :uname => ENV['USER'],
41
- :aname => ''
42
- ) do |req, rsp|
43
- T { rsp.type == Rattach.type }
44
- end
45
-
46
- transaction 'stat FS root', Tstat.new(
47
- :tag => 0,
48
- :fid => 0
49
- ) do |req, rsp|
50
- T { rsp.type == Rstat.type }
51
- end
52
-
53
- transaction 'open the FS root for reading', Topen.new(
54
- :tag => 0,
55
- :fid => 0,
56
- :mode => Topen::OREAD
57
- ) do |req, rsp|
58
- T { rsp.type == Ropen.type }
59
- end
60
-
61
- transaction 'fetch a Stat for every file in FS root', Tread.new(
62
- :tag => 0,
63
- :fid => 0,
64
- :offset => 0,
65
- :count => Tversion::MSIZE
66
- ) do |req, rsp|
67
- T { rsp.type == Rread.type }
68
-
69
- if $DEBUG
70
- s = StringIO.new(rsp.data, 'r')
71
- a = []
72
-
73
- until s.eof?
74
- t = Stat.from_9p(s)
75
- a << t
76
- end
77
-
78
- pp a
79
- end
80
- end
81
-
82
- transaction 'close the fid for FS root', Tclunk.new(
83
- :tag => 0,
84
- :fid => 0
85
- ) do |req, rsp|
86
- T { rsp.type == Rclunk.type }
87
- end
88
-
89
- transaction 'closed fid should not be readable', Tread.new(
90
- :tag => 0,
91
- :fid => 0,
92
- :offset => 0,
93
- :count => Tversion::MSIZE
94
- ) do |req, rsp|
95
- T { rsp.type == Rerror.type }
96
- end
97
- end
98
-
99
- D 'can read & write a file' do
100
- transaction 'attach to /', Tattach.new(
101
- :tag => 0,
102
- :fid => 0,
103
- :afid => Fcall::NOFID,
104
- :uname => ENV['USER'],
105
- :aname => ''
106
- ) do |req, rsp|
107
- T { rsp.type == Rattach.type }
108
- end
109
-
110
- file = %W[rbar temp#{$$}]
111
- root = file[0..-2]
112
- leaf = file.last
113
-
114
- transaction "walk to #{root.inspect}", Twalk.new(
115
- :tag => 0,
116
- :fid => 0,
117
- :newfid => 1,
118
- :wname => root
119
- ) do |req, rsp|
120
- T { rsp.type == Rwalk.type }
121
- end
122
-
123
- transaction "create #{leaf.inspect}", Tcreate.new(
124
- :tag => 0,
125
- :fid => 1,
126
- :name => leaf,
127
- :perm => 0644,
128
- :mode => Topen::ORDWR
129
- ) do |req, rsp|
130
- T { rsp.type == Rcreate.type }
131
- end
132
-
133
- transaction "close the fid for #{root.inspect}", Tclunk.new(
134
- :tag => 0,
135
- :fid => 1
136
- ) do |req, rsp|
137
- T { rsp.type == Rclunk.type }
138
- end
139
-
140
- transaction "walk to #{file.inspect} from /", Twalk.new(
141
- :tag => 0,
142
- :fid => 0,
143
- :newfid => 1,
144
- :wname => file
145
- ) do |req, rsp|
146
- T { rsp.type == Rwalk.type }
147
- end
148
-
149
- transaction 'close the fid for /', Tclunk.new(
150
- :tag => 0,
151
- :fid => 0
152
- ) do |req, rsp|
153
- T { rsp.type == Rclunk.type }
154
- end
155
-
156
- transaction "open #{file.inspect} for writing", Topen.new(
157
- :tag => 0,
158
- :fid => 1,
159
- :mode => Topen::ORDWR
160
- ) do |req, rsp|
161
- T { rsp.type == Ropen.type }
162
- end
163
-
164
- write_req, write_rsp = transaction "write to #{file.inspect}", Twrite.new(
165
- :tag => 0,
166
- :fid => 1,
167
- :offset => 0,
168
- :data => "#a1a2a3 #b1b2b3 #c1c2c3 hello world!!!"
169
- ) do |req, rsp|
170
- T { rsp.type == Rwrite.type }
171
- T { rsp.count == req.data.length }
172
- end
173
-
174
- transaction "verify stuff was written to #{file.inspect}", Tread.new(
175
- :tag => 0,
176
- :fid => 1,
177
- :offset => 0,
178
- :count => write_rsp.count
179
- ) do |req, rsp|
180
- T { rsp.type == Rread.type }
181
- T { rsp.data == write_req.data }
182
- end
183
-
184
- transaction "remove #{file.inspect}", Tremove.new(
185
- :tag => 0,
186
- :fid => 1
187
- ) do |req, rsp|
188
- T { rsp.type == Rremove.type }
189
- end
190
-
191
- transaction "fid for #{file.inspect} should have been closed by Tremove", Tclunk.new(
192
- :tag => 0,
193
- :fid => 1
194
- ) do |req, rsp|
195
- T { rsp.type == Rerror.type }
196
- end
197
- end
198
-
199
- ##
200
- # Transmits the given request and returns the received response.
201
- #
202
- def self.send_and_recv request
203
- # send the request
204
- if $DEBUG
205
- puts
206
- pp request
207
- pp request.to_9p
208
- end
209
-
210
- @conn << request.to_9p
211
-
212
- # receive the response
213
- response = Fcall.from_9p(@conn)
214
-
215
- if $DEBUG
216
- puts
217
- pp response
218
- pp response.to_9p
219
- end
220
-
221
- if response.type == Rerror.type
222
- T { response.kind_of? Rerror }
223
- else
224
- T { response.type == request.type + 1 }
225
- end
226
-
227
- T { response.tag == request.tag }
228
-
229
- response
230
- end
231
-
232
- def self.transaction description, request
233
- response = send_and_recv(request)
234
- yield request, response if block_given?
235
- [request, response]
236
- end
237
- end