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,13 +1,9 @@
1
1
  # Abstractions for the window manager.
2
- #--
3
- # Copyright protects this work.
4
- # See LICENSE file for details.
5
- #++
6
2
 
7
3
  require 'rumai/fs'
8
4
  require 'enumerator'
9
5
 
10
- class Object #:nodoc:
6
+ class Object # @private
11
7
  # prevent these deprecated properties
12
8
  # from clashing with our usage below
13
9
  undef id if respond_to? :id
@@ -21,12 +17,12 @@ module Rumai
21
17
  CLIENT_GROUPING_TAG = '@'.freeze
22
18
  CLIENT_STICKY_TAG = '/./'.freeze
23
19
 
24
- #-----------------------------------------------------------------------------
20
+ #---------------------------------------------------------------------------
25
21
  # abstraction of WM components
26
- #-----------------------------------------------------------------------------
22
+ #---------------------------------------------------------------------------
27
23
 
28
24
  ##
29
- # NOTE: Inheritors must override the 'chain' method.
25
+ # @note Inheritors must override the {Chain#chain} method.
30
26
  #
31
27
  module Chain
32
28
  ##
@@ -64,10 +60,10 @@ module Rumai
64
60
  ##
65
61
  # The basic building block of the WM hierarchy.
66
62
  #
67
- # NOTE: Inheritors must define a 'curr' class method.
68
- # NOTE: Inheritors must override the 'focus' method.
63
+ # @note Inheritors must define a {curr} class method.
64
+ # @note Inheritors must override the {focus} method.
69
65
  #
70
- module WidgetImpl #:nodoc:
66
+ module WidgetImpl
71
67
  attr_reader :id
72
68
 
73
69
  def == other
@@ -87,7 +83,7 @@ module Rumai
87
83
  ##
88
84
  # A widget that has a corresponding representation in the IXP file system.
89
85
  #
90
- class WidgetNode < Node #:nodoc:
86
+ class WidgetNode < Node
91
87
  include WidgetImpl
92
88
 
93
89
  def initialize id, path_prefix
@@ -126,9 +122,9 @@ module Rumai
126
122
  View.curr.clients
127
123
  end
128
124
 
129
- #-------------------------------------------------------------------------
125
+ #-----------------------------------------------------------------------
130
126
  # WM operations
131
- #-------------------------------------------------------------------------
127
+ #-----------------------------------------------------------------------
132
128
 
133
129
  ##
134
130
  # Focuses this client within the given view.
@@ -188,7 +184,8 @@ module Rumai
188
184
  end
189
185
 
190
186
  ##
191
- # Maximizes this client to occupy the entire screen on the current view.
187
+ # Maximizes this client to occupy the
188
+ # entire screen on the current view.
192
189
  #
193
190
  def fullscreen
194
191
  ctl.write 'Fullscreen on'
@@ -291,9 +288,9 @@ module Rumai
291
288
 
292
289
  alias manage! float!
293
290
 
294
- #-------------------------------------------------------------------------
291
+ #-----------------------------------------------------------------------
295
292
  # WM hierarchy
296
- #-------------------------------------------------------------------------
293
+ #-----------------------------------------------------------------------
297
294
 
298
295
  ##
299
296
  # Returns the area that contains this client within the given view.
@@ -309,9 +306,9 @@ module Rumai
309
306
  tags.map! {|t| View.new t }
310
307
  end
311
308
 
312
- #-------------------------------------------------------------------------
309
+ #-----------------------------------------------------------------------
313
310
  # tag manipulations
314
- #-------------------------------------------------------------------------
311
+ #-----------------------------------------------------------------------
315
312
 
316
313
  TAG_DELIMITER = '+'.freeze
317
314
 
@@ -395,9 +392,9 @@ module Rumai
395
392
  end
396
393
  end
397
394
 
398
- #-------------------------------------------------------------------------
395
+ #-----------------------------------------------------------------------
399
396
  # multiple client grouping
400
- #-------------------------------------------------------------------------
397
+ #-----------------------------------------------------------------------
401
398
 
402
399
  ##
403
400
  # Checks if this client is included in the current grouping.
@@ -449,7 +446,7 @@ module Rumai
449
446
  end
450
447
 
451
448
  ##
452
- # NOTE: Inheritors should override the 'client_ids' method.
449
+ # @note Inheritors should override the {ClientContainer#client_ids} method.
453
450
  #
454
451
  module ClientContainer
455
452
  ##
@@ -491,7 +488,8 @@ module Rumai
491
488
  attr_reader :view
492
489
 
493
490
  ##
494
- # [view] the view object which contains this area
491
+ # @param [Rumai::View] view
492
+ # the view object which contains this area
495
493
  #
496
494
  def initialize area_id, view = View.curr
497
495
  @id = Integer(area_id) rescue area_id
@@ -576,9 +574,9 @@ module Rumai
576
574
  @view.ctl.write "colmode #{@id} #{mode}"
577
575
  end
578
576
 
579
- #-------------------------------------------------------------------------
577
+ #-----------------------------------------------------------------------
580
578
  # WM operations
581
- #-------------------------------------------------------------------------
579
+ #-----------------------------------------------------------------------
582
580
 
583
581
  ##
584
582
  # Puts focus on this area.
@@ -587,9 +585,9 @@ module Rumai
587
585
  @view.ctl.write "select #{@id}"
588
586
  end
589
587
 
590
- #-------------------------------------------------------------------------
588
+ #-----------------------------------------------------------------------
591
589
  # array abstraction: area is an array of clients
592
- #-------------------------------------------------------------------------
590
+ #-----------------------------------------------------------------------
593
591
 
594
592
  ##
595
593
  # Returns the number of clients in this area.
@@ -761,9 +759,9 @@ module Rumai
761
759
  super view_id, '/tag'
762
760
  end
763
761
 
764
- #-------------------------------------------------------------------------
762
+ #-----------------------------------------------------------------------
765
763
  # WM operations
766
- #-------------------------------------------------------------------------
764
+ #-----------------------------------------------------------------------
767
765
 
768
766
  ##
769
767
  # Returns the manifest of all areas and clients in this view.
@@ -779,9 +777,9 @@ module Rumai
779
777
  ctl.write "select #{direction}"
780
778
  end
781
779
 
782
- #-------------------------------------------------------------------------
780
+ #-----------------------------------------------------------------------
783
781
  # WM hierarchy
784
- #-------------------------------------------------------------------------
782
+ #-----------------------------------------------------------------------
785
783
 
786
784
  ##
787
785
  # Returns the area which contains the given client in this view.
@@ -852,9 +850,9 @@ module Rumai
852
850
 
853
851
  alias each_managed_area each_column
854
852
 
855
- #-------------------------------------------------------------------------
853
+ #-----------------------------------------------------------------------
856
854
  # visual arrangement of clients
857
- #-------------------------------------------------------------------------
855
+ #-----------------------------------------------------------------------
858
856
 
859
857
  ##
860
858
  # Arranges the clients in this view, while maintaining
@@ -1011,9 +1009,9 @@ module Rumai
1011
1009
  end
1012
1010
  end
1013
1011
 
1014
- #-----------------------------------------------------------------------------
1012
+ #---------------------------------------------------------------------------
1015
1013
  # access to global WM state
1016
- #-----------------------------------------------------------------------------
1014
+ #---------------------------------------------------------------------------
1017
1015
 
1018
1016
  ##
1019
1017
  # Returns the root of IXP file system hierarchy.
@@ -1061,9 +1059,9 @@ module Rumai
1061
1059
  list
1062
1060
  end
1063
1061
 
1064
- #-----------------------------------------------------------------------------
1062
+ #---------------------------------------------------------------------------
1065
1063
  # shortcuts for interactive WM manipulation (via IRB)
1066
- #-----------------------------------------------------------------------------
1064
+ #---------------------------------------------------------------------------
1067
1065
 
1068
1066
  def curr_client ; Client.curr ; end
