roda-component 0.1.25 → 0.1.26

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3597012e5d7d5f29e2313055ae0d4bf2636f2e61
4
- data.tar.gz: 0c9f50edc7029a9a827b4605e27b5459c8dd5926
3
+ metadata.gz: 78dab2bcfa41cf6dd926bd00316b62a0e002f7e6
4
+ data.tar.gz: 9adfd1a24eca3929430845cdc978e802712509da
5
5
  SHA512:
6
- metadata.gz: a71b97dd28899591a0e33bc68e5b6cd9b62ea9700ef8a42fff5bf714d8a734850776473c7d998f49c864a8fb0fbb554e45cd253b1e11097f30b615a6bbdf59d7
7
- data.tar.gz: a42ee5d887dbb60490faf2f462d08729d426becb1fcef526cc7c16ab39bdbe20d13cbb349c2591c3865c21e3d6ea6b71367a69750baae4643b162c45ec2d0bd6
6
+ metadata.gz: 036dbdf68ded63e356696c7e4dc7d3a6e80748965b8e298c8f84a329f526011c4bc2224ce35178982ed6f3fcad506931bff76b731cc654f22ab8c1dfbc88aada
7
+ data.tar.gz: 8006ec9a03a51489fa03f931432a2e12d481907aa124a33786646b634e7fdb2dbeecbb0a6d80d9605f3293d43d9a67e285935e536463ea60d1f5ee61728691f6
@@ -4,6 +4,41 @@ require 'ostruct'
4
4
 
5
5
  unless RUBY_ENGINE == 'opal'
6
6
  require 'tilt'
7
+ require 'nokogiri'
8
+
9
+
10
+ module Nokogiri
11
+ module XML
12
+ class Node
13
+
14
+ private
15
+
16
+ def coerce data # :nodoc:
17
+ if data.class.to_s == 'Roda::Component::DOM'
18
+ data = data.dom
19
+ end
20
+
21
+ case data
22
+ when XML::NodeSet
23
+ return data
24
+ when XML::DocumentFragment
25
+ return data.children
26
+ when String
27
+ return fragment(data).children
28
+ when Document, XML::Attr
29
+ # unacceptable
30
+ when XML::Node
31
+ return data
32
+ end
33
+
34
+ raise ArgumentError, <<-EOERR
35
+ Requires a Node, NodeSet or String argument, and cannot accept a #{data.class}.
36
+ (You probably want to select a node from the Document with at() or search(), or create a new Node via Node.new().)
37
+ EOERR
38
+ end
39
+ end
40
+ end
41
+ end
7
42
  end
8
43
 
9
44
  require "base64"
@@ -422,6 +457,18 @@ class Roda
422
457
 
423
458
  private
424
459
 
460
+ def from_server?
461
+ if request
462
+ !request.env.include?('HTTP_X_RODA_COMPONENT_ON_SERVER')
463
+ else
464
+ false
465
+ end
466
+ end
467
+
468
+ def from_client?
469
+ !from_server?
470
+ end
471
+
425
472
  def server?
426
473
  RUBY_ENGINE == 'ruby'
427
474
  end
@@ -129,9 +129,14 @@ class Roda
129
129
  end
130
130
 
131
131
  def method_missing method, *args, &block
132
- return if method[/\=\z/]
132
+ # respond_to?(symbol, include_all=false)
133
+ if _data.respond_to? method, true
134
+ _data.send method, *args, &block
135
+ else
136
+ return if method[/\=\z/]
133
137
 
134
- super
138
+ super
139
+ end
135
140
  end
136
141
 
137
142
  # Return hash of attributes and values.
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.25"
3
+ VERSION = "0.1.26"
4
4
  end
5
5
  end
@@ -96,13 +96,12 @@ class Roda
96
96
  end
97
97
  EOF
98
98
 
99
- loaded_component_js << ("<script>#{Opal.compile(js)}</script>")
100
-
101
99
  file_path = comp.class.instance_methods(false).map { |m|
102
100
  comp.class.instance_method(m).source_location.first
103
101
  }.uniq.first.gsub("#{Dir.pwd}/#{component_opts[:path]}", '').gsub(/\.rb\Z/, '.js')
104
102
 
105
103
  loaded_component_js << "<script type=\"text/javascript\" src=\"/#{component_opts[:assets_route]}#{file_path}\"></script>"
104
+ loaded_component_js << ("<script>#{Opal.compile(js)}</script>")
106
105
  end
107
106
 
108
107
  def component name, options = {}, &block
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-component
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.25
4
+ version: 0.1.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal