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.
@@ -1,4 +1,4 @@
1
- class Eggnog::NodeDecorator < Struct.new(:node, :options)
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
- insert_into_parent_hash(parent_hash, collect_nodes)
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
@@ -1,3 +1,3 @@
1
1
  module Eggnog
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/eggnog.rb CHANGED
@@ -1,6 +1,9 @@
1
- module Eggnog
2
- end
3
-
1
+ require "nokogiri"
4
2
  require "eggnog/version"
5
- require "eggnog/node_decorator"
6
- require "node"
3
+ require "eggnog/node"
4
+
5
+ class Nokogiri::XML::Node
6
+ def to_hash(options = {})
7
+ Eggnog::Node.to_hash(self, options)
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Eggnog::NodeDecorator do
3
+ describe Eggnog::Node do
4
4
  subject { described_class.new(node, options) }
5
5
 
6
6
  let(:node) { Nokogiri::XML(xml).root }
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.1
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/node_decorator.rb
78
+ - lib/eggnog/node.rb
79
79
  - lib/eggnog/version.rb
80
- - lib/node.rb
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/node_decorator_spec.rb
110
- - spec/node_spec.rb
107
+ - spec/eggnog/node_spec.rb
111
108
  - spec/spec_helper.rb
data/lib/node.rb DELETED
@@ -1,5 +0,0 @@
1
- class Nokogiri::XML::Node
2
- def to_hash(options = {})
3
- Eggnog::NodeDecorator.to_hash(self, options)
4
- end
5
- end
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