multisax 0.0.0.2 → 0.0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,39 @@
1
1
  = multisax
2
2
 
3
- Please check spec/multisax.spec as an example.
3
+ * Please check spec/multisax.spec as an example.
4
+ * Complex usage:
5
+ ```ruby
6
+ listener=MultiSAX::Sax.parse(xml,Class.new{
7
+ include MultiSAX::Callbacks
8
+ def initialize
9
+ @content=Hash.new{|h,k|h[k]=[]}
10
+ @current_tag=[]
11
+ end
12
+ attr_reader :content
13
+
14
+ def sax_tag_start(tag,attrs)
15
+ @current_tag.push(tag)
16
+ end
17
+ def sax_tag_end(tag)
18
+ if (t=@current_tag.pop)!=tag then raise "xml is malformed /#{t}" end
19
+ end
20
+ def sax_cdata(text)
21
+ @content[@current_tag.last] << text
22
+ end
23
+ def sax_text(text)
24
+ text.strip!
25
+ @content[@current_tag.last] << text if text.size>0
26
+ end
27
+ def sax_comment(text)
28
+ end
29
+ }.new)
30
+ listener.content.each{...}
31
+ ```
32
+
33
+ * Optional XML libraries:
34
+ * gem install ox
35
+ * gem install libxml-ruby
36
+ * gem install nokogiri
4
37
 
5
38
  == Contributing to multisax
6
39
 
@@ -16,4 +49,3 @@ Please check spec/multisax.spec as an example.
16
49
 
17
50
  Copyright (c) 2013 cielavenir. See LICENSE.txt for
18
51
  further details.
19
-
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0.2
1
+ 0.0.0.3
data/lib/multisax.rb CHANGED
@@ -62,6 +62,7 @@ module MultiSAX
62
62
  return @@parser
63
63
  end
64
64
  def self.reset() @@parser=nil;@@saxmodule=nil end
65
+ def self.parser() @@parser end
65
66
 
66
67
  #def initialize(listener)
67
68
  def self.parse(body,listener)
@@ -159,7 +160,6 @@ module MultiSAX
159
160
  end
160
161
  @listener
161
162
  end
162
- attr_reader :parser
163
163
  end
164
164
  module Callbacks
165
165
  # https://github.com/sparklemotion/nokogiri/blob/master/lib/nokogiri/xml/sax/document.rb
data/multisax.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "multisax"
8
- s.version = "0.0.0.2"
8
+ s.version = "0.0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["cielavenir"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.email = "cielartisan@gmail.com"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.rdoc"
17
+ "README.md"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  "Gemfile",
23
23
  "Gemfile.lock",
24
24
  "LICENSE.txt",
25
- "README.rdoc",
25
+ "README.md",
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "lib/multisax.rb",
@@ -27,26 +27,31 @@ describe "Multisax" do
27
27
  it "rexmlstream" do
28
28
  MultiSAX::Sax.reset
29
29
  MultiSAX::Sax.open(:rexmlstream)
30
+ MultiSAX::Sax.parser.should eq :rexmlstream
30
31
  MultiSAX::Sax.parse(input_xml,MultiSAXTester.new).result.should eq answer
31
32
  end
32
33
  it "rexmlsax2" do
33
34
  MultiSAX::Sax.reset
34
35
  MultiSAX::Sax.open(:rexmlsax2)
36
+ MultiSAX::Sax.parser.should eq :rexmlsax2
35
37
  MultiSAX::Sax.parse(input_xml,MultiSAXTester.new).result.should eq answer
36
38
  end
37
39
  it "ox" do
38
40
  MultiSAX::Sax.reset
39
41
  MultiSAX::Sax.open(:ox)
42
+ MultiSAX::Sax.parser.should eq :ox
40
43
  MultiSAX::Sax.parse(input_xml,MultiSAXTester.new).result.should eq answer
41
44
  end
42
45
  it "libxml" do
43
46
  MultiSAX::Sax.reset
44
47
  MultiSAX::Sax.open(:libxml)
48
+ MultiSAX::Sax.parser.should eq :libxml
45
49
  MultiSAX::Sax.parse(input_xml,MultiSAXTester.new).result.should eq answer
46
50
  end
47
51
  it "nokogiri" do
48
52
  MultiSAX::Sax.reset
49
53
  MultiSAX::Sax.open(:nokogiri)
54
+ MultiSAX::Sax.parser.should eq :nokogiri
50
55
  MultiSAX::Sax.parse(input_xml,MultiSAXTester.new).result.should eq answer
51
56
  end
52
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multisax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.2
4
+ version: 0.0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -81,14 +81,14 @@ executables: []
81
81
  extensions: []
82
82
  extra_rdoc_files:
83
83
  - LICENSE.txt
84
- - README.rdoc
84
+ - README.md
85
85
  files:
86
86
  - .document
87
87
  - .rspec
88
88
  - Gemfile
89
89
  - Gemfile.lock
90
90
  - LICENSE.txt
91
- - README.rdoc
91
+ - README.md
92
92
  - Rakefile
93
93
  - VERSION
94
94
  - lib/multisax.rb
@@ -110,7 +110,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
110
110
  version: '0'
111
111
  segments:
112
112
  - 0
113
- hash: -4490636935170503437
113
+ hash: -2850175293617683642
114
114
  required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  none: false
116
116
  requirements: