muffins 0.0.7.pre.2 → 0.0.7.pre.3

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.
@@ -21,7 +21,7 @@ module Muffins
21
21
 
22
22
  # @api public
23
23
  def parse(doc, options = {})
24
- document = Muffins::Document.new(:body => doc)
24
+ document = Muffins::Document.new(:body => doc.to_s)
25
25
 
26
26
  if options[:single]
27
27
  new_from_node(document.first(path))
@@ -57,4 +57,4 @@ module Muffins
57
57
  end
58
58
 
59
59
  end
60
- end
60
+ end
@@ -3,16 +3,16 @@ module Muffins
3
3
 
4
4
  include Virtus
5
5
 
6
- attribute :body, Class, :reader => :protected
6
+ attribute :body, String, :reader => :protected
7
7
 
8
8
  # @api public
9
9
  def first(path)
10
- body.at_css(path)
10
+ xml.at_css(path)
11
11
  end
12
12
 
13
13
  # @api public
14
14
  def all(path)
15
- body.css(path)
15
+ xml.css(path)
16
16
  end
17
17
 
18
18
  # @api public
@@ -25,21 +25,10 @@ module Muffins
25
25
  all(path).each { |node| yield node }
26
26
  end
27
27
 
28
- protected
29
-
30
- # @api private
31
- def body=(body)
32
- case body
33
- when String
34
- @body = Nokogiri::XML(body)
35
- when Nokogiri::XML::Element
36
- @body = Nokogiri::XML(body.to_s)
37
- when Nokogiri::XML::Document
38
- @body = body
39
- else
40
- raise ArgumentError, "+body+ is an invalid type"
41
- end
42
- end
28
+ private
43
29
 
30
+ def xml
31
+ @xml ||= Nokogiri::XML(body)
32
+ end
44
33
  end
45
34
  end
@@ -10,7 +10,7 @@ module Muffins
10
10
 
11
11
  # @api public
12
12
  def parse(doc)
13
- document = Muffins::Document.new(:body => doc)
13
+ document = Muffins::Document.new(:body => doc.to_s)
14
14
 
15
15
  if collection?
16
16
  document.map(absolute_path) { |node| node.text }
@@ -31,4 +31,4 @@ module Muffins
31
31
  end
32
32
 
33
33
  end
34
- end
34
+ end
@@ -1,3 +1,3 @@
1
1
  module Muffins
2
- VERSION = "0.0.7.pre.2"
2
+ VERSION = "0.0.7.pre.3"
3
3
  end
data/spec/muffins_spec.rb CHANGED
@@ -103,4 +103,4 @@ describe Muffins do
103
103
 
104
104
  end
105
105
 
106
- end
106
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: muffins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.pre.2
4
+ version: 0.0.7.pre.3
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors: