elementor 0.0.2 → 0.0.3

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 +18 -6
  2. metadata +2 -2
@@ -1,10 +1,12 @@
1
1
  module Elementor
2
2
  class Result
3
+ attr_writer :doc_ready
3
4
  attr_reader :context, :opts
4
5
 
5
6
  def initialize(context, opts={}, &block)
6
7
  @opts = opts
7
8
  @context = context
9
+ @doc_ready = false
8
10
  block.call(naming_context)
9
11
  end
10
12
 
@@ -21,9 +23,10 @@ module Elementor
21
23
  end
22
24
 
23
25
  def dispatcher
24
- @dispatcher ||= blank_context(:this => self, :doc => doc) do
26
+ @dispatcher ||= blank_context(:this => self) do
25
27
  def method_missing(sym, *args, &block)
26
- @this.try(sym, *args, &block) || @doc.try(sym, *args, &block) || super
28
+ @this.doc_ready = true
29
+ @this.try(sym, *args, &block) || @this.doc.try(sym, *args, &block) || super
27
30
  end
28
31
  end
29
32
  end
@@ -41,11 +44,20 @@ module Elementor
41
44
  @element_names ||= { }
42
45
  end
43
46
 
44
- private
45
-
46
47
  def doc(markup=nil)
47
- @doc = nil if markup
48
- @doc ||= Nokogiri(markup || context.send(opts[:from] || :body)) rescue nil
48
+ if html = markup || content
49
+ @doc = nil if markup
50
+ @doc ||= Nokogiri(html)
51
+ end
52
+ end
53
+
54
+ def content
55
+ return unless doc_ready?
56
+ @content ||= context.send(opts[:from] || :body)
57
+ end
58
+
59
+ def doc_ready?
60
+ @doc_ready
49
61
  end
50
62
  end
51
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elementor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pat Nakajima
@@ -41,7 +41,7 @@ files:
41
41
  - lib/core_ext/kernel.rb
42
42
  - lib/core_ext/symbol.rb
43
43
  has_rdoc: false
44
- homepage: http://github.com/pivotal/elementor
44
+ homepage: http://github.com/nakajima/elementor
45
45
  post_install_message:
46
46
  rdoc_options: []
47
47