1069
1067
  def next_client ; curr_client.next ; end
@@ -0,0 +1,17 @@
1
+ require 'rumai/inochi'
2
+
3
+ unless defined? Rumai::INOCHI
4
+ fail "Rumai module must be established by Inochi"
5
+ end
6
+
7
+ Rumai::INOCHI.each do |param, value|
8
+ const = param.to_s.upcase
9
+
10
+ unless Rumai.const_defined? const
11
+ fail "Rumai::#{const} must be established by Inochi"
12
+ end
13
+
14
+ unless Rumai.const_get(const) == value
15
+ fail "Rumai::#{const} is not what Inochi established"
16
+ end
17
+ end
@@ -0,0 +1,245 @@
1
+ require 'rumai/fs'
2
+ require 'pp' if $DEBUG
3
+
4
+ D 'IXP' do
5
+ extend Rumai::IXP
6
+
7
+ D .<< do
8
+ # connect to the wmii IXP server
9
+ @conn = UNIXSocket.new(Rumai::IXP_SOCK_ADDR)
10
+
11
+ # at_exit do
12
+ # puts "just making sure there is no more data in the pipe"
13
+ # while c = @conn.getc
14
+ # puts c
15
+ # end
16
+ # end
17
+
18
+ D 'establish a new session' do
19
+ request, response = talk(Tversion,
20
+ :tag => Fcall::NOTAG,
21
+ :msize => Tversion::MSIZE,
22
+ :version => Tversion::VERSION
23
+ )
24
+ T { response.type == Rversion.type }
25
+ T { response.version == request.version }
26
+ end
27
+ end
28
+
29
+ D 'can read a directory' do
30
+ D 'attach to FS root' do
31
+ request, response = talk(Tattach,
32
+ :tag => 0,
33
+ :fid => 0,
34
+ :afid => Fcall::NOFID,
35
+ :uname => ENV['USER'],
36
+ :aname => ''
37
+ )
38
+ T { response.type == Rattach.type }
39
+ end
40
+
41
+ D 'stat FS root' do
42
+ request, response = talk(Tstat,
43
+ :tag => 0,
44
+ :fid => 0
45
+ )
46
+ T { response.type == Rstat.type }
47
+ end
48
+
49
+ D 'open the FS root for reading' do
50
+ request, response = talk(Topen,
51
+ :tag => 0,
52
+ :fid => 0,
53
+ :mode => Topen::OREAD
54
+ )
55
+ T { response.type == Ropen.type }
56
+ end
57
+
58
+ D 'fetch a Stat for every file in FS root' do
59
+ request, response = talk(Tread,
60
+ :tag => 0,
61
+ :fid => 0,
62
+ :offset => 0,
63
+ :count => Tversion::MSIZE
64
+ )
65
+ T { response.type == Rread.type }
66
+
67
+ if $DEBUG
68
+ s = StringIO.new(response.data, 'r')
69
+ a = []
70
+
71
+ until s.eof?
72
+ t = Stat.from_9p(s)
73
+ a << t
74
+ end
75
+
76
+ pp a
77
+ end
78
+ end
79
+
80
+ D 'close the fid for FS root' do
81
+ request, response = talk(Tclunk,
82
+ :tag => 0,
83
+ :fid => 0
84
+ )
85
+ T { response.type == Rclunk.type }
86
+ end
87
+
88
+ D 'closed fid should not be readable' do
89
+ request, response = talk(Tread,
90
+ :tag => 0,
91
+ :fid => 0,
92
+ :offset => 0,
93
+ :count => Tversion::MSIZE
94
+ )
95
+ T { response.type == Rerror.type }
96
+ end
97
+ end
98
+
99
+ D 'can read & write a file' do
100
+ D 'attach to /' do
101
+ request, response = talk(Tattach,
102
+ :tag => 0,
103
+ :fid => 0,
104
+ :afid => Fcall::NOFID,
105
+ :uname => ENV['USER'],
106
+ :aname => ''
107
+ )
108
+ T { response.type == Rattach.type }
109
+ end
110
+
111
+ file = %W[rbar temp#{$$}]
112
+ root = file[0..-2]
113
+ leaf = file.last
114
+
115
+ D "walk to #{root.inspect}" do
116
+ request, response = talk(Twalk,
117
+ :tag => 0,
118
+ :fid => 0,
119
+ :newfid => 1,
120
+ :wname => root
121
+ )
122
+ T { response.type == Rwalk.type }
123
+ end
124
+
125
+ D "create #{leaf.inspect}" do
126
+ request, response = talk(Tcreate,
127
+ :tag => 0,
128
+ :fid => 1,
129
+ :name => leaf,
130
+ :perm => 0644,
131
+ :mode => Topen::ORDWR
132
+ )
133
+ T { response.type == Rcreate.type }
134
+ end
135
+
136
+ D "close the fid for #{root.inspect}" do
137
+ request, response = talk(Tclunk,
138
+ :tag => 0,
139
+ :fid => 1
140
+ )
141
+ T { response.type == Rclunk.type }
142
+ end
143
+
144
+ D "walk to #{file.inspect} from /" do
145
+ request, response = talk(Twalk,
146
+ :tag => 0,
147
+ :fid => 0,
148
+ :newfid => 1,
149
+ :wname => file
150
+ )
151
+ T { response.type == Rwalk.type }
152
+ end
153
+
154
+ D 'close the fid for /' do
155
+ request, response = talk(Tclunk,
156
+ :tag => 0,
157
+ :fid => 0
158
+ )
159
+ T { response.type == Rclunk.type }
160
+ end
161
+
162
+ D "open #{file.inspect} for writing" do
163
+ request, response = talk(Topen,
164
+ :tag => 0,
165
+ :fid => 1,
166
+ :mode => Topen::ORDWR
167
+ )
168
+ T { response.type == Ropen.type }
169
+ end
170
+
171
+ D "write to #{file.inspect}" do
172
+ write_request, write_response = talk(Twrite,
173
+ :tag => 0,
174
+ :fid => 1,
175
+ :offset => 0,
176
+ :data => "#a1a2a3 #b1b2b3 #c1c2c3 hello world!!!"
177
+ )
178
+ T { write_response.type == Rwrite.type }
179
+ T { write_response.count == write_request.data.length }
180
+
181
+ D "verify the write" do
182
+ read_request, read_response = talk(Tread,
183
+ :tag => 0,
184
+ :fid => 1,
185
+ :offset => 0,
186
+ :count => write_response.count
187
+ )
188
+ T { read_response.type == Rread.type }
189
+ T { read_response.data == write_request.data }
190
+ end
191
+ end
192
+
193
+ D "remove #{file.inspect}" do
194
+ request, response = talk(Tremove,
195
+ :tag => 0,
196
+ :fid => 1
197
+ )
198
+ T { response.type == Rremove.type }
199
+ end
200
+
201
+ D "fid for #{file.inspect} should have been closed by Tremove" do
202
+ request, response = talk(Tclunk,
203
+ :tag => 0,
204
+ :fid => 1
205
+ )
206
+ T { response.type == Rerror.type }
207
+ end
208
+ end
209
+
210
+ ##
211
+ # Transmits the given request and returns the received response.
212
+ #
213
+ def talk request_type, request_options
214
+ request = request_type.new(request_options)
215
+
216
+ # send the request
217
+ if $DEBUG
218
+ puts
219
+ pp request
220
+ pp request.to_9p
221
+ end
222
+
223
+ @conn << request.to_9p
224
+
225
+ # receive the response
226
+ response = Fcall.from_9p(@conn)
227
+
228
+ if $DEBUG
229
+ puts
230
+ pp response
231
+ pp response.to_9p
232
+ end
233
+
234
+ if response.type == Rerror.type
235
+ T { response.kind_of? Rerror }
236
+ else
237
+ T { response.type == request.type + 1 }
238
+ end
239
+
240
+ T { response.tag == request.tag }
241
+
242
+ # return the conversation
243
+ [request, response]
244
+ end
245
+ end