fake_io 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +3 -0
- data/.github/workflows/ruby.yml +28 -0
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.yardopts +1 -0
- data/ChangeLog.md +8 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.md +93 -0
- data/Rakefile +13 -0
- data/fake_io.gemspec +61 -0
- data/gemspec.yml +20 -0
- data/lib/fake_io/version.rb +4 -0
- data/lib/fake_io.rb +1213 -0
- data/spec/classes/test_io.rb +36 -0
- data/spec/fake_io_spec.rb +1212 -0
- data/spec/spec_helper.rb +4 -0
- metadata +81 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'fake_io'
|
2
|
+
|
3
|
+
class TestIO
|
4
|
+
|
5
|
+
include FakeIO
|
6
|
+
|
7
|
+
def initialize(chunks)
|
8
|
+
@index = 0
|
9
|
+
@blocks = chunks
|
10
|
+
|
11
|
+
super()
|
12
|
+
end
|
13
|
+
|
14
|
+
protected
|
15
|
+
|
16
|
+
def io_open
|
17
|
+
3
|
18
|
+
end
|
19
|
+
|
20
|
+
def io_read
|
21
|
+
unless (block = @blocks[@index])
|
22
|
+
raise(EOFError,"end of stream")
|
23
|
+
end
|
24
|
+
|
25
|
+
@index += 1
|
26
|
+
return block
|
27
|
+
end
|
28
|
+
|
29
|
+
def io_write(data)
|
30
|
+
@blocks[@index] = data
|
31
|
+
@index += 1
|
32
|
+
|
33
|
+
return data.length
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|