nokogiri-streaming-reader 1.1 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nokogiri/streaming/reader.rb +27 -25
- data/lib/nokogiri/streaming/version.rb +1 -1
- data/nokogiri-streaming-reader.gemspec +2 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da58b88e2dc1bec230f86ec4c1740f1f9121d984
|
4
|
+
data.tar.gz: c5c1bd599014dd289ef567a02bf8812ce1644495
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e57f4d06b42433747cb53ce9ef317f22ac410f426419636c7fa18bb7308c04ebe4a4a74a7d4de170f07cddc6898a18bb339f65a47646b921d965d957763b454
|
7
|
+
data.tar.gz: 202fb2912eea63133ec9e8094360d8106ea54b9e1c8f01dc274392a55f8d1659f8738d0ba50e4162b2439138f4aaae3ccf934611893b5581463f89cc24651c04
|
@@ -3,36 +3,13 @@ require 'nokogiri'
|
|
3
3
|
module Nokogiri
|
4
4
|
module Streaming
|
5
5
|
|
6
|
-
# IO wrapper which traps stream exceptions. This works around bug in Nokogiri's
|
7
|
-
# SAX code, which seems to ignore exceptions entirely.
|
8
|
-
class IOWrapper
|
9
|
-
def initialize(source)
|
10
|
-
@source = source
|
11
|
-
end
|
12
|
-
|
13
|
-
def read(length = nil)
|
14
|
-
begin
|
15
|
-
return @source.read(length)
|
16
|
-
rescue => e
|
17
|
-
@exception = e
|
18
|
-
raise
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def close
|
23
|
-
@stream.close
|
24
|
-
end
|
25
|
-
|
26
|
-
attr_reader :exception
|
27
|
-
end
|
28
|
-
|
29
6
|
class ParseError < StandardError; end
|
30
7
|
|
31
8
|
class Reader < XML::SAX::Document
|
32
9
|
|
33
|
-
def initialize(source)
|
10
|
+
def initialize(source, encoding: 'utf-8')
|
34
11
|
@source = IOWrapper.new(source)
|
35
|
-
@parser = Nokogiri::XML::SAX::Parser.new(self)
|
12
|
+
@parser = Nokogiri::XML::SAX::Parser.new(self, encoding)
|
36
13
|
@stack = []
|
37
14
|
@end_triggers = {}
|
38
15
|
@start_triggers = {}
|
@@ -131,5 +108,30 @@ module Nokogiri
|
|
131
108
|
|
132
109
|
end
|
133
110
|
|
111
|
+
private
|
112
|
+
|
113
|
+
# IO wrapper which traps stream exceptions. This works around bug in Nokogiri's
|
114
|
+
# SAX code, which seems to ignore exceptions entirely.
|
115
|
+
class IOWrapper
|
116
|
+
def initialize(source)
|
117
|
+
@source = source
|
118
|
+
end
|
119
|
+
|
120
|
+
def read(length = nil)
|
121
|
+
begin
|
122
|
+
return @source.read(length)
|
123
|
+
rescue => e
|
124
|
+
@exception = e
|
125
|
+
raise
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
def close
|
130
|
+
@stream.close
|
131
|
+
end
|
132
|
+
|
133
|
+
attr_reader :exception
|
134
|
+
end
|
135
|
+
|
134
136
|
end
|
135
137
|
end
|
@@ -20,6 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
21
|
spec.require_paths = ["lib"]
|
22
22
|
|
23
|
+
spec.required_ruby_version = '>= 2.0'
|
24
|
+
|
23
25
|
spec.add_dependency "nokogiri", ">= 1.4"
|
24
26
|
spec.add_development_dependency "bundler", "~> 1.5"
|
25
27
|
spec.add_development_dependency "rake"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nokogiri-streaming-reader
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Staubo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -95,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
95
95
|
requirements:
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: '0'
|
98
|
+
version: '2.0'
|
99
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -103,10 +103,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
version: '0'
|
104
104
|
requirements: []
|
105
105
|
rubyforge_project:
|
106
|
-
rubygems_version: 2.5.2
|
106
|
+
rubygems_version: 2.4.5.2
|
107
107
|
signing_key:
|
108
108
|
specification_version: 4
|
109
109
|
summary: Simple streaming reader for Nokogiri.
|
110
110
|
test_files:
|
111
111
|
- spec/reader_spec.rb
|
112
112
|
- spec/spec_helper.rb
|
113
|
+
has_rdoc:
|