sax-machine 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +14 -4
- data/Gemfile +5 -1
- data/Guardfile +2 -2
- data/HISTORY.md +23 -6
- data/README.md +111 -40
- data/Rakefile +4 -3
- data/lib/sax-machine.rb +11 -2
- data/lib/sax-machine/{sax_ancestor_config.rb → config/sax_ancestor.rb} +3 -7
- data/lib/sax-machine/{sax_attribute_config.rb → config/sax_attribute.rb} +4 -6
- data/lib/sax-machine/{sax_collection_config.rb → config/sax_collection.rb} +6 -10
- data/lib/sax-machine/{sax_element_config.rb → config/sax_element.rb} +16 -17
- data/lib/sax-machine/{sax_element_value_config.rb → config/sax_element_value.rb} +5 -7
- data/lib/sax-machine/{sax_handler.rb → handlers/sax_abstract_handler.rb} +28 -32
- data/lib/sax-machine/handlers/sax_nokogiri_handler.rb +16 -0
- data/lib/sax-machine/handlers/sax_ox_handler.rb +41 -0
- data/lib/sax-machine/sax_config.rb +9 -9
- data/lib/sax-machine/sax_configure.rb +1 -6
- data/lib/sax-machine/sax_document.rb +28 -17
- data/lib/sax-machine/version.rb +2 -2
- data/sax-machine.gemspec +8 -11
- data/spec/fixtures/atom-content.html +15 -0
- data/spec/{sax-machine → fixtures}/atom.xml +0 -0
- data/spec/sax-machine/sax_activerecord_spec.rb +23 -0
- data/spec/sax-machine/sax_configure_spec.rb +48 -0
- data/spec/sax-machine/sax_document_spec.rb +333 -280
- data/spec/sax-machine/sax_include_spec.rb +43 -0
- data/spec/spec_helper.rb +11 -2
- metadata +36 -41
- data/spec/benchmarks/amazon.xml +0 -40
- data/spec/benchmarks/benchmark.rb +0 -158
- data/spec/benchmarks/public_timeline.xml +0 -411
- data/spec/sax-machine/configure_sax_machine_spec.rb +0 -53
- data/spec/sax-machine/include_sax_machine_spec.rb +0 -42
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
class A
|
4
|
-
|
5
|
-
SAXMachine.configure(A) do |c|
|
6
|
-
c.element :title
|
7
|
-
end
|
8
|
-
|
9
|
-
end
|
10
|
-
|
11
|
-
class B < A
|
12
|
-
|
13
|
-
SAXMachine.configure(B) do |c|
|
14
|
-
c.element :b
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
class C < B
|
20
|
-
|
21
|
-
SAXMachine.configure(C) do |c|
|
22
|
-
c.element :c
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "SAXMachine configure" do
|
28
|
-
before do
|
29
|
-
xml = "<top><title>Test</title><b>Matched!</b><c>And Again</c></top>"
|
30
|
-
@a = A.new
|
31
|
-
@a.parse xml
|
32
|
-
@b = B.new
|
33
|
-
@b.parse xml
|
34
|
-
@c = C.new
|
35
|
-
@c.parse xml
|
36
|
-
end
|
37
|
-
it { @a.should be_a(A) }
|
38
|
-
it { @a.should_not be_a(B) }
|
39
|
-
it { @a.should be_a(SAXMachine) }
|
40
|
-
it { @a.title.should == "Test" }
|
41
|
-
it { @b.should be_a(A) }
|
42
|
-
it { @b.should be_a(B) }
|
43
|
-
it { @b.should be_a(SAXMachine) }
|
44
|
-
it { @b.title.should == "Test" }
|
45
|
-
it { @b.b.should == "Matched!" }
|
46
|
-
it { @c.should be_a(A) }
|
47
|
-
it { @c.should be_a(B) }
|
48
|
-
it { @c.should be_a(C) }
|
49
|
-
it { @c.should be_a(SAXMachine) }
|
50
|
-
it { @c.title.should == "Test" }
|
51
|
-
it { @c.b.should == "Matched!" }
|
52
|
-
it { @c.c.should == "And Again" }
|
53
|
-
end
|
@@ -1,42 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
|
3
|
-
class A
|
4
|
-
include SAXMachine
|
5
|
-
element :title
|
6
|
-
end
|
7
|
-
|
8
|
-
class B < A
|
9
|
-
element :b
|
10
|
-
end
|
11
|
-
|
12
|
-
class C < B
|
13
|
-
element :c
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "SAXMachine inheritance" do
|
17
|
-
before do
|
18
|
-
xml = "<top><title>Test</title><b>Matched!</b><c>And Again</c></top>"
|
19
|
-
@a = A.new
|
20
|
-
@a.parse xml
|
21
|
-
@b = B.new
|
22
|
-
@b.parse xml
|
23
|
-
@c = C.new
|
24
|
-
@c.parse xml
|
25
|
-
end
|
26
|
-
it { @a.should be_a(A) }
|
27
|
-
it { @a.should_not be_a(B) }
|
28
|
-
it { @a.should be_a(SAXMachine) }
|
29
|
-
it { @a.title.should == "Test" }
|
30
|
-
it { @b.should be_a(A) }
|
31
|
-
it { @b.should be_a(B) }
|
32
|
-
it { @b.should be_a(SAXMachine) }
|
33
|
-
it { @b.title.should == "Test" }
|
34
|
-
it { @b.b.should == "Matched!" }
|
35
|
-
it { @c.should be_a(A) }
|
36
|
-
it { @c.should be_a(B) }
|
37
|
-
it { @c.should be_a(C) }
|
38
|
-
it { @c.should be_a(SAXMachine) }
|
39
|
-
it { @c.title.should == "Test" }
|
40
|
-
it { @c.b.should == "Matched!" }
|
41
|
-
it { @c.c.should == "And Again" }
|
42
|
-
end
|