kanrisuru 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kanrisuru/core/stream.rb +2 -2
- data/lib/kanrisuru/version.rb +1 -1
- data/spec/functional/core/stream_spec.rb +18 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc638e7e85cf76460cffecc7bcd885a7cc3f30c098c1d2fa0250daeb455e87a2
|
4
|
+
data.tar.gz: 78d733e6299f3a49ce40a0be6bb73b50a8c6b9f184ceacf920bc55661653c393
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2706ac5496f456560795adedbe445ecfa1509e7d3d60dde5b5d4e85a59687b1477fdf035aeba0b31a5ade24cc25c962a8cbb559a75ba5899eaf90e4f02ada212
|
7
|
+
data.tar.gz: 606de07f8ddd04465df2bc0f4bd3ffbfb1e362986613a31f2184076337ba9542ea05ac1874d36c24442d1609f176dfa1bd2cf8104835fa1233d9e4c68cd7f7a4
|
@@ -35,8 +35,8 @@ module Kanrisuru
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def read_file_chunk(path, start_line, end_line)
|
38
|
-
if start_line.instance_of?(Integer) || end_line.instance_of?(Integer) ||
|
39
|
-
start_line > end_line || start_line.negative?
|
38
|
+
if !start_line.instance_of?(Integer) || !end_line.instance_of?(Integer) ||
|
39
|
+
start_line > end_line || start_line.negative? || end_line.negative?
|
40
40
|
raise ArgumentError, 'Invalid start or end'
|
41
41
|
end
|
42
42
|
|
data/lib/kanrisuru/version.rb
CHANGED
@@ -74,6 +74,24 @@ RSpec.describe Kanrisuru::Core::Stream do
|
|
74
74
|
expect(result.data).to eq(['a', 'file!'])
|
75
75
|
end
|
76
76
|
|
77
|
+
it 'reads a chunk of text from a file' do
|
78
|
+
file = host.file("#{spec_dir}/test-file-chunk.txt")
|
79
|
+
file.touch
|
80
|
+
file.append do |f|
|
81
|
+
f << 'This'
|
82
|
+
f << 'is'
|
83
|
+
f << 'is'
|
84
|
+
f << 'a'
|
85
|
+
f << 'file'
|
86
|
+
f << 'forever...'
|
87
|
+
end
|
88
|
+
|
89
|
+
result = host.read_file_chunk("#{spec_dir}/test-file-chunk.txt", 2, 4)
|
90
|
+
expect(result).to be_success
|
91
|
+
expect(result.data.length).to eq(3)
|
92
|
+
expect(result.data).to eq(['is', 'is', 'a'])
|
93
|
+
end
|
94
|
+
|
77
95
|
it 'cats a file' do
|
78
96
|
result = host.cat('/etc/group')
|
79
97
|
expect(result.success?).to eq(true)
|