roda-component 0.1.25 → 0.1.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roda/component.rb +47 -0
- data/lib/roda/component/form.rb +7 -2
- data/lib/roda/component/version.rb +1 -1
- data/lib/roda/plugins/component.rb +1 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78dab2bcfa41cf6dd926bd00316b62a0e002f7e6
|
4
|
+
data.tar.gz: 9adfd1a24eca3929430845cdc978e802712509da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 036dbdf68ded63e356696c7e4dc7d3a6e80748965b8e298c8f84a329f526011c4bc2224ce35178982ed6f3fcad506931bff76b731cc654f22ab8c1dfbc88aada
|
7
|
+
data.tar.gz: 8006ec9a03a51489fa03f931432a2e12d481907aa124a33786646b634e7fdb2dbeecbb0a6d80d9605f3293d43d9a67e285935e536463ea60d1f5ee61728691f6
|
data/lib/roda/component.rb
CHANGED
@@ -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
|
data/lib/roda/component/form.rb
CHANGED
@@ -129,9 +129,14 @@ class Roda
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def method_missing method, *args, &block
|
132
|
-
|
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
|
-
|
138
|
+
super
|
139
|
+
end
|
135
140
|
end
|
136
141
|
|
137
142
|
# Return hash of attributes and values.
|
@@ -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.
|
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
|
11
|
+
date: 2015-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|