rio 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +1 -1
  3. data/README +1 -1
  4. data/lib/rio.rb +5 -4
  5. data/lib/rio/abstract_method.rb +1 -1
  6. data/lib/rio/alturi.rb +10 -69
  7. data/lib/rio/alturi/algorithm.rb +1 -18
  8. data/lib/rio/alturi/escape.rb +0 -4
  9. data/lib/rio/alturi/parse.rb +0 -29
  10. data/lib/rio/alturi/path_parts.rb +0 -2
  11. data/lib/rio/alturi/uri_parts.rb +3 -32
  12. data/lib/rio/argv.rb +1 -1
  13. data/lib/rio/arraynge.rb +1 -3
  14. data/lib/rio/arycopy.rb +1 -1
  15. data/lib/rio/assert.rb +31 -47
  16. data/lib/rio/base.rb +1 -1
  17. data/lib/rio/callstr.rb +1 -1
  18. data/lib/rio/const.rb +1 -1
  19. data/lib/rio/construct.rb +1 -1
  20. data/lib/rio/constructor.rb +1 -1
  21. data/lib/rio/context.rb +8 -4
  22. data/lib/rio/context/autoclose.rb +1 -1
  23. data/lib/rio/context/binmode.rb +1 -7
  24. data/lib/rio/context/copying.rb +1 -1
  25. data/lib/rio/context/cxx.rb +1 -1
  26. data/lib/rio/context/dir.rb +1 -1
  27. data/lib/rio/context/encoding.rb +1 -2
  28. data/lib/rio/context/gzip.rb +1 -1
  29. data/lib/rio/context/methods.rb +1 -6
  30. data/lib/rio/context/skip.rb +1 -1
  31. data/lib/rio/context/stream.rb +1 -8
  32. data/lib/rio/cp.rb +1 -1
  33. data/lib/rio/cxuri.rb +11 -7
  34. data/lib/rio/dbg/trace_states.rb +0 -2
  35. data/lib/rio/def.rb +1 -1
  36. data/lib/rio/dir.rb +2 -2
  37. data/lib/rio/doc.rb +1 -1
  38. data/lib/rio/entrysel.rb +6 -6
  39. data/lib/rio/exception.rb +1 -1
  40. data/lib/rio/exception/copy.rb +1 -1
  41. data/lib/rio/exception/notimplemented.rb +1 -1
  42. data/lib/rio/exception/notsupported.rb +1 -1
  43. data/lib/rio/exception/open.rb +1 -12
  44. data/lib/rio/exception/state.rb +1 -1
  45. data/lib/rio/ext.rb +1 -8
  46. data/lib/rio/ext/csv.rb +1 -25
  47. data/lib/rio/ext/csv/csv-legacy.rb +1 -49
  48. data/lib/rio/ext/csv/csv.rb +1 -24
  49. data/lib/rio/ext/csv/filter.rb +1 -19
  50. data/lib/rio/ext/if.rb +1 -1
  51. data/lib/rio/ext/mp3info.rb +6 -5
  52. data/lib/rio/ext/splitlines.rb +1 -23
  53. data/lib/rio/ext/yaml.rb +1 -16
  54. data/lib/rio/ext/yaml/doc.rb +1 -6
  55. data/lib/rio/ext/yaml/tie.rb +4 -7
  56. data/lib/rio/ext/zipfile.rb +1 -56
  57. data/lib/rio/ext/zipfile/fs.rb +1 -30
  58. data/lib/rio/ext/zipfile/rl.rb +1 -128
  59. data/lib/rio/ext/zipfile/rootdir.rb +1 -30
  60. data/lib/rio/ext/zipfile/state.rb +1 -105
  61. data/lib/rio/ext/zipfile/wrap.rb +1 -86
  62. data/lib/rio/factory.rb +2 -100
  63. data/lib/rio/fibpipe.rb +0 -98
  64. data/lib/rio/file.rb +1 -12
  65. data/lib/rio/filter.rb +1 -1
  66. data/lib/rio/filter/closeoneof.rb +1 -10
  67. data/lib/rio/filter/gzip.rb +1 -16
  68. data/lib/rio/fs.rb +75 -92
  69. data/lib/rio/fs/base.rb +1 -1
  70. data/lib/rio/fs/impl.rb +1 -1
  71. data/lib/rio/fs/native.rb +1 -1
  72. data/lib/rio/fs/stream.rb +1 -1
  73. data/lib/rio/fs/url.rb +1 -1
  74. data/lib/rio/ftp/conncache.rb +1 -15
  75. data/lib/rio/ftp/dir.rb +1 -2
  76. data/lib/rio/ftp/fs.rb +1 -13
  77. data/lib/rio/fwd.rb +31 -8
  78. data/lib/rio/grande.rb +2 -4
  79. data/lib/rio/handle.rb +1 -1
  80. data/lib/rio/if.rb +1 -7
  81. data/lib/rio/if/basic.rb +1 -5
  82. data/lib/rio/if/csv.rb +1 -1
  83. data/lib/rio/if/dir.rb +1 -1
  84. data/lib/rio/if/file.rb +1 -1
  85. data/lib/rio/if/fileordir.rb +1 -1
  86. data/lib/rio/if/grande.rb +1 -1
  87. data/lib/rio/if/grande_entry.rb +1 -1
  88. data/lib/rio/if/grande_stream.rb +1 -1
  89. data/lib/rio/if/internal.rb +1 -1
  90. data/lib/rio/if/path.rb +1 -1
  91. data/lib/rio/if/rubyio.rb +1 -1
  92. data/lib/rio/if/string.rb +1 -1
  93. data/lib/rio/if/temp.rb +1 -1
  94. data/lib/rio/if/test.rb +1 -1
  95. data/lib/rio/if/yaml.rb +1 -1
  96. data/lib/rio/ioh.rb +42 -24
  97. data/lib/rio/iomode.rb +3 -3
  98. data/lib/rio/ios/fail.rb +1 -1
  99. data/lib/rio/ios/generic.rb +1 -1
  100. data/lib/rio/ios/mode.rb +1 -1
  101. data/lib/rio/ios/null.rb +1 -13
  102. data/lib/rio/iowrap.rb +1 -14
  103. data/lib/rio/kernel.rb +1 -2
  104. data/lib/rio/local.rb +1 -13
  105. data/lib/rio/match.rb +1 -2
  106. data/lib/rio/matchrecord.rb +5 -34
  107. data/lib/rio/no_warn.rb +1 -1
  108. data/lib/rio/nullio.rb +1 -1
  109. data/lib/rio/open3.rb +1 -10
  110. data/lib/rio/ops.rb +1 -1
  111. data/lib/rio/ops/construct.rb +1 -1
  112. data/lib/rio/ops/create.rb +1 -3
  113. data/lib/rio/ops/dir.rb +4 -46
  114. data/lib/rio/ops/either.rb +1 -3
  115. data/lib/rio/ops/file.rb +1 -25
  116. data/lib/rio/ops/path.rb +1 -18
  117. data/lib/rio/ops/stream.rb +4 -5
  118. data/lib/rio/ops/stream/input.rb +1 -10
  119. data/lib/rio/ops/stream/output.rb +1 -3
  120. data/lib/rio/ops/stream/read.rb +1 -1
  121. data/lib/rio/ops/stream/write.rb +1 -1
  122. data/lib/rio/ops/symlink.rb +1 -10
  123. data/lib/rio/path.rb +1 -4
  124. data/lib/rio/path/reset.rb +1 -6
  125. data/lib/rio/piper.rb +1 -4
  126. data/lib/rio/piper/cp.rb +1 -16
  127. data/lib/rio/prompt.rb +1 -1
  128. data/lib/rio/rectype.rb +1 -4
  129. data/lib/rio/rl/base.rb +1 -14
  130. data/lib/rio/rl/builder.rb +1 -12
  131. data/lib/rio/rl/chmap.rb +1 -11
  132. data/lib/rio/rl/fs2url.rb +1 -8
  133. data/lib/rio/rl/ioi.rb +1 -2
  134. data/lib/rio/rl/path.rb +1 -20
  135. data/lib/rio/rl/pathmethods.rb +1 -3
  136. data/lib/rio/rl/uri.rb +1 -11
  137. data/lib/rio/rl/withpath.rb +2 -30
  138. data/lib/rio/rrl/base.rb +1 -6
  139. data/lib/rio/rrl/builder.rb +2 -8
  140. data/lib/rio/rrl/chmap.rb +1 -11
  141. data/lib/rio/rrl/ioi.rb +1 -3
  142. data/lib/rio/rrl/path.rb +1 -11
  143. data/lib/rio/rrl/withpath.rb +8 -48
  144. data/lib/rio/scheme/aryio.rb +1 -1
  145. data/lib/rio/scheme/cmdio.rb +3 -15
  146. data/lib/rio/scheme/cmdpipe.rb +1 -5
  147. data/lib/rio/scheme/fd.rb +1 -1
  148. data/lib/rio/scheme/ftp.rb +1 -40
  149. data/lib/rio/scheme/http.rb +10 -7
  150. data/lib/rio/scheme/null.rb +1 -1
  151. data/lib/rio/scheme/path.rb +1 -63
  152. data/lib/rio/scheme/stderr.rb +1 -2
  153. data/lib/rio/scheme/stdio.rb +3 -3
  154. data/lib/rio/scheme/strio.rb +1 -3
  155. data/lib/rio/scheme/sysio.rb +1 -1
  156. data/lib/rio/scheme/tcp.rb +1 -2
  157. data/lib/rio/scheme/temp.rb +9 -38
  158. data/lib/rio/state.rb +4 -38
  159. data/lib/rio/state/data.rb +4 -5
  160. data/lib/rio/state/error.rb +2 -6
  161. data/lib/rio/stream.rb +1 -31
  162. data/lib/rio/stream/base.rb +1 -5
  163. data/lib/rio/stream/duplex.rb +1 -16
  164. data/lib/rio/stream/open.rb +1 -11
  165. data/lib/rio/symantics.rb +1 -1
  166. data/lib/rio/tempdir.rb +0 -2
  167. data/lib/rio/to_rio.rb +1 -1
  168. data/lib/rio/to_rio/all.rb +1 -1
  169. data/lib/rio/to_rio/array.rb +1 -1
  170. data/lib/rio/to_rio/io.rb +1 -1
  171. data/lib/rio/to_rio/object.rb +1 -1
  172. data/lib/rio/to_rio/string.rb +1 -1
  173. data/lib/rio/undef_rake_dsl.rb +3 -0
  174. data/lib/rio/uri/file.rb +1 -18
  175. data/lib/rio/uriref.rb +1 -18
  176. data/lib/rio/util.rb +1 -1
  177. data/lib/rio/version.rb +2 -2
  178. data/misc/update-copyright.rb +2 -2
  179. data/rio.gemspec +2 -3
  180. data/test/env.sh +1 -2
  181. data/test/http/tc/copy_from_http.rb +0 -1
  182. data/test/runhttp.rb +2 -1
  183. data/test/runtests.rb +7 -5
  184. data/test/tc/copyarray.rb +4 -4
  185. data/test/tc/copydir.rb +1 -1
  186. metadata +15 -47
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -24,16 +24,17 @@
24
24
 
