nakajima-elementor 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/elementor/result.rb +8 -1
  2. metadata +1 -1
@@ -1,4 +1,6 @@
1
1
  module Elementor
2
+ class InvalidParser < ArgumentError ; end
3
+
2
4
  class Result
3
5
  attr_writer :doc_ready
4
6
  attr_reader :context, :opts
@@ -43,7 +45,12 @@ module Elementor
43
45
  def doc(markup=nil)
44
46
  if html = markup || content
45
47
  @doc = nil if markup
46
- @doc ||= Nokogiri(html)
48
+ parser = opts[:as] ? opts[:as].to_s : nil
49
+ @doc ||= case parser
50
+ when nil, 'html' then Nokogiri::HTML(html)
51
+ when 'xml' then Nokogiri::XML(html)
52
+ else raise InvalidParser.new("Nokogiri cannot parse as '#{opts[:as]}'. Please request :xml or :html.")
53
+ end
47
54
  end
48
55
  end
49
56
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nakajima-elementor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Nakajima