julien51-sax-machine 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -10,6 +10,7 @@ module SAXMachine
10
10
  unless @parser
11
11
  sax_handler = SAXHandler.new(self)
12
12
  @parser = Nokogiri::XML::SAX::PushParser.new(sax_handler)
13
+ @parser.options |= Nokogiri::XML::ParseOptions::RECOVER if @parser.respond_to?(:options)
13
14
  end
14
15
  @parser << xml_text
15
16
  self
@@ -0,0 +1,35 @@
1
+ module SAXMachine
2
+ class SAXEventRecorder < SAXHandler
3
+ def initialize(nsstack)
4
+ super(nil, nsstack)
5
+ @events = []
6
+ end
7
+
8
+ def object
9
+ # First and last belong to the parent element
10
+ @events[1..-2]
11
+ end
12
+
13
+ def start_element(name, attrs = [])
14
+ @nsstack = NSStack.new(@nsstack, attrs)
15
+ prefix, name = name.split(':', 2)
16
+ prefix, name = nil, prefix unless name
17
+ @events << [:start_element, @nsstack[prefix], name, attrs]
18
+ end
19
+
20
+ def end_element(name)
21
+ prefix, name = name.split(':', 2)
22
+ prefix, name = nil, prefix unless name
23
+ @events << [:end_element, @nsstack[prefix], name]
24
+ @nsstack = @nsstack.pop
25
+ end
26
+
27
+ def characters(string)
28
+ @events << [:chars, string]
29
+ end
30
+
31
+ def sax_config
32
+ raise
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: julien51-sax-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -41,14 +41,16 @@ files:
41
41
  - lib/sax-machine/sax_document.rb
42
42
  - lib/sax-machine/sax_handler.rb
43
43
  - lib/sax-machine/ns_stack.rb
44
+ - lib/sax-machine/sax_event_recorder.rb
44
45
  - README.textile
45
46
  - Rakefile
46
47
  - spec/spec.opts
47
48
  - spec/spec_helper.rb
48
49
  - spec/sax-machine/sax_document_spec.rb
49
- has_rdoc: false
50
- homepage: http://github.com/pauldix/sax-machine
51
- licenses:
50
+ has_rdoc: true
51
+ homepage: http://github.com/julien51/sax-machine
52
+ licenses: []
53
+
52
54
  post_install_message:
53
55
  rdoc_options: []
54
56