25
25
 
26
26
  require 'mp3info'
27
- require 'forwardable'
27
+
28
28
  module RIO
29
29
  module Ext
30
30
  module Mp3Info
31
31
  def mp3info() ::Mp3Info.new(self.fspath) end
32
32
 
33
- extend Forwardable
33
+ extend RIO::Fwd
34
+
35
+ fwd_readers :mp3info,:tag,:bitrate,:samplerate
36
+ fwd_readers :tag,:tracknum
34
37
 
35
- def_instance_delegators(:mp3info,:tag,:bitrate,:samplerate)
36
- def_instance_delegators(:tag,:tracknum)
37
38
  def title() _chop0(tag.title) end
38
39
  def album() _chop0(tag.album) end
39
40
  def artist() _chop0(tag.artist) end
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -22,26 +22,6 @@
22
22
  #++
23
23
  #
24
24
 
25
-
26
- # begin
27
- # require 'faster_csv' # first choice--for speed
28
-
29
- # # A CSV compatible interface for FasterCSV.
30
- # module CSV # :nodoc:
31
- # def self.parse_line( line, field_sep=nil, row_sep=nil )
32
- # FasterCSV.parse_line( line, :col_sep => field_sep || ",",
33
- # :row_sep => row_sep || :auto )
34
- # end
35
-
36
- # def self.generate_line( array, field_sep=nil, row_sep=nil )
37
- # FasterCSV.generate_line( array, :col_sep => field_sep || ",",
38
- # :row_sep => row_sep || "" )
39
- # end
40
- # end
41
- # rescue LoadError
42
- # require 'csv' # second choice--slower but standard
43
- # end
44
-
45
25
  module RIO
46
26
  module Ext
47
27
  module SplitLines
@@ -87,8 +67,6 @@ module RIO
87
67
  protected
88
68
 
89
69
  def to_rec_(raw_rec)
90
- #_init_cols_from_line(raw_rec) if @recno == 0
91
- #p "#{callstr('to_rec_',raw_rec.inspect,@recno)} ; itertype=#{cx['stream_itertype']}"
92
70
  case cx['stream_itertype']
93
71
  when 'lines'
94
72
  raw_rec
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -22,7 +22,6 @@
22
22
  #++
23
23
  #
24
24
 
25
-
26
25
  require 'yaml'
27
26
 
28
27
  module RIO
@@ -33,7 +32,6 @@ module RIO
33
32
  cxx('yaml',true,&block)
34
33
  end
35
34
  def yamldoc(&block)
36
- #@yamldoc = YAML::Tie::Doc.new(self.fspath).open
37
35
  become('Ext::YAML::Doc::Existing')
38
36
  end
39
37
  def yaml?() cxx?('yaml') end
@@ -111,25 +109,12 @@ module RIO
111
109
  protected
112
110
 
113
111
  def cpfrom_(arg)
114
- #p "yaml#cpfrom_(#{arg})"
115
112
  case arg
116
- #when ::Array then cpfrom_array_(arg)
117
113
  when Rio,::IO,::StringIO then super
118
114
  else self.put_(arg)
119
115
  end
120
116
  self
121
117
  end
122
- # def cpfrom_array_(array)
123
- # array.each { |el|
124
- # self.put_(el)
125
- # }
126
- # self
127
- # end
128
- # def cpfrom_rio_(ario)
129
- # p "yaml#cpfrom_rio_(#{ario})"
130
- # ioh.puts(::YAML.dump_stream(*ario[]))
131
- # self
132
- # end
133
118
  def put_(obj)
134
119
  #p callstr('put_',obj)
135
120
  ioh.puts(obj.to_yaml)
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -68,11 +68,6 @@ module RIO
68
68
  end
69
69
 
70
70
  def ystream()
71
- #cl = 'Dir::Stream'
72
- #p "LOOP: retry: #{cx['retrystate'].inspect} => #{cl}"
73
- #return nil if cx['retrystate'] == cl
74
- #cx['retrystate'] = cl
75
-
76
71
  become('Ext::YAML::Doc::Stream')
77
72
  end
78
73
  end
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -22,9 +22,7 @@
22
22
  #++
23
23
  #
24
24
 
25
-
26
25
  require 'yaml'
27
- require 'forwardable'
28
26
  require 'delegate'
29
27
 
30
28
  module RIO
@@ -32,7 +30,6 @@ module RIO
32
30
  module YAML #:nodoc: all
33
31
  module Tie
34
32
  class Doc
35
- extend Forwardable
36
33
  def initialize(fn)
37
34
  @filename = fn
38
35
  @io = nil
@@ -55,7 +52,8 @@ module RIO
55
52
  end
56
53
  end
57
54
 
58
- def_instance_delegators(:@root,:inspect)
55
+ fwd_readers :@root, :inspect
56
+
59
57
  def method_missing(sym,*args)
60
58
  @root.__send__(sym,*args)
61
59
  end
@@ -78,7 +76,6 @@ module RIO
78
76
  end
79
77
  end
80
78
  class Root < Base
81
- extend Forwardable
82
79
  attr_accessor :dirty
83
80
  def initialize(doc)
84
81
  @doc = doc
@@ -91,7 +88,7 @@ module RIO
91
88
  def dirty?()
92
89
  @dirty
93
90
  end
94
- def_instance_delegators(:@root,:inspect)
91
+ fwd_readers :@root,:inspect
95
92
  def method_missing(sym,*args)
96
93
  @root.__send__(sym,*args)
97
94
  end
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -42,58 +42,3 @@ module RIO
42
42
  end
43
43
  end
44
44
  __END__
