sax_stream 1.0.4 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5738222c184e824b0b1df587aa49db89b929d250
4
- data.tar.gz: 0d334e709b9546370943ec9db6d1f7c4132b802b
3
+ metadata.gz: 27411b80a5dfb5a158a6235b8e03d116a426f674
4
+ data.tar.gz: 0ef904fee665c4858cac0c867bbe44201d945623
5
5
  SHA512:
6
- metadata.gz: fc90bdaba07bfacd77a4eeff6110a991c354409fa6cf118061ec3e46dd90f49d91037faaef0680bb9f2f7dfb9ba6784b6bd2245dc3cc7ff68c3be8388783b053
7
- data.tar.gz: 79f209f1e3eff0c5a19223015c96394e0d98b79d8a3608ad45f902ab48788f37a76ad61230b1beaafdde01dc6b2ecdfc85afc114e4893b2472da39e4abeace3f
6
+ metadata.gz: f1bd6200c50d8e463b19b696896f2c747607739e18cadb4bb02951d1c814c6bea2d6041d76a00943cb450043a55de5fd02103a15ca865db807d61f759379ef2e
7
+ data.tar.gz: eb07a4aefe1a69d887546345981d8d2f336b9235fb3048f9b30bc00b09a854df1aa92ac7b30179dbf6874c42d3d8831a45613592cbb192f2053f36ba37099fc0
@@ -5,6 +5,11 @@ require 'sax_stream/internal/combined_handler'
5
5
  module SaxStream
6
6
  module Internal
7
7
  class SaxHandler < Nokogiri::XML::SAX::Document
8
+ ERROR_TYPES = {
9
+ 'Document is empty' => nil,
10
+ 'Start tag expected, \'<\' not found' => nil
11
+ }
12
+
8
13
  def initialize(collector, mappers, handler_stack = HandlerStack.new)
9
14
  @handler_stack = handler_stack
10
15
  mapper_handlers = mappers.map do |mapper|
@@ -29,8 +34,20 @@ module SaxStream
29
34
  @handler_stack.top.cdata_block(*params)
30
35
  end
31
36
 
32
- def error(string)
33
- raise ParsingError.new(string)
37
+ def error(message)
38
+ klass = error_class(message)
39
+ if klass
40
+ raise klass.new(message.inspect)
41
+ end
42
+ end
43
+
44
+ def error_class(message)
45
+ message.strip!
46
+ if ERROR_TYPES.has_key?(message)
47
+ ERROR_TYPES[message]
48
+ else
49
+ ParsingError
50
+ end
34
51
  end
35
52
  end
36
53
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sax_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Craig Ambrose
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-17 00:00:00.000000000 Z
11
+ date: 2014-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -55,8 +55,8 @@ files:
55
55
  - lib/sax_stream/types/decimal.rb
56
56
  - lib/sax_stream/types/integer.rb
57
57
  - lib/sax_stream/types.rb
58
- - LICENSE
59
- - README.markdown
58
+ - ./LICENSE
59
+ - ./README.markdown
60
60
  homepage: http://github.com/craigambrose/sax_stream
61
61
  licenses: []
62
62
  metadata: {}