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,20 +1,3 @@
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.init :Rumai,
11
- :version => '3.2.0',
12
- :release => '2009-11-17',
13
- :website => 'http://snk.tuxfamily.org/lib/rumai/',
14
- :tagline => 'Ruby interface to the wmii window manager',
15
- :develop => {
16
- :dfect => nil, # for unit testing
17
- }
18
-
1
+ require 'rumai/inochi'
19
2
  require 'rumai/fs'
20
3
  require 'rumai/wm'
@@ -1,8 +1,4 @@
1
1
  # File system abstractions over the 9P2000 protocol.
2
- #--
3
- # Copyright protects this work.
4
- # See LICENSE file for details.
5
- #++
6
2
 
7
3
  require 'rumai/ixp'
8
4
  require 'socket'
@@ -15,7 +11,7 @@ module Rumai
15
11
  "/tmp/ns.#{ENV['USER']}.#{display[/:\d+/]}/wmii"
16
12
 
17
13
  begin
18
- # We use a single, global connection to wmii's IXP server.
14
+ # we use a single, global connection to wmii's IXP server
19
15
  IXP_AGENT = IXP::Agent.new(UNIXSocket.new(IXP_SOCK_ADDR))
20
16
 
21
17
  rescue => error
@@ -43,7 +39,7 @@ module Rumai
43
39
  ##
44
40
  # Returns file statistics about this node.
45
41
  #
46
- # See Rumai::IXP::Client#stat for details.
42
+ # @see Rumai::IXP::Agent#stat
47
43
  #
48
44
  def stat
49
45
  IXP_AGENT.stat @path
@@ -81,7 +77,7 @@ module Rumai
81
77
  ##
82
78
  # Opens this node for I/O access.
83
79
  #
84
- # See Rumai::IXP::Client#open for details.
80
+ # @see Rumai::IXP::Agent#open
85
81
  #
86
82
  def open mode = 'r', &block
87
83
  IXP_AGENT.open @path, mode, &block
@@ -90,7 +86,7 @@ module Rumai
90
86
  ##
91
87
  # Returns the entire content of this node.
92
88
  #
93
- # See Rumai::IXP::Client#read for details.
89
+ # @see Rumai::IXP::Agent#read
94
90
  #
95
91
  def read *args
96
92
  IXP_AGENT.read @path, *args
@@ -99,7 +95,9 @@ module Rumai
99
95
  ##
100
96
  # Invokes the given block for every line in the content of this node.
101
97
  #
102
- def each_line &block #:yields: line
98
+ # @yieldparam [String] line
99
+ #
100
+ def each_line &block
103
101
  open do |file|
104
102
  until (chunk = file.read(true)).empty?
105
103
  chunk.each_line(&block)
@@ -117,7 +115,7 @@ module Rumai
117
115
  ##
118
116
  # Creates a file corresponding to this node on the IXP server.
119
117
  #
120
- # See Rumai::IXP::Client#create for details.
118
+ # @see Rumai::IXP::Agent#create
121
119
  #
122
120
  def create *args
123
121
  IXP_AGENT.create @path, *args
@@ -198,7 +196,7 @@ module Rumai
198
196
  # Both of the above expressions are equivalent.
199
197
  #
200
198
  module ExportInstanceMethods
201
- def self.extended target #:nodoc:
199
+ def self.extended target # @private
202
200
  target.instance_methods(false).each do |meth|
203
201
  (class << target; self; end).instance_eval do
204
202
  define_method meth do |path, *args|
@@ -209,10 +207,12 @@ module Rumai
209
207
  end
210
208
  end
211
209
 
210
+ ##
212
211
  # NOTE: We use extend() **AFTER** all methods have been defined
213
212
  # in the class so that the ExportInstanceMethods module
214
213
  # can do its magic. If, instead, we include()d the module
215
214
  # before all methods in the class had been defined, then
216
215
  # the magic would only apply to **SOME** of the methods!
216
+ #
217
217
  Node.extend ExportInstanceMethods
218
218
  end
@@ -0,0 +1,48 @@
1
+ module Rumai
2
+
3
+ INSTDIR = File.expand_path('../../..', __FILE__)
4
+
5
+ # load inochi configuration
6
+ inochi_file = __FILE__.sub(/rb$/, 'yaml')
7
+ begin
8
+
9
+ configs = File.open(inochi_file) do |f|
10
+ require 'yaml'
11
+ YAML.load_stream(f).documents
12
+ end
13
+
14
+ INOCHI = configs.shift.to_hash
15
+ INOCHI[:runtime] ||= {}
16
+ INOCHI[:devtime] ||= {}
17
+
18
+ INOCHI2 = (configs.shift || {}).to_hash
19
+
20
+ rescue => error
21
+ error.message.insert 0,
22
+ "Could not load Inochi configuration file: #{inochi_file.inspect}\n"
23
+ raise error
24
+ end
25
+
26
+ # make values available as constants
27
+ INOCHI.each do |param, value|
28
+ const_set param.to_s.upcase, value
29
+ end
30
+
31
+ def self.inspect
32
+ "#{PROJECT} #{VERSION} (#{RELEASE})"
33
+ end
34
+
35
+ # establish gem version dependencies
36
+ if respond_to? :gem
37
+ [:runtime, :devtime].each do |key|
38
+ INOCHI[key].each do |gem_name, gem_version|
39
+ begin
40
+ gem gem_name, *Array(gem_version)
41
+ rescue LoadError => error
42
+ warn "#{inspect} #{key}: #{error}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,94 @@
1
+ --- # information about your project -----------------------------------------
2
+
3
+ # Name of your project.
4
+ :project: Rumai
5
+
6
+ # Name of your project when packaged as a directory.
7
+ :package: rumai
8
+
9
+ # Name of Ruby module that namespaces your project.
10
+ :library: Rumai
11
+
12
+ # A short, single-line description of your project.
13
+ :tagline: Ruby interface to the wmii window manager
14
+
15
+ # Address of your project's published website.
16
+ :website: http://snk.tuxfamily.org/lib/rumai/
17
+
18
+ # A list of the core developers of your project.
19
+ #
20
+ # :authors:
21
+ # - An Example <an@example.com> # with email
22
+ # - Another Example # without email
23
+ #
24
+ :authors:
25
+ - Suraj N. Kurapati <sunaku@gmail.com>
26
+
27
+ # Number of the current release of your project.
28
+ :version: 3.2.1
29
+
30
+ # Date of the current release of your project.
31
+ :release: 2010-03-22
32
+
33
+ # A list of gems required by your project during runtime.
34
+ #
35
+ # :runtime:
36
+ # # your project needs exactly version 1.2.3 of the "an_example" gem
37
+ # an_example: 1.2.3
38
+ #
39
+ # # your project needs at least version 1.2 (but not
40
+ # # version 1.2.4 or newer) of the "another_example" gem
41
+ # another_example: [ >= 1.2 , < 1.2.4 ]
42
+ #
43
+ # # your project needs any version of the "yet_another_example" gem
44
+ # yet_another_example:
45
+ #
46
+ :runtime:
47
+
48
+ # A list of gems required by your project during development.
49
+ #
50
+ # :devtime:
51
+ # # your project needs exactly version 1.2.3 of the "an_example" gem
52
+ # an_example: 1.2.3
53
+ #
54
+ # # your project needs at least version 1.2 (but not
55
+ # # version 1.2.4 or newer) of the "another_example" gem
56
+ # another_example: [ >= 1.2 , < 1.2.4 ]
57
+ #
58
+ # # your project needs any version of the "yet_another_example" gem
59
+ # yet_another_example:
60
+ #
61
+ :devtime:
62
+ dfect: ~> 2 # for unit testing
63
+
64
+ --- # parameters for the `inochi` command ------------------------------------
65
+
66
+ # Location where project documentation will be uploaded by `inochi pub:doc`.
67
+ :pub_doc_target: ~/www/lib/rumai/
68
+
69
+ # Options for the `rsync` command used to upload your project's documentation.
70
+ :pub_doc_options: --verbose --compress --archive --update --delete
71
+
72
+ # Path to YAML file containing login information for publishing announcements.
73
+ :pub_ann_logins: ~/.config/inochi/pub_ann_logins.yaml
74
+
75
+ # Your project's unique identifier in the RAA (Ruby Application Archive).
76
+ :pub_ann_raa_id: rumai
77
+
78
+ # Arbitrary Ruby code to configure your project's
79
+ # RubyGem, whose Gem::Specification object is made
80
+ # available to the given code in the `gem` variable.
81
+ #
82
+ # :gem_spec_logic: |
83
+ # # view the Inochi-provided default configuration of your RubyGem
84
+ # puts gem
85
+ #
86
+ # # add files that are outside your project directory to your RubyGem
87
+ # gem.files += FileList['/some/outside/**/*.files']
88
+ #
89
+ # # omit some files in your project directory from your RubyGem
90
+ # gem.files.exclude '{some*files,in_your,project/**/directory}'
91
+ #
92
+ # # and so on... anything is possible! use your imagination!
93
+ #
94
+ :gem_spec_logic: |
@@ -1,8 +1,4 @@
1
1
  # An interface to wmii's IXP library for Rumai.
2
- #--
3
- # Copyright protects this work.
4
- # See LICENSE file for details.
5
- #++
6
2
 
7
3
  require 'rumai/ixp/message'
8
4
  require 'rumai/ixp/transport'
@@ -1,13 +1,7 @@
1
1
  # Primitives for the 9P2000 protocol.
2
2
  #
3
3
  # See http://cm.bell-labs.com/sys/man/5/INDEX.html
4
- #
5
4
  # See http://swtch.com/plan9port/man/man9/
6
- #
7
- #--
8
- # Copyright protects this work.
9
- # See LICENSE file for details.
10
- #++
11
5
 
12
6
  module Rumai
13
7
  module IXP
@@ -54,7 +48,7 @@ module Rumai
54
48
  ##
55
49
  # Allows field values to be initialized via the constructor.
56
50
  #
57
- # [field_values]
51
+ # @param field_values
58
52
  # a mapping from field name to field value
59
53
  #
60
54
  def initialize field_values = {}
@@ -100,7 +94,8 @@ module Rumai
100
94
  ##
101
95
  # Defines a new field in this Struct.
102
96
  #
103
- # [args] arguments for Field.new()
97
+ # @param args
98
+ # arguments for {Field.new}
104
99
  #
105
100
  def field name, format = nil, *args
106
101
  klass = Field.factory(format)
@@ -135,8 +130,6 @@ module Rumai
135
130
  end
136
131
  end
137
132
 
138
- private
139
-
140
133
  ##
141
134
  # A field inside a Struct.
142
135
  #
@@ -148,13 +141,13 @@ module Rumai
148
141
  attr_reader :name, :format, :counter, :countee
149
142
 
150
143
  ##
151
- # [name]
144
+ # @param name
152
145
  # unique (among all fields in a struct) name for the field
153
146
  #
154
- # [format]
147
+ # @param format
155
148
  # number of bytes, a class, or nil
156
149
  #
157
- # [counter]
150
+ # @param [Field] counter
158
151
  # field which counts the length of this field's value
159
152
  #
160
153
  def initialize name, format = nil, counter = nil
@@ -272,8 +265,6 @@ module Rumai
272
265
  end
273
266
  end
274
267
 
275
- #:stopdoc:
276
-
277
268
  ##
278
269
  # A field whose value knows how to convert itself to and from 9p.
279
270
  #
@@ -310,8 +301,6 @@ module Rumai
310
301
  stream.read_9p(4) | (stream.read_9p(4) << BYTE4_BITS)
311
302
  end
312
303
  end
313
-
314
- #:startdoc:
315
304
  end
316
305
 
317
306
  ##
@@ -1,8 +1,4 @@
1
1
  # Transport layer for 9P2000 protocol.
2
- #--
3
- # Copyright protects this work.
4
- # See LICENSE file for details.
5
- #++
6
2
 
7
3
  require 'rumai/ixp/message'
8
4
  require 'thread' # for Mutex and Queue
@@ -20,7 +16,7 @@ module Rumai
20
16
  attr_reader :msize
21
17
 
22
18
  ##
23
- # [stream]
19
+ # @param stream
24
20
  # I/O stream on which a 9P2000 server is listening.
25
21
  #
26
22
  def initialize stream
@@ -105,7 +101,7 @@ module Rumai
105
101
  end
106
102
 
107
103
  ##
108
- # Sends the given request (Rumai::IXP::Fcall) and returns
104
+ # Sends the given request {Rumai::IXP::Fcall} and returns
109
105
  # a ticket that you can use later to receive the reply.
110
106
  #
111
107
  def send request
@@ -119,7 +115,7 @@ module Rumai
119
115
 
120
116
  ##
121
117
  # Returns the reply for the given ticket, which was previously given
122
- # to you when you sent the corresponding request (Rumai::IXP::Fcall).
118
+ # to you when you sent the corresponding request {Rumai::IXP::Fcall}.
123
119
  #