45
- module RIO
46
- module_function
47
- def load_lib(lib)
48
- begin
49
- require lib
50
- rescue LoadError => ex
51
- begin
52
- p "using Gem for #{lib}" if $DEBUG
53
- require 'rubygems'
54
- require_gem lib
55
- rescue
56
- raise ex
57
- end
58
- end
59
- end
60
- end
61
-
62
- begin
63
- RIO.load_lib('zip/zip')
64
- require 'zip/zipfilesystem'
65
- require 'rio/ext/zipfile/opt'
66
- RIO::Ext::ZipFile.load_extension
67
- rescue LoadError
68
- p "No zipfile support" if $DEBUG
69
- end
70
-
71
-
72
- # module RIO
73
- # module Ext
74
- # module ZipFile
75
- # module Cx
76
- # def zipfile(&block)
77
- # #require 'rio/ext/zipfile/state'
78
- # cxx('zipfile',true,&block)
79
- # #self.extend(ZipFile::State).fstream
80
- # end
81
- # def zipfile?() cxx?('zipfile') end
82
- # def zipfile_()
83
- # cxx_('zipfile',true)
84
- # end
85
- # protected :zipfile_
86
-
87
- # def zipent(&block)
88
- # cxx('zipent',true,&block)
89
- # end
90
- # def zipent?() cxx?('zipent') end
91
- # def zipent_()
92
- # cxx_('zipent',true)
93
- # end
94
- # protected :zipent_
95
- # end
96
- # end
97
- # end
98
- # end
99
- __END__
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -63,7 +63,6 @@ module RIO
63
63
  @file = RIO::ZipFile::Wrap::File.new(@zipfile.file)
64
64
  @dir = RIO::ZipFile::Wrap::Dir.new(@zipfile.dir)
65
65
  @test = @file
66
- #p "InFile: #{@file.class}"
67
66
  end
68
67
  include RIO::FS::File
69
68
  include RIO::FS::Dir
@@ -75,31 +74,3 @@ module RIO
75
74
  end
76
75
 
77
76
  __END__
78
-
79
-
80
- class CentralDir < RIO::FS::Native
81
- def initialize(zipfilepath)
82
- @zipfilepath = zipfilepath
83
- @zipfile = Zip::ZipFile.new(@zipfilepath)
84
- super
85
- end
86
- def mkdir(path)
87
- @zipfile.mkdir(path)
88
- end
89
- def rmdir(path)
90
- @zipfile.remove(path)
91
- end
92
- def file()
93
- self
94
- end
95
- def open(zipfilepath)
96
- @zipfilepath = zipfilepath
97
- @zipfile = Zip::ZipFile.new(@zipfilepath)
98
- RIO::ZipFile::CentralDir.new(@zipfile)
99
- end
100
-
101
- end
102
-
103
- end
104
- end
105
- end
@@ -1,6 +1,6 @@
1
1
  #--
2
2
  # ===========================================================================
3
- # Copyright (c) 2005-2012 Christopher Kleckner
3
+ # Copyright (c) 2005-2017 Christopher Kleckner
4
4
  # All rights reserved
5
5
  #
6
6
  # This file is part of the Rio library for ruby.
@@ -30,7 +30,6 @@ module RIO
30
30
  module ZipFile #:nodoc: all
31
31
  module RootDir
32
32
  RESET_STATE = 'ZipFile::State::Reset'
33
- #RESET_STATE = RIO::RL::PathBase::RESET_STATE
34
33
 
35
34
  require 'rio/rl/base'
36
35
  class RL < RIO::RL::Base
@@ -57,7 +56,6 @@ module RIO
57
56
  IOH::Dir.new(ZipFile::Wrap::Stream::Root.new(@zipfile))
58
57
  end
59
58
  def close()
60
- p "CLOSING ZIPFILE RL"
61
59
  end
62
60
  def path()
63
61
  @infilepath
@@ -66,7 +64,6 @@ module RIO
66
64
  @infilepath
67
65
  end
68
66
  def base(*args)
69
- #p "base: #{args.inspect}"
70
67
  ''
71
68
  end
72
69
  def path_no_slash() self.path.to_s.sub(/\/$/,'') end
@@ -114,127 +111,3 @@ end
114
111
 
115
112
 
116
113
  __END__
