wedge 0.2.5 → 0.2.6

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: 8c93ae71aeb6b571d456229ac1c8f445b90d22d7
4
- data.tar.gz: d11d01de2de851f3a4bda2d463f763d86c6ae68e
3
+ metadata.gz: c71fcced61481b9f728755337c97887dda0694c5
4
+ data.tar.gz: 1ab6d87facb32dfc95fd4251ba172959f8eb12e7
5
5
  SHA512:
6
- metadata.gz: 8011b201963883dc776f0f5928d9d22ace4f25ef2f817170c164dc3cd5b075ca9a30cbd3818513f433cbd468614d97c5b1bad8073eec13f297ce78f18a3e91a1
7
- data.tar.gz: 164309fabb1a40652cda03ff73c2997e8e8db8466b3ba4ce45e6939e236310f80492744fef213e866cced7c68853921c9df9d0e61ddf5fb7895dcca35bbadca6
6
+ metadata.gz: a041c32b5a735350d65379a9b2e01172a49748bb91d3bedf8bb993f7d220c62685549e4622b10689bc5eebf50f6a1620336b1b27407d2909dd29a6d7355bb4db
7
+ data.tar.gz: c4a459c0dcabb30556997bc436caea9ff6f993aeec49d70ddc24685deb18933e8348aa61ef1cf9165e2f6948474531e3721dee0de1ba2038039d2c0e1833e108
@@ -1,7 +1,9 @@
1
- require 'opal'
2
- require 'opal-jquery'
1
+ unless RUBY_ENGINE == 'opal'
2
+ require 'opal'
3
+ Opal.append_path File.expand_path('../', __FILE__).untaint
4
+ end
5
+
3
6
  require 'wedge/version'
4
- require 'wedge/opal'
5
7
  require 'wedge/utilis/indifferent_hash'
6
8
  require 'wedge/utilis/hash'
7
9
  require 'wedge/utilis/blank'
@@ -12,6 +14,7 @@ require 'wedge/utilis/element'
12
14
  require 'base64'
13
15
  require 'forwardable'
14
16
  unless RUBY_ENGINE == 'opal'
17
+ require 'wedge/opal'
15
18
  require 'nokogiri'
16
19
  require 'wedge/utilis/nokogiri'
17
20
  require 'wedge/middleware'
@@ -22,7 +25,7 @@ require 'wedge/dom'
22
25
  require 'wedge/events'
23
26
  require 'wedge/config'
24
27
  require 'wedge/component'
25
- require 'wedge/railtie' if RUBY_ENGINE == 'RUBY' && defined?(Rails::Railtie)
28
+ require 'wedge/railtie' if RUBY_ENGINE != 'opal' && defined?(Rails::Railtie)
26
29
 
27
30
  class Wedge
28
31
  include Methods
@@ -214,35 +217,7 @@ class Wedge
214
217
  build(path_name, options).to_s
215
218
  end
216
219
  else
217
- # note: ?body=1 is a hack for sprockets to make source maps work # correctly.
218
- # url = "#{url}?body=1" if Wedge.config.debug
219
- cache = options[:cache_assets]
220
-
221
- if !Wedge.config.debug
222
- url ||= "#{Wedge.assets_url_with_host}/#{options[:path]}.js"
223
-
224
- `jQuery.ajax({ url: url, dataType: "script", cache: cache }).done(function() {`
225
- trigger_javascript_loaded path_name, options
226
- `}).fail(function(jqxhr, settings, exception){ window.console.log(exception); })`
227
- else
228
- url = "#{Wedge.assets_url_with_host}/wedge/list_assets.call"
229
- payload = { path_name: path_name}
230
- headers = {
231
- 'X-CSRF-TOKEN' => Element.find('meta[name=_csrf]').attr('content'),
232
- }
233
- HTTP.post(url, dataType: 'json', headers: headers, payload: payload) do |response|
234
- res = JSON.from_object(`response`)
235
-
236
- res[:body][:urls].each do |url|
237
- `jQuery.ajax({url: url, dataType: "script", cache: cache, async: false})`
238
- end
239
-
240
- code = res[:body][:code]
241
- `jQuery.globalEval(code);`
242
-
243
- trigger_javascript_loaded path_name, options
244
- end
245
- end
220
+ trigger_javascript_loaded path_name, options
246
221
  end
247
222
  end
248
223
 
@@ -150,7 +150,7 @@ class Wedge
150
150
  def wedge_on_server(m = false, &block)
151
151
  m ||= Module.new(&block)
152
152
 
153
- if server?
153
+ if RUBY_ENGINE != 'opal'
154
154
  yield if block_given?
155
155
 
156
156
  m.public_instance_methods(false).each do |meth|
@@ -1,80 +1,13 @@
1
1
  class Wedge
2
+ module Plugins
3
+ end
4
+
2
5
  # Create our own opal instance.
3
6
  Opal = ::Opal.dup
7
+ # Opal = Marshal.load(Marshal.dump(::Opal))
4
8
 
5
9
  unless RUBY_ENGINE == 'opal'
6
10
  module Opal
7
- class Builder
8
- # @return [String] Compiled javascript.
9
- def javascript
10
- to_s
11
- end
12
- end
13
-
14
- def self.original_compile(source, options = {})
15
- Compiler.new(source, options).original_compile
16
- end
17
-
18
- class Compiler
19
- alias_method :original_compile, :compile
20
- def compile
21
- @result = original_compile
22
-
23
- if defined? Wedge
24
- logical_path = self.file
25
- classes = Wedge.config.component_class
26
- comp_class = classes["#{Wedge.config.app_dir}/#{logical_path}".gsub(/\//, '__')] || classes[logical_path.gsub(/\//, '__')]
27
-
28
- if logical_path == 'wedge'
29
- compiled_data = Base64.encode64 Wedge.config.client_data.to_json
30
- # We need to merge in some data that is only set on the server.
31
- # i.e. path, assets_key etc....
32
- @result << Opal.original_compile("require '#{self.file}'; Wedge.config.data = HashObject.new(Wedge.config.data.to_h.merge JSON.parse(Base64.decode64('#{compiled_data}')))")
33
- # load all global plugins into wedge
34
- Wedge.config.plugins.each do |path|
35
- @result << Builder.build(path).to_s
36
- end
37
- elsif comp_class
38
- comp_class.config.on_compile.each { |blk| comp_class.instance_exec(true, &blk) }
39
- comp_name = comp_class.config.name
40
- compiled_data = Base64.encode64 comp_class.config.client_data.to_json
41
- js = ''
42
-
43
- js << "require '#{self.file}'; Wedge.config.component_class[:#{comp_name}].config.data = HashObject.new(Wedge.config.component_class[:#{comp_name}].config.data.to_h.merge JSON.parse(Base64.decode64('#{compiled_data}')))"
44
- # todo: discuss: pass plugin settings that were set server side?
45
- js << "; Wedge.plugin(:#{comp_name.to_s.gsub(/_plugin$/, '')})" if comp_class.config.is_plugin
46
-
47
- @result << Opal.original_compile(js)
48
-
49
- if compile_str = comp_class.config.compile_str
50
- @result << compile_str
51
- end
52
-
53
- load_requires logical_path
54
- end
55
- end
56
-
57
- @result
58
- end
59
-
60
- def load_requires path_name
61
- if requires = Wedge.config.requires[path_name.gsub(/\//, '__')]
62
- requires.each do |path|
63
- next unless comp_class = Wedge.config.component_class[path]
64
-
65
- comp_class.config.on_compile.each { |blk| comp_class.instance_eval(&blk) }
66
-
67
- comp_name = comp_class.config.name
68
- compiled_data = Base64.encode64 comp_class.config.client_data.to_json
69
-
70
- load_requires path
71
-
72
- @result << Opal.original_compile("require '#{path}'; Wedge.config.component_class[:#{comp_name}].config.data = HashObject.new(Wedge.config.component_class[:#{comp_name}].config.data.to_h.merge JSON.parse(Base64.decode64('#{compiled_data}')))")
73
- end
74
- end
75
- end
76
- end
77
-
78
11
  class Server
79
12
  attr_accessor :headers, :gzip
80
13
 
@@ -165,24 +98,5 @@ if RUBY_ENGINE == 'opal'
165
98
  alias_native :replace_with, :replaceWith
166
99
  # alias_native :selectize
167
100
  end
168
- else
169
- # issue:
170
- # Wedge::Opal.use_gem 'wedge'
171
- # NoMethodError: method `runtime_dependencies' for nil:NilClass
172
- # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `require_paths_for_gem'
173
- # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:37:in `block in require_paths_for_gem'
174
- # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `each'
175
- # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:36:in `require_paths_for_gem'
176
- # /home/rof/cache/bundler/ruby/2.1.0/bundler/gems/opal-921df0c1dcf0/lib/opal/paths.rb:27:in `use_gem'
177
- # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge/opal.rb:92:in `<top (required)>'
178
- # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge.rb:1:in `require'
179
- # /home/rof/cache/bundler/ruby/2.1.0/gems/wedge-0.1.29/lib/wedge.rb:1:in `<top (required)>'
180
- # /home/rof/src/github.com/acdcorp/autolink.cuba/app/config/boot.rb:10:in `require'
181
- # /home/rof/src/github.com/acdcorp/autolink.cuba/app/config/boot.rb:10:in `<top (required)>'
182
- # /home/rof/src/github.com/acdcorp/autolink.cuba/Rakefile:15:in `require'
183
- # /home/rof/src/github.com/acdcorp/autolink.cuba/Rakefile:15:in `<top (required)>'
184
- # (See full trace by running task with --trace)
185
- # make: *** [test] Error 1
186
- Wedge::Opal.append_path Wedge.method(:version).source_location.first.sub('wedge/opal.rb', '')
187
101
  end
188
102
 
@@ -1,3 +1,3 @@
1
1
  class Wedge
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wedge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-18 00:00:00.000000000 Z
11
+ date: 2016-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal-jquery