124
120
  def recv tag
125
121
  loop do
@@ -127,17 +123,30 @@ module Rumai
127
123
  if @recv_buf.key? tag
128
124
  @recv_buf.delete tag
129
125
  else
130
- # reply was not in the receive buffer, so wait
131
- # for the next reply... hoping that it is ours
132
- msg = Fcall.from_9p(@stream)
133
-
134
- if msg.tag == tag
135
- msg
136
- else
137
- # we got someone else's reply, so buffer
138
- # it (for them to receive) and try again
139
- @recv_buf[msg.tag] = msg
140
- nil
126
+ # reply was not in receive buffer, so read
127
+ # the next reply... hoping that it is ours
128
+
129
+ next_reply_available =
130
+ @recv_buf.empty? || begin
131
+ # check (in a non-blocking fashion) if
132
+ # the stream has reply for us right now
133
+ @stream.ungetc @stream.read_nonblock(1)
134
+ true
135
+ rescue Errno::EAGAIN
136
+ # the stream is empty
137
+ end
138
+
139
+ if next_reply_available
140
+ msg = Fcall.from_9p(@stream)
141
+
142
+ if msg.tag == tag
143
+ msg
144
+ else
145
+ # we got someone else's reply, so buffer
146
+ # it (for them to receive) and try again
147
+ @recv_buf[msg.tag] = msg
148
+ nil
149
+ end
141
150
  end
142
151
  end
143
152
  end
@@ -158,7 +167,7 @@ module Rumai
158
167
  end
159
168
 
160
169
  ##
161
- # Sends the given request (Rumai::IXP::Fcall) and returns its reply.
170
+ # Sends the given request {Rumai::IXP::Fcall} and returns its reply.
162
171
  #
163
172
  def talk request
164
173
  tag = send(request)
@@ -190,13 +199,13 @@ module Rumai
190
199
  end
191
200
 
192
201
  ##
193
- # Opens the given path for I/O access through a FidStream
202
+ # Opens the given path for I/O access through a {FidStream}
194
203
  # object. If a block is given, it is invoked with a
195
- # FidStream object and the stream is closed afterwards.
204
+ # {FidStream} object and the stream is closed afterwards.
196
205
  #
197
- # See File::open in the Ruby documentation.
206
+ # @see File::open
198
207
  #
199
- def open path, mode = 'r' # :yields: FidStream
208
+ def open path, mode = 'r'
200
209
  mode = MODES.parse(mode)
201
210
 
202
211
  # open the file
@@ -224,7 +233,7 @@ module Rumai
224
233
  ##
225
234
  # Encapsulates I/O access over a file handle (fid).
226
235
  #
227
- # NOTE: this class is NOT thread safe!
236
+ # @note this class is NOT thread safe!
228
237
  #
229
238
  class FidStream
230
239
  attr_reader :fid, :stat
@@ -272,17 +281,17 @@ module Rumai
272
281
 
273
282
  ##
274
283
  # Reads some data from this stream at the current position.
284
+ # If this stream corresponds to a directory, then an Array of
285
+ # Stat (one for each file in the directory) will be returned.
286
+ #
287
+ # @param [Boolean] partial
275
288
  #
276
- # [partial]
277
289
  # When false, the entire content of
278
290
  # this stream is read and returned.
279
291
  #
280
292
  # When true, the maximum amount of content that can fit
281
293
  # inside a single 9P2000 message is read and returned.
282
294
  #
283
- # If this stream corresponds to a directory, then an Array of
284
- # Stat (one for each file in the directory) will be returned.
285
- #
286
295
  def read partial = false
287
296
  raise 'cannot read from a closed stream' if @closed
288
297
 
@@ -355,7 +364,7 @@ module Rumai
355
364
  # Returns the basenames of all files
356
365
  # inside the directory at the given path.
357
366
  #
358
- # See Dir::entries in the Ruby documentation.
367
+ # @see Dir::entries
359
368
  #
360
369
  def entries path
361
370
  unless stat(path).directory?
@@ -478,7 +487,7 @@ module Rumai
478
487
  ##
479
488
  # Invokes the given block with a temporary FID.
480
489
  #
481
- def with_fid # :yields: fid
490
+ def with_fid
482
491
  begin
483
492
  fid = @fid_pool.obtain
484
493
  yield fid