117
- module Dir
118
- require 'rio/rl/path'
119
- RESET_STATE = RIO::RL::PathBase::RESET_STATE
120
- require 'tmpdir'
121
- class RL < RIO::RL::PathBase
122
- RIOSCHEME = 'tempdir'
123
- DFLT_PREFIX = Temp::RL::DFLT_PREFIX
124
- DFLT_TMPDIR = Temp::RL::DFLT_TMPDIR
125
- attr_reader :prefix,:tmpdir,:tmprl
126
- def initialize(file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
127
- #puts "initialize(#{file_prefix.inspect},#{temp_dir.inspect})"
128
- @prefix = file_prefix || DFLT_PREFIX
129
- @tmpdir = temp_dir || DFLT_TMPDIR
130
- require 'rio/tempdir'
131
- @td = ::Tempdir.new( @prefix.to_s, @tmpdir.to_s)
132
- super(@td.to_s)
133
- end
134
- def dir_rl()
135
- RIO::Dir::RL.new(self.uri, {:fs => self.fs})
136
- #self
137
- end
138
- SPLIT_RE = Temp::RL::SPLIT_RE
139
- def self.splitrl(s)
140
- Temp::RL.splitrl(s)
141
- end
142
- end
143
- end
144
- module File
145
- require 'rio/rl/path'
146
- RESET_STATE = 'Temp::Stream::Open'
147
- class RL < RIO::RL::PathBase
148
- RIOSCHEME = 'tempfile'
149
- DFLT_PREFIX = Temp::RL::DFLT_PREFIX
150
- DFLT_TMPDIR = Temp::RL::DFLT_TMPDIR
151
- attr_reader :prefix,:tmpdir,:tmprl
152
- def initialize(file_prefix=DFLT_PREFIX,temp_dir=DFLT_TMPDIR)
153
- #puts "initialize(#{file_prefix.inspect},#{temp_dir.inspect})"
154
- @prefix = file_prefix || DFLT_PREFIX
155
- @tmpdir = temp_dir || DFLT_TMPDIR
156
- require 'tempfile'
157
- @tf = ::Tempfile.new( @prefix.to_s, @tmpdir.to_s)
158
- super(@tf.path)
159
- end
160
- def file_rl()
161
- RIO::File::RL.new(self.uri,{:fs => self.fs})
162
- #self
163
- end
164
- def open(mode='ignored')
165
- #p callstr('open',mode)
166
- @tf
167
- end
168
- def close
169
- super
170
- @tf = nil
171
- end
172
- SPLIT_RE = Temp::RL::SPLIT_RE
173
- def self.splitrl(s)
174
- Temp::RL.splitrl(s)
175
- end
176
- end
177
- end
178
- require 'rio/state'
179
- class Reset < State::Base
180
- def initialize(*args)
181
- super
182
- #p args
183
- @tempobj = nil
184
- end
185
- #def self.default_cx
186
- # Cx::Vars.new( { 'closeoneof' => false, 'closeoncopy' => false } )
187
- #end
188
-
189
- def check?() true end
190
- def mkdir(prefix=rl.prefix,tmpdir=rl.tmpdir)
191
- self.rl = RIO::Temp::Dir::RL.new(prefix, tmpdir)
192
- become 'Dir::Existing'
193
- end
194
- # def mkdir()
195
- # dir()
196
- # end
197
- def chdir(&block)
198
- self.mkdir.chdir(&block)
199
- end
200
- def file(prefix=rl.prefix,tmpdir=rl.tmpdir)
201
- self.rl = RIO::Temp::File::RL.new(prefix, tmpdir)
202
- become 'Temp::Stream::Open'
203
- end
204
- def scheme() rl.scheme() end
205
- def host() rl.host() end
206
- def opaque() rl.opaque() end
207
- def to_s() rl.url() end
208
- def exist?() false end
209
- def file?() false end
210
- def dir?() false end
211
- def open?() false end
212
- def closed?() true end
213
- def when_missing(sym,*args)
214
- #p @rl.scheme
215
- if @tempobj.nil?
216
- file()
217
- else
218
- gofigure(sym,*args)
219
- end
220
- end
221
- end
222
- require 'rio/stream/open'
223
- module Stream
224
- class Open < RIO::Stream::Open
225
- def iostate(sym)
226
- mode_('w+').open_.inout()
227
- end
228
- # def inout() stream_state('Temp::Stream::InOut') end
229
- end
230
- # require 'rio/stream'
231
- # class InOut < RIO::Stream::InOut
232
- # def base_state() 'Temp::Stream::Close' end
233
- # end
234
- # class Close < RIO::Stream::Close
235
- # def base_state() 'Temp::Reset' end
236
- # end
237
-
238
- end
239
- end
240
- end