roda-component 0.1.26 → 0.1.27

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: 78dab2bcfa41cf6dd926bd00316b62a0e002f7e6
4
- data.tar.gz: 9adfd1a24eca3929430845cdc978e802712509da
3
+ metadata.gz: 34af2117ec9844c79388172c7925327234a15420
4
+ data.tar.gz: 47664199fa77227ee28102b6b3e7f0b79525f49e
5
5
  SHA512:
6
- metadata.gz: 036dbdf68ded63e356696c7e4dc7d3a6e80748965b8e298c8f84a329f526011c4bc2224ce35178982ed6f3fcad506931bff76b731cc654f22ab8c1dfbc88aada
7
- data.tar.gz: 8006ec9a03a51489fa03f931432a2e12d481907aa124a33786646b634e7fdb2dbeecbb0a6d80d9605f3293d43d9a67e285935e536463ea60d1f5ee61728691f6
6
+ metadata.gz: e1da41e5dd0a4abb369e5c51b3d6407f5dfe46686bd43e7a5f44ba1cddf75300ab2993ab485d712e815cf5418289c1bd9f0024c6d33c2e852582b2cb6eee0541
7
+ data.tar.gz: 4bf89d4fb46a3d17ecab201d12e2fc462acb3baf2410ddbd857422f1ffc45dc5ab41600644c65ff720498c146ce38e37410339590e0d3d66c7fd1fef207e0589
@@ -6,6 +6,27 @@ unless RUBY_ENGINE == 'opal'
6
6
  require 'tilt'
7
7
  require 'nokogiri'
8
8
 
9
+ # this is to fix `.maps` not using correct url.
10
+ module Opal
11
+ class Processor < Tilt::Template
12
+ def evaluate(context, locals, &block)
13
+ return Opal.compile data unless context.is_a? ::Sprockets::Context
14
+
15
+ path = context.logical_path
16
+ prerequired = []
17
+
18
+ builder = self.class.new_builder(context)
19
+ result = builder.build_str(data, path, :prerequired => prerequired)
20
+
21
+ if self.class.source_map_enabled
22
+ register_source_map(context.logical_path, result.source_map.to_s)
23
+ "#{result.to_s}\n//# sourceMappingURL=/#{Roda::Component.app.component_opts[:assets_route]}/#{context.logical_path}.map\n"
24
+ else
25
+ result.to_s
26
+ end
27
+ end
28
+ end
29
+ end
9
30
 
10
31
  module Nokogiri
11
32
  module XML
@@ -4,6 +4,14 @@ class Element
4
4
  alias_native :serialize_array, :serializeArray
5
5
  alias_native :has_class, :hasClass
6
6
  alias_native :click
7
+
8
+ def get_script url, &block
9
+ %x{
10
+ $.getScript(url, function(){
11
+ #{block.call if block_given?}
12
+ });
13
+ }
14
+ end
7
15
  end
8
16
 
9
17
  class String
@@ -1,5 +1,5 @@
1
1
  class Roda
2
2
  class Component
3
- VERSION = "0.1.26"
3
+ VERSION = "0.1.27"
4
4
  end
5
5
  end
@@ -81,26 +81,28 @@ class Roda
81
81
  options = Base64.encode64 options.to_json
82
82
  comp_name = comp.class._name
83
83
 
84
+ file_path = comp.class.instance_methods(false).map { |m|
85
+ comp.class.instance_method(m).source_location.first
86
+ }.uniq.first.gsub("#{Dir.pwd}/#{component_opts[:path]}", '').gsub(/\.rb\Z/, '.js')
87
+
84
88
  js = <<-EOF
85
89
  unless $faye
86
90
  $faye = Roda::Component::Faye.new('/faye')
87
91
  end
88
92
 
89
93
  unless $component_opts[:comp][:"#{comp_name}"]
90
- Document.ready? do
91
- c = $component_opts[:comp][:"#{comp_name}"] = #{comp.class}.new
92
- c.instance_variable_set(:@_cache, JSON.parse(Base64.decode64('#{cache}')))
93
- c.events.trigger_jquery_events
94
- c.#{action}(JSON.parse(Base64.decode64('#{options}')))
95
- end
94
+ $component_opts[:comp][:"#{comp_name}"] = true
95
+ `$.getScript("/#{component_opts[:assets_route]}#{file_path}", function(){`
96
+ Document.ready? do
97
+ c = $component_opts[:comp][:"#{comp_name}"] = #{comp.class}.new
98
+ c.instance_variable_set(:@_cache, JSON.parse(Base64.decode64('#{cache}')))
99
+ c.events.trigger_jquery_events
100
+ c.#{action}(JSON.parse(Base64.decode64('#{options}')))
101
+ end
102
+ `});`
96
103
  end
97
104
  EOF
98
105
 
99
- file_path = comp.class.instance_methods(false).map { |m|
100
- comp.class.instance_method(m).source_location.first
101
- }.uniq.first.gsub("#{Dir.pwd}/#{component_opts[:path]}", '').gsub(/\.rb\Z/, '.js')
102
-
103
- loaded_component_js << "<script type=\"text/javascript\" src=\"/#{component_opts[:assets_route]}#{file_path}\"></script>"
104
106
  loaded_component_js << ("<script>#{Opal.compile(js)}</script>")
105
107
  end
106
108
 
@@ -194,12 +196,16 @@ class Roda
194
196
  opal = Opal::Server.new do |s|
195
197
  # Append the gems path
196
198
  if scope.component_opts[:debug]
197
- s.debug = true
199
+ s.debug = true
198
200
  s.source_map = true
199
201
  else
200
202
  s.source_map = false
201
203
  end
202
204
 
205
+ # we are loading the source maps ourselves
206
+
207
+ s.prefix = "/#{scope.component_opts[:assets_route]}"
208
+
203
209
  s.append_path Gem::Specification.find_by_name("roda-component").gem_dir + '/lib'
204
210
 
205
211
  # Append the path to the components folder
@@ -217,7 +223,6 @@ class Roda
217
223
  if path[/\.rb\Z/] && js_file = scope.request.env['PATH_INFO'].scan(/(.*\.map)/)
218
224
  scope.request.env['PATH_INFO'] = path.gsub(js_file.last.first, '').gsub("/#{scope.component_opts[:assets_route]}", '')
219
225
  end
220
-
221
226
  run Opal::SourceMapServer.new(opal.sprockets, path)
222
227
  end
223
228
  end
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.26
4
+ version: 0.1.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-01 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal