rio 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. data/ChangeLog +140 -0
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/doc/ANNOUNCE +87 -0
  5. data/doc/RELEASE_NOTES +7 -0
  6. data/doc/rdoc/classes/Kernel.html +9 -9
  7. data/doc/rdoc/classes/Kernel.src/{M000183.html → M000182.html} +0 -0
  8. data/doc/rdoc/classes/RIO.html +35 -0
  9. data/doc/rdoc/classes/RIO.src/M000001.html +4 -4
  10. data/doc/rdoc/classes/RIO.src/M000002.html +4 -4
  11. data/doc/rdoc/classes/RIO.src/M000003.html +4 -4
  12. data/doc/rdoc/classes/RIO/Doc/HOWTO.html +11 -7
  13. data/doc/rdoc/classes/RIO/Doc/INTRO.html +255 -36
  14. data/doc/rdoc/classes/RIO/Doc/SYNOPSIS.html +47 -17
  15. data/doc/rdoc/classes/RIO/Rio.html +1032 -1007
  16. data/doc/rdoc/classes/RIO/Rio.src/M000011.html +3 -3
  17. data/doc/rdoc/classes/RIO/Rio.src/M000012.html +3 -3
  18. data/doc/rdoc/classes/RIO/Rio.src/M000013.html +3 -3
  19. data/doc/rdoc/classes/RIO/Rio.src/M000014.html +3 -3
  20. data/doc/rdoc/classes/RIO/Rio.src/M000015.html +3 -3
  21. data/doc/rdoc/classes/RIO/Rio.src/M000016.html +3 -3
  22. data/doc/rdoc/classes/RIO/Rio.src/M000017.html +3 -3
  23. data/doc/rdoc/classes/RIO/Rio.src/M000018.html +3 -3
  24. data/doc/rdoc/classes/RIO/Rio.src/M000019.html +3 -3
  25. data/doc/rdoc/classes/RIO/Rio.src/M000020.html +3 -3
  26. data/doc/rdoc/classes/RIO/Rio.src/M000021.html +3 -3
  27. data/doc/rdoc/classes/RIO/Rio.src/M000022.html +3 -3
  28. data/doc/rdoc/classes/RIO/Rio.src/M000023.html +3 -3
  29. data/doc/rdoc/classes/RIO/Rio.src/M000024.html +3 -3
  30. data/doc/rdoc/classes/RIO/Rio.src/M000025.html +3 -3
  31. data/doc/rdoc/classes/RIO/Rio.src/M000026.html +3 -3
  32. data/doc/rdoc/classes/RIO/Rio.src/M000027.html +3 -3
  33. data/doc/rdoc/classes/RIO/Rio.src/M000028.html +3 -3
  34. data/doc/rdoc/classes/RIO/Rio.src/M000029.html +3 -3
  35. data/doc/rdoc/classes/RIO/Rio.src/M000030.html +3 -3
  36. data/doc/rdoc/classes/RIO/Rio.src/M000031.html +3 -3
  37. data/doc/rdoc/classes/RIO/Rio.src/M000032.html +3 -3
  38. data/doc/rdoc/classes/RIO/Rio.src/M000033.html +3 -3
  39. data/doc/rdoc/classes/RIO/Rio.src/M000034.html +3 -3
  40. data/doc/rdoc/classes/RIO/Rio.src/M000035.html +3 -3
  41. data/doc/rdoc/classes/RIO/Rio.src/M000036.html +3 -3
  42. data/doc/rdoc/classes/RIO/Rio.src/M000037.html +3 -3
  43. data/doc/rdoc/classes/RIO/Rio.src/M000038.html +3 -3
  44. data/doc/rdoc/classes/RIO/Rio.src/M000039.html +3 -3
  45. data/doc/rdoc/classes/RIO/Rio.src/M000040.html +3 -3
  46. data/doc/rdoc/classes/RIO/Rio.src/M000041.html +3 -3
  47. data/doc/rdoc/classes/RIO/Rio.src/M000042.html +3 -3
  48. data/doc/rdoc/classes/RIO/Rio.src/M000043.html +3 -3
  49. data/doc/rdoc/classes/RIO/Rio.src/M000044.html +3 -3
  50. data/doc/rdoc/classes/RIO/Rio.src/M000045.html +3 -3
  51. data/doc/rdoc/classes/RIO/Rio.src/M000046.html +3 -3
  52. data/doc/rdoc/classes/RIO/Rio.src/M000047.html +3 -3
  53. data/doc/rdoc/classes/RIO/Rio.src/M000048.html +3 -3
  54. data/doc/rdoc/classes/RIO/Rio.src/M000049.html +3 -3
  55. data/doc/rdoc/classes/RIO/Rio.src/M000050.html +3 -3
  56. data/doc/rdoc/classes/RIO/Rio.src/M000051.html +3 -3
  57. data/doc/rdoc/classes/RIO/Rio.src/M000052.html +3 -3
  58. data/doc/rdoc/classes/RIO/Rio.src/M000053.html +3 -3
  59. data/doc/rdoc/classes/RIO/Rio.src/M000054.html +3 -3
  60. data/doc/rdoc/classes/RIO/Rio.src/M000055.html +3 -3
  61. data/doc/rdoc/classes/RIO/Rio.src/M000056.html +3 -3
  62. data/doc/rdoc/classes/RIO/Rio.src/M000057.html +3 -3
  63. data/doc/rdoc/classes/RIO/Rio.src/M000058.html +3 -3
  64. data/doc/rdoc/classes/RIO/Rio.src/M000059.html +3 -3
  65. data/doc/rdoc/classes/RIO/Rio.src/M000060.html +3 -3
  66. data/doc/rdoc/classes/RIO/Rio.src/M000061.html +3 -3
  67. data/doc/rdoc/classes/RIO/Rio.src/M000062.html +3 -3
  68. data/doc/rdoc/classes/RIO/Rio.src/M000063.html +3 -3
  69. data/doc/rdoc/classes/RIO/Rio.src/M000064.html +3 -3
  70. data/doc/rdoc/classes/RIO/Rio.src/M000065.html +3 -3
  71. data/doc/rdoc/classes/RIO/Rio.src/M000066.html +3 -3
  72. data/doc/rdoc/classes/RIO/Rio.src/M000067.html +3 -3
  73. data/doc/rdoc/classes/RIO/Rio.src/M000068.html +3 -3
  74. data/doc/rdoc/classes/RIO/Rio.src/M000069.html +3 -3
  75. data/doc/rdoc/classes/RIO/Rio.src/M000070.html +3 -3
  76. data/doc/rdoc/classes/RIO/Rio.src/M000071.html +3 -3
  77. data/doc/rdoc/classes/RIO/Rio.src/M000072.html +3 -3
  78. data/doc/rdoc/classes/RIO/Rio.src/M000073.html +3 -3
  79. data/doc/rdoc/classes/RIO/Rio.src/M000074.html +3 -3
  80. data/doc/rdoc/classes/RIO/Rio.src/M000075.html +3 -3
  81. data/doc/rdoc/classes/RIO/Rio.src/M000076.html +3 -3
  82. data/doc/rdoc/classes/RIO/Rio.src/M000077.html +3 -3
  83. data/doc/rdoc/classes/RIO/Rio.src/M000078.html +3 -3
  84. data/doc/rdoc/classes/RIO/Rio.src/M000079.html +3 -3
  85. data/doc/rdoc/classes/RIO/Rio.src/M000080.html +3 -3
  86. data/doc/rdoc/classes/RIO/Rio.src/M000081.html +3 -3
  87. data/doc/rdoc/classes/RIO/Rio.src/M000082.html +3 -3
  88. data/doc/rdoc/classes/RIO/Rio.src/M000083.html +3 -3
  89. data/doc/rdoc/classes/RIO/Rio.src/M000084.html +3 -3
  90. data/doc/rdoc/classes/RIO/Rio.src/M000085.html +3 -3
  91. data/doc/rdoc/classes/RIO/Rio.src/M000086.html +3 -3
  92. data/doc/rdoc/classes/RIO/Rio.src/M000087.html +3 -3
  93. data/doc/rdoc/classes/RIO/Rio.src/M000088.html +3 -3
  94. data/doc/rdoc/classes/RIO/Rio.src/M000089.html +2 -2
  95. data/doc/rdoc/classes/RIO/Rio.src/M000090.html +2 -2
  96. data/doc/rdoc/classes/RIO/Rio.src/M000091.html +2 -2
  97. data/doc/rdoc/classes/RIO/Rio.src/M000092.html +2 -2
  98. data/doc/rdoc/classes/RIO/Rio.src/M000093.html +2 -2
  99. data/doc/rdoc/classes/RIO/Rio.src/M000094.html +2 -2
  100. data/doc/rdoc/classes/RIO/Rio.src/M000095.html +2 -2
  101. data/doc/rdoc/classes/RIO/Rio.src/M000096.html +2 -2
  102. data/doc/rdoc/classes/RIO/Rio.src/M000097.html +2 -2
  103. data/doc/rdoc/classes/RIO/Rio.src/M000098.html +2 -2
  104. data/doc/rdoc/classes/RIO/Rio.src/M000099.html +2 -2
  105. data/doc/rdoc/classes/RIO/Rio.src/M000100.html +2 -2
  106. data/doc/rdoc/classes/RIO/Rio.src/M000101.html +2 -2
  107. data/doc/rdoc/classes/RIO/Rio.src/M000102.html +2 -2
  108. data/doc/rdoc/classes/RIO/Rio.src/M000103.html +2 -2
  109. data/doc/rdoc/classes/RIO/Rio.src/M000104.html +2 -2
  110. data/doc/rdoc/classes/RIO/Rio.src/M000105.html +2 -2
  111. data/doc/rdoc/classes/RIO/Rio.src/M000106.html +2 -2
  112. data/doc/rdoc/classes/RIO/Rio.src/M000107.html +2 -2
  113. data/doc/rdoc/classes/RIO/Rio.src/M000108.html +3 -3
  114. data/doc/rdoc/classes/RIO/Rio.src/M000109.html +3 -3
  115. data/doc/rdoc/classes/RIO/Rio.src/M000110.html +3 -3
  116. data/doc/rdoc/classes/RIO/Rio.src/M000111.html +3 -3
  117. data/doc/rdoc/classes/RIO/Rio.src/M000112.html +3 -3
  118. data/doc/rdoc/classes/RIO/Rio.src/M000113.html +3 -3
  119. data/doc/rdoc/classes/RIO/Rio.src/M000114.html +3 -3
  120. data/doc/rdoc/classes/RIO/Rio.src/M000115.html +3 -3
  121. data/doc/rdoc/classes/RIO/Rio.src/M000116.html +3 -3
  122. data/doc/rdoc/classes/RIO/Rio.src/M000117.html +3 -3
  123. data/doc/rdoc/classes/RIO/Rio.src/M000118.html +3 -3
  124. data/doc/rdoc/classes/RIO/Rio.src/M000119.html +3 -3
  125. data/doc/rdoc/classes/RIO/Rio.src/M000120.html +3 -3
  126. data/doc/rdoc/classes/RIO/Rio.src/M000121.html +3 -3
  127. data/doc/rdoc/classes/RIO/Rio.src/M000122.html +3 -3
  128. data/doc/rdoc/classes/RIO/Rio.src/M000123.html +3 -3
  129. data/doc/rdoc/classes/RIO/Rio.src/M000124.html +3 -3
  130. data/doc/rdoc/classes/RIO/Rio.src/M000125.html +3 -3
  131. data/doc/rdoc/classes/RIO/Rio.src/M000126.html +3 -3
  132. data/doc/rdoc/classes/RIO/Rio.src/M000127.html +3 -3
  133. data/doc/rdoc/classes/RIO/Rio.src/M000128.html +3 -3
  134. data/doc/rdoc/classes/RIO/Rio.src/M000129.html +3 -3
  135. data/doc/rdoc/classes/RIO/Rio.src/M000130.html +3 -3
  136. data/doc/rdoc/classes/RIO/Rio.src/M000131.html +3 -3
  137. data/doc/rdoc/classes/RIO/Rio.src/M000132.html +3 -3
  138. data/doc/rdoc/classes/RIO/Rio.src/M000133.html +3 -3
  139. data/doc/rdoc/classes/RIO/Rio.src/M000134.html +3 -3
  140. data/doc/rdoc/classes/RIO/Rio.src/M000135.html +3 -3
  141. data/doc/rdoc/classes/RIO/Rio.src/M000136.html +3 -3
  142. data/doc/rdoc/classes/RIO/Rio.src/M000137.html +3 -3
  143. data/doc/rdoc/classes/RIO/Rio.src/M000138.html +3 -3
  144. data/doc/rdoc/classes/RIO/Rio.src/M000139.html +3 -3
  145. data/doc/rdoc/classes/RIO/Rio.src/M000140.html +3 -3
  146. data/doc/rdoc/classes/RIO/Rio.src/M000141.html +3 -3
  147. data/doc/rdoc/classes/RIO/Rio.src/M000142.html +3 -3
  148. data/doc/rdoc/classes/RIO/Rio.src/M000143.html +3 -3
  149. data/doc/rdoc/classes/RIO/Rio.src/M000144.html +3 -3
  150. data/doc/rdoc/classes/RIO/Rio.src/M000145.html +3 -3
  151. data/doc/rdoc/classes/RIO/Rio.src/M000146.html +3 -3
  152. data/doc/rdoc/classes/RIO/Rio.src/M000147.html +3 -3
  153. data/doc/rdoc/classes/RIO/Rio.src/M000148.html +3 -3
  154. data/doc/rdoc/classes/RIO/Rio.src/M000149.html +3 -3
  155. data/doc/rdoc/classes/RIO/Rio.src/M000150.html +3 -3
  156. data/doc/rdoc/classes/RIO/Rio.src/M000151.html +3 -3
  157. data/doc/rdoc/classes/RIO/Rio.src/M000152.html +3 -3
  158. data/doc/rdoc/classes/RIO/Rio.src/M000153.html +3 -3
  159. data/doc/rdoc/classes/RIO/Rio.src/M000154.html +3 -3
  160. data/doc/rdoc/classes/RIO/Rio.src/M000155.html +3 -3
  161. data/doc/rdoc/classes/RIO/Rio.src/M000156.html +3 -3
  162. data/doc/rdoc/classes/RIO/Rio.src/M000157.html +3 -3
  163. data/doc/rdoc/classes/RIO/Rio.src/M000158.html +3 -3
  164. data/doc/rdoc/classes/RIO/Rio.src/M000159.html +3 -3
  165. data/doc/rdoc/classes/RIO/Rio.src/M000160.html +3 -3
  166. data/doc/rdoc/classes/RIO/Rio.src/M000161.html +3 -3
  167. data/doc/rdoc/classes/RIO/Rio.src/M000162.html +3 -3
  168. data/doc/rdoc/classes/RIO/Rio.src/M000163.html +3 -3
  169. data/doc/rdoc/classes/RIO/Rio.src/M000164.html +3 -3
  170. data/doc/rdoc/classes/RIO/Rio.src/M000165.html +3 -3
  171. data/doc/rdoc/classes/RIO/Rio.src/M000166.html +3 -3
  172. data/doc/rdoc/classes/RIO/Rio.src/M000167.html +3 -3
  173. data/doc/rdoc/classes/RIO/Rio.src/M000168.html +3 -3
  174. data/doc/rdoc/classes/RIO/Rio.src/M000169.html +3 -3
  175. data/doc/rdoc/classes/RIO/Rio.src/M000170.html +3 -3
  176. data/doc/rdoc/classes/RIO/Rio.src/M000171.html +3 -3
  177. data/doc/rdoc/classes/RIO/Rio.src/M000172.html +3 -3
  178. data/doc/rdoc/classes/RIO/Rio.src/M000173.html +3 -3
  179. data/doc/rdoc/classes/RIO/Rio.src/M000174.html +3 -3
  180. data/doc/rdoc/classes/RIO/Rio.src/M000175.html +3 -3
  181. data/doc/rdoc/classes/RIO/Rio.src/M000176.html +3 -3
  182. data/doc/rdoc/classes/RIO/Rio.src/M000177.html +3 -3
  183. data/doc/rdoc/classes/RIO/Rio.src/M000178.html +3 -3
  184. data/doc/rdoc/classes/RIO/Rio.src/M000179.html +3 -3
  185. data/doc/rdoc/classes/RIO/Rio.src/M000180.html +3 -3
  186. data/doc/rdoc/classes/RIO/Rio.src/M000181.html +3 -3
  187. data/doc/rdoc/created.rid +1 -1
  188. data/doc/rdoc/files/lib/rio/constructor_rb.html +1 -1
  189. data/doc/rdoc/files/lib/rio/doc/HOWTO_rb.html +1 -1
  190. data/doc/rdoc/files/lib/rio/doc/INTRO_rb.html +1 -1
  191. data/doc/rdoc/files/lib/rio/doc/SYNOPSIS_rb.html +1 -1
  192. data/doc/rdoc/files/lib/rio/if/basic_rb.html +1 -1
  193. data/doc/rdoc/files/lib/rio/if/path_rb.html +1 -1
  194. data/doc/rdoc/files/lib/rio_rb.html +1 -1
  195. data/doc/rdoc/fr_method_index.html +154 -155
  196. data/ex/findinruby +7 -3
  197. data/ex/findruby +6 -2
  198. data/lib/rio.rb +1 -1
  199. data/lib/rio/argv.rb +4 -0
  200. data/lib/rio/constructor.rb +17 -0
  201. data/lib/rio/context.rb +1 -1
  202. data/lib/rio/context/dir.rb +1 -0
  203. data/lib/rio/context/methods.rb +3 -3
  204. data/lib/rio/dir.rb +2 -2
  205. data/lib/rio/doc/HOWTO.rb +11 -6
  206. data/lib/rio/doc/INTRO.rb +149 -12
  207. data/lib/rio/doc/SYNOPSIS.rb +26 -13
  208. data/lib/rio/factory.rb +13 -2
  209. data/lib/rio/grande.rb +25 -0
  210. data/lib/rio/if/basic.rb +1 -1
  211. data/lib/rio/if/path.rb +61 -35
  212. data/lib/rio/matchrecord.rb +20 -1
  213. data/lib/rio/ops/dir.rb +2 -3
  214. data/lib/rio/ops/path.rb +25 -11
  215. data/lib/rio/ops/stream/input.rb +6 -3
  216. data/lib/rio/rl/base.rb +3 -2
  217. data/lib/rio/rl/ioi.rb +2 -1
  218. data/lib/rio/rl/path.rb +18 -3
  219. data/lib/rio/rl/uri.rb +8 -4
  220. data/lib/rio/scheme/cmdio.rb +1 -1
  221. data/lib/rio/scheme/path.rb +1 -0
  222. data/lib/rio/scheme/stdio.rb +1 -1
  223. data/lib/rio/scheme/strio.rb +1 -1
  224. data/lib/rio/scheme/sysio.rb +1 -1
  225. data/lib/rio/scheme/tcp.rb +1 -0
  226. data/lib/rio/scheme/temp.rb +184 -0
  227. data/lib/rio/state.rb +17 -6
  228. data/lib/rio/stream.rb +1 -1
  229. data/lib/rio/stream/open.rb +1 -1
  230. data/lib/rio/tempdir.rb +132 -0
  231. data/lib/rio/version.rb +1 -1
  232. data/test/tc/all.rb +4 -0
  233. data/test/tc/copylines.rb +38 -32
  234. data/test/tc/riorl.rb +104 -0
  235. data/test/tc/temp.rb +155 -0
  236. data/test/tc/tempdir.rb +63 -0
  237. data/test/tc/tempfile.rb +38 -0
  238. metadata +10 -5
  239. data/doc/rdoc/classes/RIO/Rio.src/M000182.html +0 -16
  240. data/lib/rio/scheme/tempfile.rb +0 -104
data/ex/findinruby CHANGED
@@ -1,16 +1,20 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rio'
4
+ require 'rio/argv'
4
5
 
5
6
  re = ARGV.shift
6
7
 
7
- require 'rio/argv'
8
- RIO::argv.each do |path|
9
- rio(path).norecurse('.svn','pkg').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) do |f|
8
+ is_ruby_exe = proc{ |f| f.executable? and f[0][0] =~ /^#!.+ruby/ }
9
+
10
+ RIO.ARGV.each do |rpath|
11
+ rpath.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) do |f|
10
12
  print f.lines[/#{re}/].map{ |line| "#{f}: #{line}" }
11
13
  end
14
+
12
15
  end
13
16
  __END__
17
+
14
18
  ARGV.each do |path|
15
19
  rio(path).norecurse('.svn','pkg').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) do |f|
16
20
  print f.lines[/#{re}/].map{ |line| "#{f}: #{line}" }
data/ex/findruby CHANGED
@@ -1,9 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rio'
4
+ require 'rio/argv'
4
5
 
5
- ARGV.each do |path|
6
- rio(path).norecurse('.svn').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) do |f|
6
+ #is_ruby_exe = proc{ |f| f.executable? and f[0][0] =~ /^#!.+ruby/ }
7
+ is_ruby_exe = proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ }
8
+
9
+ RIO.ARGV.each do |rpath|
10
+ rpath.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) do |f|
7
11
  puts f
8
12
  end
9
13
  end
data/lib/rio.rb CHANGED
@@ -44,7 +44,7 @@ require 'extensions/symbol'
44
44
  require 'extensions/enumerable'
45
45
  require 'extensions/string'
46
46
  require 'forwardable'
47
-
47
+ $trace_states = false
48
48
  module RIO
49
49
  # See also: RIO::Doc::SYNOPSIS; RIO::Doc::INTRO; RIO::Doc::HOWTO.
50
50
  class Rio < Base #:doc:
data/lib/rio/argv.rb CHANGED
@@ -43,6 +43,10 @@ module RIO
43
43
  ::ARGV.map { |path| rio(path) }
44
44
  end
45
45
  module_function :argv
46
+ def ARGV()
47
+ ::ARGV.map { |path| rio(path) }
48
+ end
49
+ module_function :ARGV
46
50
  end
47
51
 
48
52
  if $0 == __FILE__
@@ -135,6 +135,23 @@ module RIO
135
135
  # rio(??)
136
136
  # rio(??,basename='rio',tmpdir=Dir::tmpdir)
137
137
  #
138
+ # To create a temporary object that will become a file
139
+ # or a directory, depending on how you use it:
140
+ # rio(??)
141
+ # rio(??,basename='rio',tmpdir=Dir::tmpdir)
142
+ #
143
+ # To force it to become a file
144
+ # rio(??).file
145
+ # or just write to it.
146
+ #
147
+ # To force it to become a directory:
148
+ # rio(??).dir
149
+ # or
150
+ # rio(??).mkdir
151
+ # or
152
+ # rio(??).chdir
153
+ #
154
+ #
138
155
  # ===== Creating a Rio that refers to an arbitrary TCPSocket
139
156
  #
140
157
  # rio('tcp:',hostname,port)
data/lib/rio/context.rb CHANGED
@@ -90,7 +90,7 @@ module RIO
90
90
  p = {}
91
91
  ncx = Vars.new(q,p)
92
92
  keys.each { |key|
93
- ncx.set_(key,@values[key])
93
+ ncx.set_(key,@values[key]) if @values.has_key?(key)
94
94
  }
95
95
  ncx
96
96
  end
@@ -42,6 +42,7 @@ require 'rio/entrysel'
42
42
  module RIO
43
43
  module Cx
44
44
  module Methods
45
+ def dir_iter?() cx.has_key?('sel') || cx.has_key?('nosel') end
45
46
 
46
47
  private
47
48
 
@@ -85,13 +85,13 @@ module RIO
85
85
 
86
86
  module Cx
87
87
  module Methods
88
- def noclose(arg=false,&block)
88
+ def noautoclose(arg=false,&block)
89
89
  closeoncopy(arg).closeoneof(arg,&block)
90
90
  end
91
- def noclose_(arg=false)
91
+ def noautoclose_(arg=false)
92
92
  closeoncopy_(arg).closeoneof_(arg)
93
93
  end
94
- protected :noclose_
94
+ protected :noautoclose_
95
95
  end
96
96
  end
97
97
 
data/lib/rio/dir.rb CHANGED
@@ -70,9 +70,9 @@ module RIO
70
70
  def open(m=nil,*args)
71
71
  open_(*args)
72
72
  end
73
- def open_()
73
+ def open_(*args)
74
74
  unless open?
75
- ios = self.rl.open()
75
+ ios = self.rl.open(*args)
76
76
  self.ioh = IOH::Dir.new(ios)
77
77
  # self.ioh = self.rl.open()
78
78
  end
data/lib/rio/doc/HOWTO.rb CHANGED
@@ -103,7 +103,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
103
103
 
104
104
  * Read all lines starting with 'require' into an array, with each line chomped
105
105
  # method 1
106
- array = ario.chomp.lines(/^\s*require/)
106
+ array = ario.chomp.lines[/^\s*require/]
107
107
  # method 2
108
108
  ario.chomp.lines(/^\s*require/) > array
109
109
 
@@ -173,7 +173,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
173
173
  # method 2
174
174
  ario.print(string)
175
175
  # method 3
176
- ario.noclose < string
176
+ ario.noautoclose < string
177
177
 
178
178
  * Write a string to a file and close the file
179
179
  # method 1
@@ -189,7 +189,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
189
189
  # method 2
190
190
  ario.a.print(string)
191
191
  # method 3
192
- ario.noclose << string
192
+ ario.noautoclose << string
193
193
 
194
194
  * Append a string to a file and close the file
195
195
  # method 1
@@ -204,7 +204,7 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
204
204
  ario = rio('afile').nocloseoncopy
205
205
  ario << array
206
206
  # method 2
207
- ario.noclose < array
207
+ ario.noautoclose < array
208
208
 
209
209
  * Write an array to a file and close the file
210
210
  # method 1
@@ -302,9 +302,14 @@ IO, File, Dir, Pathname, FileUtils, Tempfile, StringIO, OpenURI, Zlib, and CSV.
302
302
  # method 5
303
303
  array = ario.norecurse('.svn')['*.txt']
304
304
 
305
- * Iterate through all ruby files in a directory structure except those in the '.svn' and 'pkg' directories
305
+ * Iterate through ruby files in a directory and subdirectories skipping
306
+ those in the '.svn', and 'pkg' directories
306
307
  # method 1
307
- ario.norecurse('.svn','pkg').files('*.rb',proc{ |f| f.executable? and f[0] =~ /^#!.+ruby/ }) { |f| ... }
308
+ is_ruby_exe = proc{ |f| f.executable? and f[0][0] =~ /^#!.+ruby/ }
309
+ ario.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) { |f| ... }
310
+ # method 2
311
+ is_ruby_exe = proc{ |f| f.executable? and f.gets =~ /^#!.+ruby/ }
312
+ ario.norecurse('.svn','pkg').files('*.rb',is_ruby_exe) { |f| ... }
308
313
 
309
314
  * Put all files excluding those that are symlinks to files in an array
310
315
  # method 1
data/lib/rio/doc/INTRO.rb CHANGED
@@ -67,7 +67,7 @@ as an implied +each+.
67
67
  == Using a Rio
68
68
 
69
69
  Using a Rio can be described as having 3 steps:
70
- * Creating a Rio (using the constructor or as the result of one of path manipulation methods)
70
+ * Creating a Rio (using the constructor or as the result of one of the path manipulation methods)
71
71
  * Configuring a Rio
72
72
  * Rio I/O
73
73
 
@@ -139,8 +139,8 @@ character.
139
139
  <tt>rio(?-)</tt> (mnemonic: '-' is used by some Unix programs to specify stdin or stdout in place of a file)
140
140
 
141
141
  Just as a Rio that refers to a file, does not know whether that file will be opened for reading or
142
- writing until an io operation is specified, a +stdio:+ Rio does not know whether it will connect
143
- to stdin or stdout until an io operation is specified.
142
+ writing until an io operation is specified, a <tt>stdio:</tt> Rio does not know whether it will connect
143
+ to stdin or stdout until an I/O operation is specified.
144
144
 
145
145
  ===== Creating a Rio that refers to a clone of your programs stderr.
146
146
 
@@ -167,12 +167,28 @@ to stdin or stdout until an io operation is specified.
167
167
  astring = ""
168
168
  rio(?","")
169
169
 
170
- ===== Creating a Rio that refers to a Tempfile object
170
+ ===== Creating a Rio that refers to a Temporary object
171
171
 
172
172
  <tt>rio(??)</tt> (mnemonic: '?' you don't know its name)
173
+
174
+ To create a temporary object that will become a file
175
+ or a directory, depending on how you use it:
173
176
  rio(??)
174
177
  rio(??,basename='rio',tmpdir=Dir::tmpdir)
175
178
 
179
+ To force it to become a file
180
+ rio(??).file
181
+ or just write to it.
182
+
183
+ To force it to become a directory:
184
+ rio(??).dir
185
+ or
186
+ rio(??).mkdir
187
+ or
188
+ rio(??).chdir
189
+
190
+
191
+
176
192
  ===== Creating a Rio that refers to an arbitrary TCPSocket
177
193
 
178
194
  rio('tcp:',hostname,port)
@@ -196,10 +212,10 @@ the return values converted to a Rio.
196
212
 
197
213
  ==== Creating a Rio from a Rio's component parts.
198
214
 
199
- The Rio methods for creating a Rio from a Rio's component parts are Rio#dirname,
200
- Rio#filename, Rio#basename,
201
- and Rio#extname.
202
- The behavior of Rio#basename depends on the setting of the +ext+ configuration variable
215
+ The Rio methods for creating a Rio from a Rio's component parts are
216
+ Rio#dirname, Rio#filename, Rio#basename, and Rio#extname.
217
+ The behavior of Rio#basename depends on the setting of the +ext+
218
+ configuration variable
203
219
  and is different from its counterpart in the File class. The default value of the +ext+ configuration variable
204
220
  is the string returned File#extname. The +ext+ configuration variable can be changed using Rio#ext and Rio#noext
205
221
  and can be queried using Rio#ext?. This value is used by calls to Rio#basename.
@@ -562,10 +578,131 @@ symlinks to non-existant object even though the symlink itself exists).
562
578
  The deleting methods' purpose is to make things not exist, so
563
579
  calling one of them on something that already does not exist is considered a success.
564
580
 
565
- To create a clean copy of a directory whether or not anything with that name exists you might do this
566
- rio('adir').delete!.mkpath.chdir do
567
- # do something in adir
568
- end
581
+ To create a clean copy of a directory whether or not anything with that name exists one might do this
582
+ rio('adir').delete!.mkpath.chdir do
583
+ # do something in adir
584
+ end
585
+
586
+ ---
587
+
588
+ == Miscellany
589
+
590
+
591
+ ==== Using Symbolic Links
592
+
593
+ To create a symbolic link (symlink) to the file-system entry refered to by a Rio, use Rio#symlink.
594
+ Rio#symlink differs from File#symlink in that it calculates the path from the symlink location to
595
+ the Rio's position. So:
596
+
597
+ File#symlink('adir/afile','adir/alink')
598
+
599
+ creates a symlink in the directory 'adir' named 'alink' which references 'adir/afile'. From the
600
+ perspective of 'alink', 'adir/afile' does not exist. While:
601
+
602
+ rio('adir/afile').symlink('adir/alink')
603
+
604
+ creates a symlink in the directory 'adir' named 'alink' which references 'afile'. This is the route
605
+ to 'adir/afile' from the perspective of 'adir/alink'.
606
+
607
+ Note that the return value from +symlink+ is the calling Rio and not a Rio refering to the symlink.
608
+ This is done for consistency with the rest of Rio.
609
+
610
+ Rio#symlink? can be used to test if a file-system object is a symlink. A Rio is extended with
611
+ Rio#readlink, and Rio#lstat only if Rio#symlink? returns true. So for non-symlinks, these
612
+ will raise a NoMethodError. These are both passed to their counterparts in File. Rio#readlink
613
+ returns a Rio refering to the result of File#readlink.
614
+
615
+ ==== Using A Rio as an IO (or File or Dir)
616
+
617
+ Rio supports so much of IO's interface that one might be tempted to pass it to a method that
618
+ expects an IO. While Rio is not and is not intended to be a stand in for IO, this can work.
619
+ It requires knowledge of every IO method that will be called, under any circumstances.
620
+
621
+ Even in cases where Rio supports the required IO interface, A Rio feature that seems to
622
+ cause the most incompatibility, is its automatic closing of files. To turn off all of Rio's
623
+ automatic closing use Rio#noautoclose.
624
+
625
+ For example:
626
+ require 'yaml'
627
+ yrio = rio('ran.yaml').delete!.noautoclose
628
+ YAML.dump( ['badger', 'elephant', 'tiger'], yrio )
629
+ obj = YAML::load( yrio ) #=> ["badger", "tiger", "elephant"]
630
+
631
+ ==== Automatic Closing of Files
632
+
633
+ Rio closes files automatically in three instances.
634
+
635
+ When reading from an IO it is closed when the end of file is reached. While
636
+ this is a reasonable thing to do in many cases, sometimes this is not desired.
637
+ To turn Rio's automatic closing on end of file use Rio#nocloseoneof (it can
638
+ be turned back on via Rio#closeoneof)
639
+
640
+ ario = rio('afile').nocloseoneof
641
+ lines = ario[]
642
+ ario.closed? #=> false
643
+
644
+ Closing on end-of-file is necessary for many of Rio's "one-liners", but has an
645
+ implication that may be surprising at first. A Rio starts life as a path, not
646
+ much more than a string. When one of its read methods is called it becomes an
647
+ input stream. When the stream is closed, it becomes a path again. This means
648
+ that when reading from a Rio, the end-of-file condition is seen only once before it
649
+ becomes a path again, and will be reopened if another read operation is attempted.
650
+
651
+ Another time a Rio will be closed atomatically is when writing to it with one
652
+ of the copy operators (<tt><, <<, >, >></tt>).
653
+ This behavior can be turned off with Rio#nocloseoncopy.
654
+
655
+ To turn off both of thes types of automatic closing use Rio#noautoclose.
656
+
657
+ The third instance when Rio will close a file automatically is when a file opened
658
+ for one type of access receives a method which that access mode does not support.
659
+ So, the code
660
+ rio('afile').puts("Hello World").gets
661
+ will open the file for write access when the +puts+ method is received. When +gets+ is
662
+ called the file is closed and reopened with read access.
663
+
664
+ ==== Explicit Closing of Files
665
+
666
+ Rio can not determine when the client is finished writing to it, as it does
667
+ using +eof+ on read. It is the author's understanding that Ruby does not support
668
+ a mechanism to have code run when there are no more references to it -- that finalizers
669
+ are not necessarily run immediatly upon an object's reference count reaching 0.
670
+ If this understanding is incorrect, some of Rio's extranious ways of closing a file
671
+ may be rethought.
672
+
673
+ That being said, Rio support several ways to explicitly close a file. Rio#close will close
674
+ any open Rio. The output methods Rio#puts!, Rio#putc!, Rio#printf!, Rio#print!, and Rio#write!
675
+ behave as if their counterparts without the exclamation point had been called and
676
+ then call Rio#close or Rio#close_write if the underlying IO object is opened for duplex access.
677
+
678
+
679
+ ==== Open mode selection
680
+
681
+ A Rio is typically not explicitly opened. It opens a file automatically when an
682
+ input or output methed is called. For output methods Rio opens a file with mode 'w',
683
+ and otherwise opens a file with mode 'r'. This behavior can be modified using the
684
+ tersely named methods Rio#a, Rio#a!, Rio#r, Rio#r!, Rio#w, and Rio#w!, which cause
685
+ the Rio to use modes 'a','a+','r','r+','w',and 'w+' respectively.
686
+
687
+ One way to append a string to a file and close it in one line is
688
+ rio('afile').a.puts!("Hello World")
689
+
690
+ Run a cmd that must be opened for read and write
691
+ ans = rio(?-,'cat').w!.puts!("Hello Kitty").readlines
692
+
693
+ The automatic selection of mode can be bypassed entirely using Rio#mode and Rio#open.
694
+
695
+ If a mode is specified using +mode+, the file will still be opened automatically, but
696
+ the mode specified in the +mode+ method will be used regardless of whether it makes sense.
697
+
698
+ A Rio can also be opened explicitly using Rio#open. +open+ takes one parameter, a mode.
699
+ This also will override all of Rio's automatic mode selection.
700
+
701
+
702
+
703
+
704
+ ---
705
+
569
706
 
570
707
  See also:
571
708
  * RIO::Doc::SYNOPSIS
@@ -63,6 +63,9 @@ For the following assume:
63
63
  Copy a file into a string
64
64
  rio('afile') > astring
65
65
 
66
+ Copy a string into a file
67
+ rio('afile') < astring
68
+
66
69
  Copy the chomped lines of a file into an array
67
70
  rio('afile').chomp > anarray
68
71
 
@@ -78,18 +81,18 @@ Copy an entire directory structure into another directory
78
81
  Copy a web page into a file
79
82
  rio('http://rubydoc.org/') > rio('afile')
80
83
 
81
- Copy a file from a ftp server into a file
84
+ Copy a file from a ftp server into a local file
82
85
  rio('ftp://host/afile.gz') > rio('afile.gz')
83
86
 
84
87
  Copy a gzipped file un-gzipping it
85
88
  rio('afile.gz').gzip > rio('afile')
86
89
 
87
- Copy a file from a ftp server into a local file un-gzipping it
88
- rio('ftp://host/afile.gz').gzip > rio('afile')
89
-
90
90
  Copy a plain file, gzipping it
91
91
  rio('afile.gz').gzip < rio('afile')
92
92
 
93
+ Copy a file from a ftp server into a local file un-gzipping it
94
+ rio('ftp://host/afile.gz').gzip > rio('afile')
95
+
93
96
  Iterate over the entries in a directory
94
97
  rio('adir').entries { |entrio| ... }
95
98
 
@@ -99,6 +102,15 @@ Iterate over only the files in a directory
99
102
  Iterate over only the .rb files in a directory
100
103
  rio('adir').files('*.rb') { |entrio| ... }
101
104
 
105
+ Iterate over only the directories in a directory
106
+ rio('adir').dirs { |entrio| ... }
107
+
108
+ Iterate over only the _dot_ files in a directory
109
+ rio('adir').dirs(/^\./) { |entrio| ... }
110
+
111
+ Iterate over the files in a directory and its subdirectories, skipping '.svn' and 'CVS' directories
112
+ rio('adir').norecurse(/^\.svn$/,'CVS').files { |entrio| ... }
113
+
102
114
  Create an array of the .rb entries in a directory
103
115
  anarray = rio('adir')['*.rb']
104
116
 
@@ -111,8 +123,7 @@ Create an array of the .rb entries in a directory and its subdirectories
111
123
  Create an array of the .rb files in a directory and its subdirectories
112
124
  anarray = rio('adir').all.files['*.rb']
113
125
 
114
- Copy an entire directory structure but only the .rb files from a directory and its subdirectories
115
- into another directory
126
+ Copy an entire directory structure and the .rb files within it
116
127
  rio('adir').dirs.files('*.rb') > rio('another_directory')
117
128
 
118
129
  Iterate over the chomped lines of a file
@@ -133,14 +144,17 @@ Copy the first 10 lines of a file into another file
133
144
  Copy the first 10 lines of a file to stdout
134
145
  rio('afile').lines(0..9) > rio(?-)
135
146
 
136
- Copy the first 10 lines of a gzipped file to stdout
137
- rio('afile.gz').gzip.lines(0..9) > rio(?-)
138
-
139
147
  Copy the first 10 lines of a gzipped file on an ftp server to stdout
140
148
  rio('ftp://host/afile.gz').gzip.lines(0..9) > rio(?-)
141
149
 
142
150
  Put the first 100 chomped lines of a gzipped file into an array
143
- anarray = rio('afile.gz').gzip[0...100]
151
+ anarray = rio('afile.gz').chomp.gzip[0...100]
152
+
153
+ Put chomped lines that start with 'Rio' into an array
154
+ anarray = rio('afile').chomp[/^Rio/]
155
+
156
+ Iterate over the non-empty, non-comment chomped lines of a file
157
+ rio('afile').chomp.nolines(:empty?,/^\s*#/) { |line| ... }
144
158
 
145
159
  Copy the output of th ps command into an array, skipping the header line and the ps command entry
146
160
  rio(?-,'ps -a').nolines(0,/ps$/) > anarray
@@ -148,14 +162,13 @@ Copy the output of th ps command into an array, skipping the header line and the
148
162
  Prompt for input and return what was typed
149
163
  ans = rio(?-).print("Type Something: ").chomp.gets
150
164
 
151
- Change the extension of all files with the extension '.htm' in a directory and its
152
- subdirectories to have the extension '.html'
165
+ Change the extension of all .htm files in a directory and its subdirectories to .html
153
166
  rio('adir').rename.all.files('*.htm') do |htmfile|
154
167
  htmfile.extname = '.html'
155
168
  end
156
169
 
157
170
  Create a symbolic link 'asymlink' in 'adir' which refers to 'adir/afile'
158
- rio('adir/afile').symlinke('adir/asymlink')
171
+ rio('adir/afile').symlink('adir/asymlink')
159
172
 
160
173
  === SUGGESTED READING
161
174