rumai 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/Rakefile +1 -1
  2. data/doc/api/classes/Integer.src/M000002.html +1 -1
  3. data/doc/api/classes/Rumai.html +1 -1
  4. data/doc/api/classes/Rumai.src/M000015.html +1 -1
  5. data/doc/api/classes/Rumai.src/M000016.html +1 -1
  6. data/doc/api/classes/Rumai.src/M000017.html +1 -1
  7. data/doc/api/classes/Rumai.src/M000018.html +1 -1
  8. data/doc/api/classes/Rumai.src/M000019.html +1 -1
  9. data/doc/api/classes/Rumai.src/M000020.html +1 -1
  10. data/doc/api/classes/Rumai.src/M000021.html +1 -1
  11. data/doc/api/classes/Rumai.src/M000022.html +1 -1
  12. data/doc/api/classes/Rumai.src/M000023.html +1 -1
  13. data/doc/api/classes/Rumai.src/M000024.html +1 -1
  14. data/doc/api/classes/Rumai.src/M000025.html +1 -1
  15. data/doc/api/classes/Rumai.src/M000026.html +1 -1
  16. data/doc/api/classes/Rumai/Area.html +87 -87
  17. data/doc/api/classes/Rumai/Area.src/{M000091.html → M000079.html} +5 -8
  18. data/doc/api/classes/Rumai/Area.src/M000080.html +4 -5
  19. data/doc/api/classes/Rumai/Area.src/M000081.html +3 -3
  20. data/doc/api/classes/Rumai/Area.src/M000082.html +5 -5
  21. data/doc/api/classes/Rumai/Area.src/M000083.html +3 -3
  22. data/doc/api/classes/Rumai/Area.src/M000084.html +3 -3
  23. data/doc/api/classes/Rumai/Area.src/M000085.html +4 -4
  24. data/doc/api/classes/Rumai/Area.src/M000086.html +4 -4
  25. data/doc/api/classes/Rumai/Area.src/M000087.html +4 -4
  26. data/doc/api/classes/Rumai/Area.src/M000088.html +4 -4
  27. data/doc/api/classes/Rumai/Area.src/M000089.html +4 -4
  28. data/doc/api/classes/Rumai/Area.src/M000090.html +7 -3
  29. data/doc/api/classes/Rumai/Area.src/M000092.html +23 -0
  30. data/doc/api/classes/Rumai/Area.src/M000093.html +8 -3
  31. data/doc/api/classes/Rumai/Area.src/M000094.html +4 -14
  32. data/doc/api/classes/Rumai/Area.src/M000095.html +17 -4
  33. data/doc/api/classes/Rumai/Chain.html +18 -18
  34. data/doc/api/classes/Rumai/Chain.src/{M000079.html → M000076.html} +4 -4
  35. data/doc/api/classes/Rumai/Chain.src/M000077.html +4 -4
  36. data/doc/api/classes/Rumai/Chain.src/M000078.html +4 -4
  37. data/doc/api/classes/Rumai/Client.html +48 -30
  38. data/doc/api/classes/Rumai/Client.src/M000113.html +18 -0
  39. data/doc/api/classes/Rumai/Client.src/M000114.html +4 -4
  40. data/doc/api/classes/Rumai/Client.src/M000115.html +5 -5
  41. data/doc/api/classes/Rumai/Client.src/M000116.html +26 -5
  42. data/doc/api/classes/Rumai/Client.src/M000117.html +5 -25
  43. data/doc/api/classes/Rumai/Client.src/M000118.html +4 -13
  44. data/doc/api/classes/Rumai/Client.src/M000119.html +4 -5
  45. data/doc/api/classes/Rumai/Client.src/M000120.html +1 -1
  46. data/doc/api/classes/Rumai/Client.src/M000121.html +1 -1
  47. data/doc/api/classes/Rumai/Client.src/M000122.html +1 -1
  48. data/doc/api/classes/Rumai/Client.src/M000123.html +1 -1
  49. data/doc/api/classes/Rumai/Client.src/M000124.html +1 -1
  50. data/doc/api/classes/Rumai/Client.src/M000125.html +1 -1
  51. data/doc/api/classes/Rumai/Client.src/M000126.html +1 -1
  52. data/doc/api/classes/Rumai/Client.src/M000127.html +1 -1
  53. data/doc/api/classes/Rumai/Client.src/M000128.html +1 -1
  54. data/doc/api/classes/Rumai/Client.src/M000129.html +1 -1
  55. data/doc/api/classes/Rumai/Client.src/M000130.html +1 -1
  56. data/doc/api/classes/Rumai/ClientContainer.src/M000027.html +1 -1
  57. data/doc/api/classes/Rumai/ClientContainer.src/M000028.html +1 -1
  58. data/doc/api/classes/Rumai/ClientContainer.src/M000029.html +1 -1
  59. data/doc/api/classes/Rumai/IXP/Agent.html +77 -77
  60. data/doc/api/classes/Rumai/IXP/Agent.src/M000044.html +53 -0
  61. data/doc/api/classes/Rumai/IXP/Agent.src/M000045.html +36 -0
  62. data/doc/api/classes/Rumai/IXP/Agent.src/M000046.html +20 -28
  63. data/doc/api/classes/Rumai/IXP/Agent.src/M000047.html +5 -29
  64. data/doc/api/classes/Rumai/IXP/Agent.src/M000048.html +7 -24
  65. data/doc/api/classes/Rumai/IXP/Agent.src/M000049.html +5 -5
  66. data/doc/api/classes/Rumai/IXP/Agent.src/M000050.html +18 -7
  67. data/doc/api/classes/Rumai/IXP/Agent.src/M000051.html +5 -6
  68. data/doc/api/classes/Rumai/IXP/Agent.src/M000052.html +4 -19
  69. data/doc/api/classes/Rumai/IXP/Agent.src/M000053.html +7 -5
  70. data/doc/api/classes/Rumai/IXP/Agent.src/M000054.html +6 -4
  71. data/doc/api/classes/Rumai/IXP/Agent.src/M000055.html +6 -7
  72. data/doc/api/classes/Rumai/IXP/Agent.src/M000056.html +8 -6
  73. data/doc/api/classes/Rumai/IXP/Agent.src/M000057.html +9 -6
  74. data/doc/api/classes/Rumai/IXP/Agent.src/M000058.html +5 -8
  75. data/doc/api/classes/Rumai/IXP/Agent/FidStream.html +93 -35
  76. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000060.html +23 -0
  77. data/doc/api/classes/Rumai/IXP/{Struct/Field.src/M000040.html → Agent/FidStream.src/M000061.html} +5 -4
  78. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000062.html +8 -8
  79. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000063.html +4 -7
  80. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000064.html +12 -9
  81. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000065.html +21 -11
  82. data/doc/api/classes/Rumai/IXP/Agent/MODES.html +5 -5
  83. data/doc/api/classes/Rumai/IXP/Agent/MODES.src/{M000061.html → M000059.html} +0 -0
  84. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.html +16 -16
  85. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000067.html +22 -0
  86. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000068.html +21 -8
  87. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000069.html +4 -18
  88. data/doc/api/classes/Rumai/IXP/Fcall.html +21 -21
  89. data/doc/api/classes/Rumai/IXP/Fcall.src/M000070.html +20 -0
  90. data/doc/api/classes/Rumai/IXP/Fcall.src/M000071.html +11 -6
  91. data/doc/api/classes/Rumai/IXP/Fcall.src/M000072.html +4 -11
  92. data/doc/api/classes/Rumai/IXP/Fcall.src/M000073.html +3 -3
  93. data/doc/api/classes/Rumai/IXP/Stat.html +5 -5
  94. data/doc/api/classes/Rumai/IXP/Stat.src/{M000076.html → M000075.html} +1 -1
  95. data/doc/api/classes/Rumai/IXP/Stream.html +5 -5
  96. data/doc/api/classes/Rumai/IXP/Stream.src/{M000045.html → M000043.html} +1 -2
  97. data/doc/api/classes/Rumai/IXP/Struct.html +11 -47
  98. data/doc/api/classes/Rumai/IXP/Struct.src/M000030.html +1 -1
  99. data/doc/api/classes/Rumai/IXP/Struct.src/M000031.html +4 -4
  100. data/doc/api/classes/Rumai/IXP/Struct.src/M000032.html +5 -3
  101. data/doc/api/classes/Rumai/IXP/Struct.src/M000033.html +43 -4
  102. data/doc/api/classes/Rumai/IXP/Struct/Field.html +34 -42
  103. data/doc/api/classes/Rumai/IXP/Struct/Field.src/M000034.html +21 -0
  104. data/doc/api/classes/Rumai/IXP/Struct/Field.src/{M000041.html → M000035.html} +7 -4
  105. data/doc/api/classes/Rumai/IXP/Struct/Field.src/M000036.html +6 -7
  106. data/doc/api/classes/Rumai/IXP/Struct/Field.src/M000037.html +13 -5
  107. data/doc/api/classes/Rumai/IXP/Struct/Field.src/M000038.html +4 -6
  108. data/doc/api/classes/Rumai/IXP/Struct/Field.src/M000039.html +4 -15
  109. data/doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.html +12 -12
  110. data/doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/{M000043.html → M000041.html} +3 -3
  111. data/doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/{M000044.html → M000042.html} +4 -4
  112. data/doc/api/classes/Rumai/IXP/Struct/Field/CounterField.html +6 -6
  113. data/doc/api/classes/Rumai/IXP/Struct/Field/CounterField.src/{M000042.html → M000040.html} +3 -3
  114. data/doc/api/classes/Rumai/IXP/Terror.html +5 -5
  115. data/doc/api/classes/Rumai/IXP/Terror.src/{M000075.html → M000074.html} +1 -1
  116. data/doc/api/classes/Rumai/Node.html +88 -88
  117. data/doc/api/classes/Rumai/Node.src/M000096.html +18 -0
  118. data/doc/api/classes/Rumai/Node.src/M000097.html +4 -4
  119. data/doc/api/classes/Rumai/Node.src/M000098.html +8 -4
  120. data/doc/api/classes/Rumai/Node.src/M000099.html +4 -8
  121. data/doc/api/classes/Rumai/Node.src/M000100.html +4 -4
  122. data/doc/api/classes/Rumai/Node.src/M000101.html +4 -4
  123. data/doc/api/classes/Rumai/Node.src/M000102.html +4 -4
  124. data/doc/api/classes/Rumai/Node.src/M000103.html +8 -4
  125. data/doc/api/classes/Rumai/Node.src/M000104.html +4 -8
  126. data/doc/api/classes/Rumai/Node.src/M000105.html +4 -4
  127. data/doc/api/classes/Rumai/Node.src/M000106.html +4 -4
  128. data/doc/api/classes/Rumai/Node.src/M000107.html +4 -4
  129. data/doc/api/classes/Rumai/Node.src/M000108.html +4 -4
  130. data/doc/api/classes/Rumai/Node.src/M000109.html +4 -4
  131. data/doc/api/classes/Rumai/Node.src/M000110.html +5 -5
  132. data/doc/api/classes/Rumai/Node.src/M000111.html +7 -5
  133. data/doc/api/classes/Rumai/Node.src/M000112.html +12 -5
  134. data/doc/api/classes/Rumai/View.html +2 -2
  135. data/doc/api/classes/Rumai/View.src/M000131.html +1 -1
  136. data/doc/api/classes/Rumai/View.src/M000132.html +1 -1
  137. data/doc/api/classes/Rumai/View.src/M000133.html +1 -1
  138. data/doc/api/classes/Rumai/View.src/M000134.html +1 -1
  139. data/doc/api/classes/Rumai/View.src/M000135.html +1 -1
  140. data/doc/api/classes/Rumai/View.src/M000136.html +1 -1
  141. data/doc/api/classes/Rumai/View.src/M000137.html +1 -1
  142. data/doc/api/classes/Rumai/View.src/M000138.html +1 -1
  143. data/doc/api/classes/Rumai/View.src/M000139.html +1 -1
  144. data/doc/api/classes/Rumai/View.src/M000140.html +1 -1
  145. data/doc/api/classes/Rumai/View.src/M000141.html +3 -3
  146. data/doc/api/classes/Rumai/View.src/M000142.html +1 -1
  147. data/doc/api/classes/Rumai/View.src/M000143.html +1 -1
  148. data/doc/api/classes/Rumai/View.src/M000144.html +1 -1
  149. data/doc/api/classes/Rumai/View.src/M000145.html +1 -1
  150. data/doc/api/classes/Rumai/View.src/M000146.html +1 -1
  151. data/doc/api/classes/String.src/M000005.html +1 -1
  152. data/doc/api/classes/String.src/M000006.html +2 -3
  153. data/doc/api/classes/Time.src/M000003.html +1 -1
  154. data/doc/api/classes/Time.src/M000004.html +1 -1
  155. data/doc/api/created.rid +1 -1
  156. data/doc/api/files/lib/rumai/fs_rb.html +1 -1
  157. data/doc/api/files/lib/rumai/ixp/message_rb.html +1 -1
  158. data/doc/api/files/lib/rumai/ixp/transport_rb.html +1 -1
  159. data/doc/api/files/lib/rumai/nfo_rb.html +1 -1
  160. data/doc/api/files/lib/rumai/wm_rb.html +1 -1
  161. data/doc/api/fr_method_index.html +91 -91
  162. data/doc/guide.erb +2 -2
  163. data/doc/guide.html +49 -41
  164. data/lib/rumai/fs.rb +3 -3
  165. data/lib/rumai/ixp/message.rb +19 -36
  166. data/lib/rumai/ixp/transport.rb +98 -85
  167. data/lib/rumai/nfo.rb +2 -2
  168. data/lib/rumai/wm.rb +15 -25
  169. metadata +24 -25
  170. data/doc/api/classes/Rumai/Area.src/M000096.html +0 -31
  171. data/doc/api/classes/Rumai/IXP/Agent.src/M000059.html +0 -23
  172. data/doc/api/classes/Rumai/IXP/Agent.src/M000060.html +0 -19
  173. data/doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000066.html +0 -36
  174. data/doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000070.html +0 -20
  175. data/doc/api/classes/Rumai/IXP/Fcall.src/M000074.html +0 -18
  176. data/doc/api/classes/Rumai/IXP/Struct.src/M000034.html +0 -20
  177. data/doc/api/classes/Rumai/IXP/Struct.src/M000035.html +0 -57
  178. data/doc/api/classes/Rumai/Node.src/M000113.html +0 -27
  179. data/doc/index.html +0 -2035
@@ -14,15 +14,21 @@ module Rumai
14
14
  attr_reader :msize
15
15
 
16
16
  def initialize aStream
17
- @stream = aStream
18
- @sendLock = Mutex.new
19
- @recvLock = Mutex.new
20
-
21
- @responses = {} # tag => message
22
- @tagPool = RangedPool.new(0...BYTE2_MASK)
17
+ @stream = aStream
18
+ @sendLock = Mutex.new
19
+ @recvBays = Hash.new {|h,k| h[k] = Queue.new } # tag => Queue(message)
20
+
21
+ # background thread which continuously receives
22
+ # and dispatches messages from the 9P2000 server
23
+ Thread.new do
24
+ while true
25
+ msg = Fcall.from_9p @stream
26
+ @recvBays[msg.tag] << msg
27
+ end
28
+ end.priority = -1
23
29
 
24
- @fidPool = RangedPool.new(0...BYTE4_MASK)
25
- @msize = Tversion::MSIZE
30
+ @tagPool = RangedPool.new(0...BYTE2_MASK)
31
+ @fidPool = RangedPool.new(0...BYTE4_MASK)
26
32
 
27
33
  # establish connection with 9P2000 server
28
34
  req = Tversion.new(
@@ -48,7 +54,8 @@ module Rumai
48
54
 
49
55
  # A finite, thread-safe pool of range members.
50
56
  class RangedPool
51
- # how many new members should be added to the pool when the pool is empty?
57
+ # how many new members should be added
58
+ # to the pool when the pool is empty?
52
59
  FILL_RATE = 10
53
60
 
54
61
  def initialize aRange
@@ -56,35 +63,36 @@ module Rumai
56
63
  @lim = aRange.last
57
64
  @lim = @lim.succ unless aRange.exclude_end?
58
65
 
59
- @pool = Array.new
60
- @lock = Mutex.new
66
+ @pool = Queue.new
61
67
  end
62
68
 
63
69
  # Returns an unoccupied range member from the pool.
64
70
  def obtain
65
- until member = @lock.synchronize { @pool.shift }
66
- # the pool is empty, so fill it
67
- @lock.synchronize do
68
- FILL_RATE.times do
69
- if @pos != @lim
70
- @pool.push @pos
71
- @pos = @pos.succ
72
- else
73
- break
74
- end
71
+ begin
72
+ @pool.deq true
73
+
74
+ rescue ThreadError
75
+ # pool is empty, so fill it
76
+ FILL_RATE.times do
77
+ if @pos != @lim
78
+ @pool << @pos
79
+ @pos = @pos.succ
80
+ else
81
+ # range is exhausted, so give other threads
82
+ # a chance to fill the pool before retrying
83
+ Thread.pass
84
+ break
75
85
  end
76
- end or Thread.pass # range is exhausted, so wait for other threads to fill the pool
77
- end
86
+ end
78
87
 
79
- member
88
+ retry
89
+ end
80
90
  end
81
91
 
82
92
  # Marks the given member as being unoccupied so
83
93
  # that it may be occupied again in the future.
84
94
  def release aMember
85
- @lock.synchronize do
86
- @pool.push aMember
87
- end
95
+ @pool << aMember
88
96
  end
89
97
  end
90
98
 
@@ -94,32 +102,24 @@ module Rumai
94
102
  # worrying about the details of tag collisions and thread safety.
95
103
  #
96
104
  def talk aRequest
97
- # send the messsage
98
- ticket = aRequest.tag = @tagPool.obtain
105
+ # send the request
106
+ tag = @tagPool.obtain
107
+ bay = @recvBays[tag]
99
108
 
109
+ aRequest.tag = tag
110
+ output = aRequest.to_9p
100
111
  @sendLock.synchronize do
101
- @stream << aRequest.to_9p
112
+ @stream << output
102
113
  end
103
114
 
104
115
  # receive the response
105
- while true
106
- # check for *my* response in the bucket
107
- if response = @recvLock.synchronize { @responses.delete ticket }
108
- @tagPool.release ticket
109
-
110
- if response.is_a? Rerror
111
- raise Error, "#{response.ename.inspect} in response to #{aRequest.inspect}"
112
- else
113
- return response
114
- end
116
+ response = bay.shift
117
+ @tagPool.release tag
115
118
 
116
- # put the next response into the bucket
117
- else
118
- @recvLock.synchronize do
119
- response = Fcall.from_9p @stream
120
- @responses[response.tag] = response
121
- end
122
- end
119
+ if response.is_a? Rerror
120
+ raise Error, "#{response.ename.inspect} in response to #{aRequest.inspect}"
121
+ else
122
+ return response
123
123
  end
124
124
  end
125
125
 
@@ -170,8 +170,15 @@ module Rumai
170
170
  end
171
171
 
172
172
  # Encapsulates I/O access over a file handle (fid).
173
+ # NOTE that this class is NOT thread-safe.
173
174
  class FidStream
174
- attr_reader :fid
175
+ attr_reader :fid, :stat
176
+
177
+ attr_reader :eof
178
+ alias eof? eof
179
+
180
+ attr_accessor :pos
181
+ alias tell pos
175
182
 
176
183
  def initialize aAgent, aPathFid, aMessageSize
177
184
  @agent = aAgent
@@ -179,6 +186,13 @@ module Rumai
179
186
  @msize = aMessageSize
180
187
  @stat = @agent.stat_fid @fid
181
188
  @closed = false
189
+ rewind
190
+ end
191
+
192
+ # Rewinds the stream to the beginning.
193
+ def rewind
194
+ @pos = 0
195
+ @eof = false
182
196
  end
183
197
 
184
198
  # Closes this stream.
@@ -186,25 +200,41 @@ module Rumai
186
200
  unless @closed
187
201
  @agent.clunk @fid
188
202
  @closed = true
203
+ @eof = true
189
204
  end
190
205
  end
191
206
 
192
- # Returns the entire content of this stream. If this
193
- # stream corresponds to a directory, then an Array of Stat
194
- # (one for each file in the directory) will be returned.
195
- def read
207
+ # Returns true if this stream is closed.
208
+ def closed?
209
+ @closed
210
+ end
211
+
212
+ # Reads some data from this stream at the current position.
213
+ #
214
+ # aPartial:: When false, the entire content of this stream
215
+ # is read and returned. When true, the maximum
216
+ # amount of content that can fit inside a
217
+ # single 9P2000 message is read and returned.
218
+ #
219
+ # If this stream corresponds to a directory, then an Array of
220
+ # Stat (one for each file in the directory) will be returned.
221
+ #
222
+ def read aPartial = false
196
223
  raise 'cannot read from a closed stream' if @closed
197
224
 
198
225
  content = ''
199
- offset = 0
200
-
201
226
  begin
202
- chunk = read_partial(offset)
203
- content << chunk
227
+ req = Tread.new(
228
+ :fid => @fid,
229
+ :offset => @pos,
230
+ :count => @msize
231
+ )
232
+ rsp = @agent.talk(req)
204
233
 
205
- count = chunk.length
206
- offset = (offset + count) % BYTE8_LIMIT
207
- end until count < @msize
234
+ content << rsp.data
235
+ count = rsp.count
236
+ @pos += count
237
+ end until @eof = count.zero? or aPartial
208
238
 
209
239
  # the content of a directory is a sequence
210
240
  # of Stat for all files in that directory
@@ -220,43 +250,26 @@ module Rumai
220
250
  content
221
251
  end
222
252
 
223
- # Returns the maximum amount of content that can fit in
224
- # one 9P2000 message, starting from the given offset.
225
- #
226
- # The end of file is reached when the returned
227
- # content string is empty (has zero length).
228
- def read_partial aOffset = 0
229
- raise 'cannot read from a closed stream' if @closed
230
-
231
- req = Tread.new(
232
- :fid => @fid,
233
- :offset => aOffset,
234
- :count => @msize
235
- )
236
- rsp = @agent.talk(req)
237
- rsp.data
238
- end
239
-
240
- # Writes the given content to the beginning of this stream.
253
+ # Writes the given content at the current position in this stream.
241
254
  def write aContent
242
255
  raise 'closed streams cannot be written to' if @closed
243
256
  raise 'directories cannot be written to' if @stat.directory?
244
257
 
245
- offset = 0
246
- content = aContent.to_s
258
+ data = aContent.to_s
259
+ limit = data.length + @pos
247
260
 
248
- while offset < content.length
249
- chunk = content[offset, @msize]
261
+ while @pos < limit
262
+ chunk = data[@pos, @msize]
250
263
 
251
264
  req = Twrite.new(
252
265
  :fid => @fid,
253
- :offset => offset,
266
+ :offset => @pos,
254
267
  :count => chunk.length,
255
268
  :data => chunk
256
269
  )
257
270
  rsp = @agent.talk(req)
258
271
 
259
- offset += rsp.count
272
+ @pos += rsp.count
260
273
  end
261
274
  end
262
275
 
@@ -264,9 +277,9 @@ module Rumai
264
277
  end
265
278
 
266
279
  # Returns the content of the file/directory at the given path.
267
- def read aPath
280
+ def read aPath, *aArgs
268
281
  open aPath do |f|
269
- f.read
282
+ f.read(*aArgs)
270
283
  end
271
284
  end
272
285
 
data/lib/rumai/nfo.rb CHANGED
@@ -6,8 +6,8 @@
6
6
  module Rumai
7
7
  NFO = {
8
8
  :name => 'Rumai',
9
- :version => '1.0.0',
10
- :release => '2008-01-26',
9
+ :version => '2.0.0',
10
+ :release => '2008-02-04',
11
11
  :website => 'http://rumai.rubyforge.org',
12
12
  :home => File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
13
13
  }
data/lib/rumai/wm.rb CHANGED
@@ -143,7 +143,7 @@ module Rumai
143
143
  super "#{aPathPrefix}/#{aId}"
144
144
 
145
145
  if aId.to_s == 'sel' and ctl.exist?
146
- @id = ctl.read
146
+ @id = ctl.read.split.first
147
147
  @path = File.join(File.dirname(@path), @id)
148
148
  else
149
149
  @id = File.basename(@path)
@@ -178,7 +178,7 @@ module Rumai
178
178
  def focus aView = nil
179
179
  if exist? and not focus?
180
180
  (aView ? [aView] : self.views).each do |v|
181
- if a = self.area(v)
181
+ if a = self.area(v) and a.exist?
182
182
  v.focus
183
183
  a.focus
184
184
 
@@ -202,15 +202,6 @@ module Rumai
202
202
 
203
203
  # Sends this client to the given destination within the given view.
204
204
  def send aAreaOrId, aView = View.curr
205
- if aAreaOrId.to_s != 'toggle'
206
- # XXX: it is an error to send a floating client directly to a
207
- # managed area, so we gotta "ground" it first and then send it
208
- # to the desired managed area. John-Galt will fix this someday.
209
- if area(aView).float?
210
- aView.ctl.write "send #{@id} toggle"
211
- end
212
- end
213
-
214
205
  dst = area_to_id(aAreaOrId)
215
206
  aView.ctl.write "send #{@id} #{dst}"
216
207
  end
@@ -221,6 +212,11 @@ module Rumai
221
212
  aView.ctl.write "swap #{@id} #{dst}"
222
213
  end
223
214
 
215
+ # Terminates this client nicely (requests this window to be closed).
216
+ def kill
217
+ ctl.write :kill
218
+ end
219
+
224
220
  ##
225
221
  #
226
222
  # WM hierarchy
@@ -316,9 +312,8 @@ module Rumai
316
312
 
317
313
  def area_to_id aAreaOrId
318
314
  if aAreaOrId.respond_to? :id
319
- # XXX: +1 until John-Galt fixes this: right now, index 1
320
- # is floating area; but ~ (0) should be floating area.
321
- aAreaOrId.id+1
315
+ id = aAreaOrId.id
316
+ id == '~' ? :toggle : id
322
317
  else
323
318
  aAreaOrId
324
319
  end
@@ -359,13 +354,13 @@ module Rumai
359
354
 
360
355
  # aView:: the view which contains this area.
361
356
  def initialize aAreaId, aView = View.curr
362
- @id = aAreaId.to_i
357
+ @id = Integer(aAreaId) rescue aAreaId
363
358
  @view = aView
364
359
  end
365
360
 
366
361
  # Checks if this area is the floating area.
367
362
  def float?
368
- @id == 0
363
+ @id == '~'
369
364
  end
370
365
 
371
366
  # Checks if this area is a column in the managed area.
@@ -392,7 +387,7 @@ module Rumai
392
387
  include ClientContainer
393
388
  # Returns the IDs of the clients in this area.
394
389
  def client_ids
395
- @view.client_ids ctl_id
390
+ @view.client_ids @id
396
391
  end
397
392
 
398
393
  include Enumerable
@@ -403,7 +398,7 @@ module Rumai
403
398
 
404
399
  # Sets the layout of clients in this column.
405
400
  def layout= aMode
406
- @view.ctl.write "colmode #{ctl_id} #{aMode}"
401
+ @view.ctl.write "colmode #{@id} #{aMode}"
407
402
  end
408
403
 
409
404
  ##
@@ -414,7 +409,7 @@ module Rumai
414
409
 
415
410
  # Puts focus on this area.
416
411
  def focus
417
- @view.ctl.write "select #{ctl_id}"
412
+ @view.ctl.write "select #{@id}"
418
413
  end
419
414
 
420
415
  ##
@@ -491,11 +486,6 @@ module Rumai
491
486
 
492
487
  private
493
488
 
494
- # Makes the ID usable in wmii's /ctl commands.
495
- def ctl_id
496
- float? ? '~' : @id
497
- end
498
-
499
489
  # Moves the given client into this area.
500
490
  def import_client c
501
491
  if exist?
@@ -594,7 +584,7 @@ module Rumai
594
584
  end
595
585
 
596
586
  # Returns the floating area of this view.
597
- def floating_area
587
+ def floater
598
588
  areas.first
599
589
  end
600
590
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumai
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors: []
7
7
 
@@ -9,11 +9,11 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-01-26 00:00:00 -08:00
12
+ date: 2008-02-04 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: Ruby interface to wmii.
16
+ description: Ruby interface to the wmii window manager.
17
17
  email:
18
18
  executables:
19
19
  - rumai
@@ -41,7 +41,6 @@ files:
41
41
  - doc
42
42
  - doc/guide.html
43
43
  - doc/guide.erb
44
- - doc/index.html
45
44
  - doc/api
46
45
  - doc/api/classes
47
46
  - doc/api/classes/Time.html
@@ -69,8 +68,6 @@ files:
69
68
  - doc/api/classes/Rumai/Area.src
70
69
  - doc/api/classes/Rumai/Area.src/M000094.html
71
70
  - doc/api/classes/Rumai/Area.src/M000080.html
72
- - doc/api/classes/Rumai/Area.src/M000096.html
73
- - doc/api/classes/Rumai/Area.src/M000091.html
74
71
  - doc/api/classes/Rumai/Area.src/M000086.html
75
72
  - doc/api/classes/Rumai/Area.src/M000095.html
76
73
  - doc/api/classes/Rumai/Area.src/M000093.html
@@ -80,6 +77,8 @@ files:
80
77
  - doc/api/classes/Rumai/Area.src/M000083.html
81
78
  - doc/api/classes/Rumai/Area.src/M000087.html
82
79
  - doc/api/classes/Rumai/Area.src/M000081.html
80
+ - doc/api/classes/Rumai/Area.src/M000079.html
81
+ - doc/api/classes/Rumai/Area.src/M000092.html
83
82
  - doc/api/classes/Rumai/Area.src/M000088.html
84
83
  - doc/api/classes/Rumai/Area.src/M000082.html
85
84
  - doc/api/classes/Rumai/Area.src/M000090.html
@@ -90,6 +89,7 @@ files:
90
89
  - doc/api/classes/Rumai/Client.src/M000121.html
91
90
  - doc/api/classes/Rumai/Client.src/M000124.html
92
91
  - doc/api/classes/Rumai/Client.src/M000114.html
92
+ - doc/api/classes/Rumai/Client.src/M000113.html
93
93
  - doc/api/classes/Rumai/Client.src/M000115.html
94
94
  - doc/api/classes/Rumai/Client.src/M000119.html
95
95
  - doc/api/classes/Rumai/Client.src/M000127.html
@@ -112,16 +112,14 @@ files:
112
112
  - doc/api/classes/Rumai/IXP/Struct.src
113
113
  - doc/api/classes/Rumai/IXP/Struct.src/M000032.html
114
114
  - doc/api/classes/Rumai/IXP/Struct.src/M000033.html
115
- - doc/api/classes/Rumai/IXP/Struct.src/M000035.html
116
115
  - doc/api/classes/Rumai/IXP/Struct.src/M000031.html
117
116
  - doc/api/classes/Rumai/IXP/Struct.src/M000030.html
118
- - doc/api/classes/Rumai/IXP/Struct.src/M000034.html
119
117
  - doc/api/classes/Rumai/IXP/Rflush.html
120
118
  - doc/api/classes/Rumai/IXP/Tauth.html
121
119
  - doc/api/classes/Rumai/IXP/Fcall.html
122
120
  - doc/api/classes/Rumai/IXP/Tcreate.html
123
121
  - doc/api/classes/Rumai/IXP/Fcall.src
124
- - doc/api/classes/Rumai/IXP/Fcall.src/M000074.html
122
+ - doc/api/classes/Rumai/IXP/Fcall.src/M000070.html
125
123
  - doc/api/classes/Rumai/IXP/Fcall.src/M000073.html
126
124
  - doc/api/classes/Rumai/IXP/Fcall.src/M000071.html
127
125
  - doc/api/classes/Rumai/IXP/Fcall.src/M000072.html
@@ -132,27 +130,27 @@ files:
132
130
  - doc/api/classes/Rumai/IXP/Tattach.html
133
131
  - doc/api/classes/Rumai/IXP/Rremove.html
134
132
  - doc/api/classes/Rumai/IXP/Stat.src
135
- - doc/api/classes/Rumai/IXP/Stat.src/M000076.html
133
+ - doc/api/classes/Rumai/IXP/Stat.src/M000075.html
136
134
  - doc/api/classes/Rumai/IXP/Rerror.html
137
135
  - doc/api/classes/Rumai/IXP/Stream.src
138
- - doc/api/classes/Rumai/IXP/Stream.src/M000045.html
136
+ - doc/api/classes/Rumai/IXP/Stream.src/M000043.html
139
137
  - doc/api/classes/Rumai/IXP/Struct.html
140
138
  - doc/api/classes/Rumai/IXP/Struct
141
139
  - doc/api/classes/Rumai/IXP/Struct/Field
142
140
  - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.html
143
141
  - doc/api/classes/Rumai/IXP/Struct/Field/CounterField.html
144
142
  - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src
145
- - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/M000043.html
146
- - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/M000044.html
143
+ - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/M000041.html
144
+ - doc/api/classes/Rumai/IXP/Struct/Field/CounteeField.src/M000042.html
147
145
  - doc/api/classes/Rumai/IXP/Struct/Field/CounterField.src
148
- - doc/api/classes/Rumai/IXP/Struct/Field/CounterField.src/M000042.html
146
+ - doc/api/classes/Rumai/IXP/Struct/Field/CounterField.src/M000040.html
149
147
  - doc/api/classes/Rumai/IXP/Struct/Field.src
150
148
  - doc/api/classes/Rumai/IXP/Struct/Field.src/M000038.html
151
149
  - doc/api/classes/Rumai/IXP/Struct/Field.src/M000036.html
152
- - doc/api/classes/Rumai/IXP/Struct/Field.src/M000040.html
153
150
  - doc/api/classes/Rumai/IXP/Struct/Field.src/M000037.html
154
- - doc/api/classes/Rumai/IXP/Struct/Field.src/M000041.html
151
+ - doc/api/classes/Rumai/IXP/Struct/Field.src/M000035.html
155
152
  - doc/api/classes/Rumai/IXP/Struct/Field.src/M000039.html
153
+ - doc/api/classes/Rumai/IXP/Struct/Field.src/M000034.html
156
154
  - doc/api/classes/Rumai/IXP/Struct/Field.html
157
155
  - doc/api/classes/Rumai/IXP/Tstat.html
158
156
  - doc/api/classes/Rumai/IXP/Rstat.html
@@ -171,16 +169,17 @@ files:
171
169
  - doc/api/classes/Rumai/IXP/Tremove.html
172
170
  - doc/api/classes/Rumai/IXP/Agent
173
171
  - doc/api/classes/Rumai/IXP/Agent/FidStream.src
174
- - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000066.html
172
+ - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000060.html
175
173
  - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000063.html
176
174
  - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000065.html
175
+ - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000061.html
177
176
  - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000064.html
178
177
  - doc/api/classes/Rumai/IXP/Agent/FidStream.src/M000062.html
179
178
  - doc/api/classes/Rumai/IXP/Agent/FidStream.html
180
179
  - doc/api/classes/Rumai/IXP/Agent/MODES.src
181
- - doc/api/classes/Rumai/IXP/Agent/MODES.src/M000061.html
180
+ - doc/api/classes/Rumai/IXP/Agent/MODES.src/M000059.html
182
181
  - doc/api/classes/Rumai/IXP/Agent/RangedPool.src
183
- - doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000070.html
182
+ - doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000067.html
184
183
  - doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000068.html
185
184
  - doc/api/classes/Rumai/IXP/Agent/RangedPool.src/M000069.html
186
185
  - doc/api/classes/Rumai/IXP/Agent/MODES.html
@@ -188,12 +187,11 @@ files:
188
187
  - doc/api/classes/Rumai/IXP/Rwalk.html
189
188
  - doc/api/classes/Rumai/IXP/Agent.html
190
189
  - doc/api/classes/Rumai/IXP/Terror.src
191
- - doc/api/classes/Rumai/IXP/Terror.src/M000075.html
190
+ - doc/api/classes/Rumai/IXP/Terror.src/M000074.html
192
191
  - doc/api/classes/Rumai/IXP/Error.html
193
192
  - doc/api/classes/Rumai/IXP/Tclunk.html
194
193
  - doc/api/classes/Rumai/IXP/Ropen.html
195
194
  - doc/api/classes/Rumai/IXP/Agent.src
196
- - doc/api/classes/Rumai/IXP/Agent.src/M000060.html
197
195
  - doc/api/classes/Rumai/IXP/Agent.src/M000055.html
198
196
  - doc/api/classes/Rumai/IXP/Agent.src/M000056.html
199
197
  - doc/api/classes/Rumai/IXP/Agent.src/M000051.html
@@ -203,20 +201,22 @@ files:
203
201
  - doc/api/classes/Rumai/IXP/Agent.src/M000054.html
204
202
  - doc/api/classes/Rumai/IXP/Agent.src/M000049.html
205
203
  - doc/api/classes/Rumai/IXP/Agent.src/M000047.html
204
+ - doc/api/classes/Rumai/IXP/Agent.src/M000044.html
205
+ - doc/api/classes/Rumai/IXP/Agent.src/M000045.html
206
206
  - doc/api/classes/Rumai/IXP/Agent.src/M000052.html
207
207
  - doc/api/classes/Rumai/IXP/Agent.src/M000046.html
208
208
  - doc/api/classes/Rumai/IXP/Agent.src/M000053.html
209
- - doc/api/classes/Rumai/IXP/Agent.src/M000059.html
210
209
  - doc/api/classes/Rumai/IXP/Agent.src/M000057.html
211
210
  - doc/api/classes/Rumai/IXP/Rversion.html
212
211
  - doc/api/classes/Rumai/IXP/Rattach.html
213
212
  - doc/api/classes/Rumai/Chain.src
213
+ - doc/api/classes/Rumai/Chain.src/M000076.html
214
214
  - doc/api/classes/Rumai/Chain.src/M000078.html
215
- - doc/api/classes/Rumai/Chain.src/M000079.html
216
215
  - doc/api/classes/Rumai/Chain.src/M000077.html
217
216
  - doc/api/classes/Rumai/Node.src
218
217
  - doc/api/classes/Rumai/Node.src/M000101.html
219
218
  - doc/api/classes/Rumai/Node.src/M000111.html
219
+ - doc/api/classes/Rumai/Node.src/M000096.html
220
220
  - doc/api/classes/Rumai/Node.src/M000106.html
221
221
  - doc/api/classes/Rumai/Node.src/M000110.html
222
222
  - doc/api/classes/Rumai/Node.src/M000103.html
@@ -224,7 +224,6 @@ files:
224
224
  - doc/api/classes/Rumai/Node.src/M000100.html
225
225
  - doc/api/classes/Rumai/Node.src/M000098.html
226
226
  - doc/api/classes/Rumai/Node.src/M000109.html
227
- - doc/api/classes/Rumai/Node.src/M000113.html
228
227
  - doc/api/classes/Rumai/Node.src/M000105.html
229
228
  - doc/api/classes/Rumai/Node.src/M000099.html
230
229
  - doc/api/classes/Rumai/Node.src/M000112.html
@@ -315,6 +314,6 @@ rubyforge_project: rumai
315
314
  rubygems_version: 1.0.1
316
315
  signing_key:
317
316
  specification_version: 2
318
- summary: Ruby interface to wmii.
317
+ summary: Ruby interface to the wmii window manager.
319
318
  test_files: []
320
319