io-segmenter 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/io-segmenter.rb +3 -1
- data/lib/io-segmenter/core_ext/file.rb +8 -0
- data/lib/io-segmenter/core_ext/io.rb +5 -0
- data/lib/io-segmenter/core_ext/json.rb +22 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef640a71172e11880fce87b592533bc43d00e6ad4f05719d39528712bec96d8c
|
4
|
+
data.tar.gz: fc1a44127e69b4bf53108f4d5fa87e9a3f8cb1f715659ccb2093936a922449c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0a06f587dec25d94295597912ddc9668398ca14b79f24ce606979816447efd224578c3362ddcd7ea5131fec614ac77f990b56e2cd63d726a18b936a77b13981
|
7
|
+
data.tar.gz: 636c3bafcbf5991e8779aad2762fc8711e9d75d3784ff4a459fd73f6b3ccec0fc7bcf8585b54632f9d77b8d2cb1d1afec250b936c09fc3b343a26f5dcf8d3019
|
data/lib/io-segmenter.rb
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
class IOSegmenter
|
5
5
|
include Enumerable
|
6
6
|
|
7
|
-
|
7
|
+
DEFAULT_READ_SIZE = 8192
|
8
|
+
|
9
|
+
def initialize(io, starting_char, ending_char, quote_char, escape_char, max_read_size=DEFAULT_READ_SIZE)
|
8
10
|
@io = io
|
9
11
|
@starting_char = starting_char
|
10
12
|
@ending_char = ending_char
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JSON
|
4
|
+
def self.each_object(io, max_read_size=IOSegmenter::DEFAULT_READ_SIZE, &block)
|
5
|
+
IOSegmenter.new(io, '{', '}', '"', '\\', max_read_size).each do |segement|
|
6
|
+
yield parse(segement)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.each_string(io, max_read_size=IOSegmenter::DEFAULT_READ_SIZE)
|
11
|
+
IOSegmenter.new(io, '"', '"', nil, '\\', max_read_size).each do |segement|
|
12
|
+
yield segement[1, segement.size-2]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.each_item(io, max_read_size=IOSegmenter::DEFAULT_READ_SIZE)
|
17
|
+
io.read(1)
|
18
|
+
IOSegmenter.new(io, '[', ']', '"', '\\', max_read_size).each do |segement|
|
19
|
+
yield parse(segement)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: io-segmenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
@@ -17,6 +17,9 @@ extensions: []
|
|
17
17
|
extra_rdoc_files: []
|
18
18
|
files:
|
19
19
|
- lib/io-segmenter.rb
|
20
|
+
- lib/io-segmenter/core_ext/file.rb
|
21
|
+
- lib/io-segmenter/core_ext/io.rb
|
22
|
+
- lib/io-segmenter/core_ext/json.rb
|
20
23
|
homepage: https://github.com/dougyouch/io-segemnter
|
21
24
|
licenses: []
|
22
25
|
metadata: {}
|