eggnog 0.0.1 → 0.0.2
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.
- data/lib/eggnog/{node_decorator.rb → node.rb} +7 -2
- data/lib/eggnog/version.rb +1 -1
- data/lib/eggnog.rb +8 -5
- data/spec/eggnog/{node_decorator_spec.rb → node_spec.rb} +1 -1
- metadata +4 -7
- data/lib/node.rb +0 -5
- data/spec/node_spec.rb +0 -16
@@ -1,4 +1,4 @@
|
|
1
|
-
class Eggnog::
|
1
|
+
class Eggnog::Node < Struct.new(:node, :options)
|
2
2
|
|
3
3
|
CONTENT_ROOT = "__content__".freeze
|
4
4
|
|
@@ -7,7 +7,12 @@ class Eggnog::NodeDecorator < Struct.new(:node, :options)
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def to_hash(parent_hash = {})
|
10
|
-
|
10
|
+
case node
|
11
|
+
when Nokogiri::XML::Document
|
12
|
+
self.class.to_hash(node.root, options)
|
13
|
+
else
|
14
|
+
insert_into_parent_hash(parent_hash, collect_nodes)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
private
|
data/lib/eggnog/version.rb
CHANGED
data/lib/eggnog.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eggnog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -75,11 +75,9 @@ files:
|
|
75
75
|
- eggnog.gemspec
|
76
76
|
- eggnog.jpg
|
77
77
|
- lib/eggnog.rb
|
78
|
-
- lib/eggnog/
|
78
|
+
- lib/eggnog/node.rb
|
79
79
|
- lib/eggnog/version.rb
|
80
|
-
-
|
81
|
-
- spec/eggnog/node_decorator_spec.rb
|
82
|
-
- spec/node_spec.rb
|
80
|
+
- spec/eggnog/node_spec.rb
|
83
81
|
- spec/spec_helper.rb
|
84
82
|
homepage: http://github.com/rclosner/eggnog
|
85
83
|
licenses: []
|
@@ -106,6 +104,5 @@ signing_key:
|
|
106
104
|
specification_version: 3
|
107
105
|
summary: Nokogiri Mixin - Converts Nodes to a Hash
|
108
106
|
test_files:
|
109
|
-
- spec/eggnog/
|
110
|
-
- spec/node_spec.rb
|
107
|
+
- spec/eggnog/node_spec.rb
|
111
108
|
- spec/spec_helper.rb
|
data/lib/node.rb
DELETED
data/spec/node_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Nokogiri::XML::Node do
|
4
|
-
subject { Nokogiri::XML(xml) }
|
5
|
-
|
6
|
-
let(:xml) {"<root><foo>bar</foo></root>"}
|
7
|
-
|
8
|
-
describe "#to_hash" do
|
9
|
-
let(:options) { {} }
|
10
|
-
|
11
|
-
it "delegates to NodeDecorator" do
|
12
|
-
Eggnog::NodeDecorator.should_receive(:to_hash).with(subject, options)
|
13
|
-
subject.to_hash(options)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|