roda-component 0.1.19 → 0.1.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66723e0404166c9f7164960ab737e3c6f4b90fa9
4
- data.tar.gz: ff7525825b5879547063169799e716da534af47a
3
+ metadata.gz: c498627e08894de678599a4c6f1e5ee3c2c51a23
4
+ data.tar.gz: ba8977a923ef51aa5378fcd14760c5811d4f0537
5
5
  SHA512:
6
- metadata.gz: 7fef4da2dac5d2e5eda3994ba3fb8972ca0c702c58aa9bdecfe94fc202dbb109168480454883976f8f113dccba05beb635f8cb3bbae35e173d1210698e15b19e
7
- data.tar.gz: d317c8b92f8b10d21dbed7dd82d311911b256db603c4eddd9d7da8ba6a431406640422ba3dae3453f010afd236a7fa23296433b1d416ff74f86c80bd099eb222
6
+ metadata.gz: 7cd6097f479d63615a6b6b2c393dc5191f166e7b6da8e6e84ad00a732622f4c586326152f1980b9ed78420c0b3596a9c35304cfb8d25707325a07caf8fe7e021
7
+ data.tar.gz: b653b8d9c78622090a362e23b9a53429de4434157103ebc251753971301a3e7097ca7e86ae1dc926d8d159d982b34adc3eb96288720e45ff37b8ec3f74b8bb86
@@ -1,6 +1,8 @@
1
+ require 'delegate'
2
+
1
3
  class Roda
2
4
  class Component
3
- class DOM
5
+ class DOM < SimpleDelegator
4
6
  attr_accessor :dom, :raw_html
5
7
 
6
8
  def initialize html
@@ -11,23 +13,25 @@ class Roda
11
13
  else
12
14
  @dom = raw_html.is_a?(String) ? Element[raw_html.dup] : raw_html
13
15
  end
16
+
17
+ super @dom
14
18
  end
15
19
 
16
20
  def find string, &block
17
- if server?
18
- node = DOM.new dom.css(string)
19
- else
21
+ if client?
20
22
  node = DOM.new dom.find(string)
23
+ elsif server?
24
+ if block
25
+ node = DOM.new dom.css(string)
26
+ else
27
+ node = DOM.new dom.at(string)
28
+ end
21
29
  end
22
30
 
23
31
  if block
24
32
  node.each do |n|
25
33
  block.call DOM.new n
26
34
  end
27
- else
28
- if server?
29
- node = DOM.new node.first
30
- end
31
35
  end
32
36
 
33
37
  node
@@ -75,14 +79,14 @@ class Roda
75
79
 
76
80
  # This allows you to use all the nokogiri or opal jquery methods if a
77
81
  # global one isn't set
78
- def method_missing method, *args, &block
79
- # respond_to?(symbol, include_all=false)
80
- if dom.respond_to? method, true
81
- dom.send method, *args, &block
82
- else
83
- super
84
- end
85
- end
82
+ # def method_missing method, *args, &block
83
+ # # respond_to?(symbol, include_all=false)
84
+ # if dom.respond_to? method, true
85
+ # dom.send method, *args, &block
86
+ # else
87
+ # super
88
+ # end
89
+ # end
86
90
 
87
91
  private
88
92
 
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.19"
3
+ VERSION = "0.1.20"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.19
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj