opal-connect 0.0.10 → 0.0.11

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: 94cef52546df779b3d2ccd5acc12ae71da6fb5c0
4
- data.tar.gz: bbdd0a3e580573ae7ef6c1b494f442849995d489
3
+ metadata.gz: f94e4ee7aff0175252749e2f327a3c070bb07427
4
+ data.tar.gz: 1f4431064a572782d46d161225e72303951a8c40
5
5
  SHA512:
6
- metadata.gz: 96b52dbda56bb1b26a751c7f26327314596f39900ae6217a139aa7c04f0a4eb4340c0fc6357289a4e1d7de30fc3ae78b46ab501cfde965a40e370a63c2b0cc88
7
- data.tar.gz: 6771e915a15bb40841519a551b9f1649234bf0c45db6f9eac9103a32ea513bed287111132fe5be3d4b3c0a27bbfde4f8aa951028b10bcad59765312101a5ab31
6
+ metadata.gz: 9f05e1417b03caa119070db5aa499b20004b0ee07f27317a836de96d14478c9d52e9d670632f2fd93de5ea2249a9d0bda9737bf0f68f3fca3d00e5dcb8963d6b
7
+ data.tar.gz: f174ea1b0a29f06caf0034fb33dff9d976e5ce73be73a2e46b1f1d7b24eefad89cdba9ce0ba2c56da6213883c432f496b7301e3bec7a6f72941bf39f5cb409fc
data/.gitignore CHANGED
@@ -12,3 +12,6 @@
12
12
  *.o
13
13
  *.a
14
14
  mkmf.log
15
+ .connect
16
+ NERD_tree_1
17
+ node_modules
data/Gemfile CHANGED
@@ -1,4 +1,12 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
+ gem 'roda', '2.14.0'
4
+ gem 'thin', '1.6.4'
5
+ gem 'rack-unreloader', '1.5.0'
6
+ gem 'rack-livereload'
7
+ # gem 'opal-rspec', github: 'opal/opal-rspec'
8
+ gem 'pry'
9
+ gem 'awesome_print'
10
+
3
11
  # Specify your gem's dependencies in opal-connect.gemspec
4
12
  gemspec
data/Makefile ADDED
@@ -0,0 +1,2 @@
1
+ server:
2
+ bundle exec rake webpack:run& bundle exec thin start --port=3000
data/Rakefile CHANGED
@@ -1 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ $:.unshift './lib'
4
+
5
+ require './app/config/boot'
6
+ require 'opal-connect'
7
+ require 'opal/connect/rake_task'
8
+
9
+ Opal::Connect::RakeTask.new('webpack')
data/app/app.rb ADDED
@@ -0,0 +1,21 @@
1
+ require_relative 'config/connect'
2
+
3
+ class App < Roda
4
+ plugin :assets,
5
+ path: '.connect/output',
6
+ css_dir: '',
7
+ js_dir: '',
8
+ group_subdirs: false,
9
+ gzip: true,
10
+ js: { connect: [ 'opal.js', 'connect.js' ] }
11
+
12
+ use Rack::LiveReload
13
+
14
+ route do |r|
15
+ r.assets
16
+
17
+ r.root do
18
+ Components::Example.scope(self).render :display
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ class App
2
+ module Components
3
+ class Example
4
+ include Opal::Connect
5
+
6
+ def display
7
+ dom.set! html! {
8
+ html do
9
+ head do
10
+ meta charset: 'utf-8'
11
+ end
12
+
13
+ body do
14
+ div 'Example'
15
+ end
16
+ end
17
+ }
18
+
19
+ if RUBY_ENGINE == 'opal'
20
+ dom.find('body').append 'cow'
21
+ else
22
+ dom.find('html').append assets([:js, :connect])
23
+ end
24
+
25
+ dom
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ $:.unshift './app'
2
+ $:.unshift './lib'
3
+
4
+ require 'bundler'
5
+ Bundler.setup :default, ENV.fetch('RACK_ENV') { 'development' }
6
+
7
+ require 'roda'
8
+ require 'rack/unreloader'
9
+ require 'rack-livereload'
10
+
11
+ class App < Roda; end
12
+
13
+ Unreloader = Rack::Unreloader.new(subclasses: %w'Roda Roda::RodaPlugins Opal::Connect Opal::Connect::CLIENT_OPTIONS'){App}
14
+
15
+ Unreloader.require './lib/opal/connect.rb'
16
+ Unreloader.require 'app/config/connect'
17
+ Unreloader.require 'app'
18
+ Unreloader.require 'app/components/**/*'
@@ -0,0 +1,7 @@
1
+ require 'opal-connect'
2
+
3
+ Opal::Connect.setup do
4
+ options[:plugins] = [ :server, :html, :dom, :events, :scope ]
5
+ options[:livereload] = true
6
+ end
7
+
data/config.ru ADDED
@@ -0,0 +1,3 @@
1
+ require './app/config/boot'
2
+
3
+ run Unreloader
@@ -0,0 +1,16 @@
1
+ require 'opal/connect'
2
+
3
+ <% plugins.each do |path| %>
4
+ require '<%= path %>'
5
+ <% end %>
6
+
7
+ options = JSON.parse(Base64.decode64('<%= client_options %>'))
8
+ options.each { |key, value| Opal::Connect.options[key] = value }
9
+
10
+ <%= entry %>
11
+
12
+ <% files.each do |file| %>
13
+ require '<%= file %>'
14
+ <% end %>
15
+
16
+ Opal::Connect.setup
@@ -13,7 +13,7 @@ module Opal
13
13
 
14
14
  unless RUBY_ENGINE == 'opal'
15
15
  Connect::CLIENT_OPTIONS << 'current_user'
16
- connect.options[:plugin_requires] << options[:class_path]
16
+ connect.options[:requires] << options[:class_path]
17
17
  require options[:class_path]
18
18
  end
19
19
 
@@ -1,7 +1,11 @@
1
- if RUBY_ENGINE != 'opal'
1
+ if RUBY_ENGINE == 'opal'
2
+ `require("expose?$!expose?jQuery!jquery/dist/jquery.min.js")`;
3
+ else
2
4
  require 'oga'
3
5
  end
4
6
 
7
+ require 'opal-jquery'
8
+
5
9
  module Opal
6
10
  module Connect
7
11
  module ConnectPlugins
@@ -9,6 +13,11 @@ module Opal
9
13
  # A thread safe cache class, offering only #[] and #[]= methods,
10
14
  # each protected by a mutex.
11
15
  module Dom
16
+ ConnectJavascript = -> do
17
+ templates = Base64.encode64 Connect.templates.hash.to_json
18
+ "Opal::Connect.templates = JSON.parse(Base64.decode64('#{templates}'));"
19
+ end
20
+
12
21
  module ConnectClassMethods
13
22
  attr_accessor :templates
14
23
 
@@ -167,6 +176,8 @@ module Opal
167
176
 
168
177
  def attr(key, value = false)
169
178
  if value
179
+ value = value.to_s
180
+
170
181
  if node.respond_to? :set
171
182
  node.set(key, value)
172
183
  else
@@ -4,6 +4,8 @@ module Opal
4
4
  module Events
5
5
  $connect_events = ConnectCache.new if RUBY_ENGINE == 'opal'
6
6
 
7
+ ConnectJavascript = -> { "Opal::Connect.start_events unless $connect_events_started" }
8
+
7
9
  module InstanceMethods
8
10
  def connect_event_instance_variables(event, _name, _selector)
9
11
  # gives you access to this, like jquery
@@ -25,12 +25,6 @@ module Opal
25
25
  end
26
26
  end
27
27
 
28
- module ClassMethods
29
- def html!(&block)
30
- HTML::DSL.scope!(self).html!(&block).to_html
31
- end
32
- end
33
-
34
28
  # http://erikonrails.snowedin.net/?p=379
35
29
  class DSL
36
30
  def initialize(tag, *args, &block)
@@ -2,6 +2,12 @@ module Opal
2
2
  module Connect
3
3
  module ConnectPlugins
4
4
  module Server
5
+ ConnectJavascript = -> do
6
+ %{Opal::Connect.server_methods = JSON.parse(
7
+ Base64.decode64('#{Base64.encode64 Connect.server_methods.to_json}')
8
+ );}
9
+ end
10
+
5
11
  module ConnectClassMethods
6
12
  def server_methods
7
13
  @server_methods ||= ConnectCache.new
@@ -0,0 +1,6 @@
1
+ module Kernel
2
+ def puts(*args)
3
+ require 'console'
4
+ $console.log(*args)
5
+ end
6
+ end
@@ -2,43 +2,50 @@ module Opal
2
2
  module Connect
3
3
  class RakeTask
4
4
  include Rake::DSL if defined? Rake::DSL
5
-
6
- DEFAULT_OPTIONS = { port: 8080, host: '0.0.0.0' }
5
+ STUBS = %w'opal native promise console base64 json'
7
6
 
8
7
  def initialize(name = 'webpack', opts = {})
9
- options = DEFAULT_OPTIONS.merge opts
10
-
11
8
  namespace name do
12
9
  return unless defined? Opal.append_path
13
10
 
14
- Opal::Connect.write_plugins_file
15
11
  Opal::Connect.write_entry_file
16
12
 
17
13
  Opal.append_path Dir.pwd
18
14
 
19
- opal_file_path = "#{Dir.pwd}/.connect/opal.js"
15
+ write_opal_file
20
16
 
21
- unless File.exist? opal_file_path
22
- builder = Opal::Builder.new
23
- build_str = '`require("expose?$!expose?jQuery!jquery")`; require "opal"; require "opal-jquery"; require "opal/connect";'
24
- builder.build_str(build_str, '(inline)', { dynamic_require_severity: :ignore })
25
- File.write opal_file_path, builder.to_s
26
- end
17
+ envs = ENV.to_h.merge({
18
+ BUNDLE_BIN: true,
19
+ CONNECT_STUBS: STUBS.concat(Opal::Config.stubbed_files.to_a).join(','),
20
+ OPAL_LOAD_PATH: Opal.paths.join(":"),
21
+ OPAL_USE_BUNDLER: true
22
+ }).inject({}) { |env, (k, v)| env[k.to_s] = v.to_s; env }
27
23
 
28
24
  desc "Start webpack"
29
25
  task :run do
30
- exec({"OPAL_LOAD_PATH" => Opal.paths.join(":")}, "webpack-dev-server --progress -d --host #{options[:host]} --port #{options[:port]} --compress --devtool eval --progress --colors --historyApiFallback true --hot --watch")
26
+ exec(envs, 'webpack --progress --watch')
31
27
  end
32
28
 
33
29
  desc "Build webpack"
34
30
  task :build do
35
- exec({
36
- "OPAL_LOAD_PATH" => Opal.paths.join(":"),
37
- "RACK_ENV" => 'production'
38
- }, 'webpack --progress')
31
+ exec(envs, 'webpack --progress')
39
32
  end
40
33
  end
41
34
  end
35
+
36
+ def write_opal_file
37
+ file_path = "#{Dir.pwd}/.connect"
38
+ version_path = "#{file_path}/opal_version"
39
+ version = File.exist?(version_path) ? File.read(version_path) : false
40
+
41
+ if !File.exist?("#{file_path}/opal.js") || !version || (version && version != Opal::VERSION)
42
+ builder = Opal::Builder.new
43
+ build_str = STUBS.map { |stub| "require '#{stub}'" }.join(";")
44
+ builder.build_str(build_str, '(inline)', { dynamic_require_severity: :ignore })
45
+ File.write version_path, Opal::VERSION
46
+ File.write "#{file_path}/opal.js", builder.to_s
47
+ end
48
+ end
42
49
  end
43
50
  end
44
51
  end
@@ -1,5 +1,5 @@
1
1
  module Opal
2
2
  module Connect
3
- VERSION = "0.0.10"
3
+ VERSION = "0.0.11"
4
4
  end
5
5
  end
data/lib/opal/connect.rb CHANGED
@@ -1,42 +1,43 @@
1
- require "opal/connect/version"
1
+ require 'opal'
2
2
  require 'base64'
3
+ require "opal/connect/version"
3
4
 
4
5
  if RUBY_ENGINE == 'opal'
5
- module Kernel
6
- def puts(*args)
7
- require 'console'
8
- $console.log(*args)
9
- end
10
- end
6
+ require 'opal/connect/puts'
11
7
  else
8
+ require 'erb'
12
9
  Opal.append_path File.expand_path('../..', __FILE__).untaint
13
10
  end
14
11
 
15
12
  module Opal
16
13
  module Connect
17
- CLIENT_OPTIONS = %w'url plugins' unless RUBY_ENGINE == 'opal'
14
+ CLIENT_OPTIONS = %w'url plugins'
18
15
 
19
16
  class << self
20
17
  attr_accessor :pids
21
18
 
22
19
  def options
23
20
  @_options ||= Connect::ConnectCache.new(
24
- hot_reload: false,
21
+ livereload: false,
25
22
  url: '/connect',
26
23
  plugins: [],
27
24
  javascript: [],
28
- plugin_requires: [],
25
+ requires: [],
29
26
  setup_blocks: []
30
27
  )
31
28
  end
32
29
 
30
+ def client_options
31
+ Connect.options.hash.select { |key, _| CLIENT_OPTIONS.include? key.to_s }
32
+ end
33
+
33
34
  def setup(&block)
34
35
  instance_exec(&block) if block_given?
35
36
 
36
37
  # make sure we include the default plugins with connect
37
38
  options[:plugins].each { |plug| Connect.plugin plug }
38
39
 
39
- options[:setup_blocks].each { |b| Class.new { include Opal::Connect }.new.instance_exec(&b) }
40
+ options[:setup_blocks].each { |b| Class.new { include Opal::Connect }.instance_exec(&b) }
40
41
  end
41
42
 
42
43
  def included(klass)
@@ -49,33 +50,6 @@ module Opal
49
50
 
50
51
  Connect.options[:plugins].each { |plug| klass.plugin plug, :included }
51
52
  end
52
-
53
- # We need to wripte a plugins.rb file which has all the plugins required
54
- # by the server, so that the client can require them. Opal doesn't handle
55
- # dynamically generated imports, which is the reason we make a single file.
56
- def write_plugins_file
57
- path = "#{Dir.pwd}/.connect/plugins.rb"
58
- FileUtils.mkdir_p(File.dirname(path))
59
- File.open(path, 'w+') do |file|
60
- ConnectPlugins.plugins.each do |name, _|
61
- plugins_path = Connect.options[:plugins_path]
62
-
63
- if plugins_path && File.exist?("#{plugins_path}/#{name}.rb")
64
- path = "require('#{plugins_path}/#{name}')"
65
- path = "`#{path}`" if Connect.options[:hot_reload]
66
- file.puts path
67
- else
68
- file.puts "require('opal/connect/plugins/#{name}')"
69
- end
70
- end
71
-
72
- Connect.options[:plugin_requires].each do |require_path|
73
- path = "require('#{require_path}')"
74
- path = "`#{path}`" if Connect.options[:hot_reload]
75
- file.puts path
76
- end
77
- end
78
- end
79
53
  end
80
54
 
81
55
  class ConnectError < StandardError; end
@@ -136,8 +110,7 @@ module Opal
136
110
  end
137
111
 
138
112
  def self.load_plugin(name)
139
- h = @plugins
140
- unless plugin = h[name]
113
+ unless plugin = @plugins[name]
141
114
  unless RUBY_ENGINE == 'opal'
142
115
  plugins_path = Connect.options[:plugins_path]
143
116
 
@@ -147,16 +120,17 @@ module Opal
147
120
  require "opal/connect/plugins/#{name}"
148
121
  end
149
122
 
150
- raise ConnectError, "Plugin #{name} did not register itself correctly in Roda::RodaPlugins" unless plugin = h[name]
123
+ raise ConnectError, "Plugin #{name} did not register itself correctly in Opal::Connect::ConnectPlugins" unless plugin = @plugins[name]
151
124
  end
152
125
  end
126
+
153
127
  plugin
154
128
  end
155
129
 
156
- # Register the given plugin with Roda, so that it can be loaded using #plugin
130
+ # Register the given plugin with Opal::Connect, so that it can be loaded using #plugin
157
131
  # with a symbol. Should be used by plugin files. Example:
158
132
  #
159
- # Roda::RodaPlugins.register_plugin(:plugin_name, PluginModule)
133
+ # Opal::Connect::ConnectPlugins.register_plugin(:plugin_name, PluginModule)
160
134
  def self.register_plugin(name, mod)
161
135
  @plugins[name] = mod
162
136
  end
@@ -165,24 +139,12 @@ module Opal
165
139
  module InstanceMethods
166
140
  if RUBY_ENGINE != 'opal'
167
141
  def render(method, *options, &block)
168
- if hl = Connect.options[:hot_reload]
169
- Connect.write_entry_file(self, method, *options)
170
-
171
- html = "#{public_send(method, *options, &block)}"
172
-
173
- if hl.is_a?(Hash) && file_name = hl[:javascript_file_name]
174
- hl = {} unless hl.is_a? Hash
175
- hl = { host: 'http://localhost', port: 8080 }.merge hl
142
+ code = Connect.javascript(self, method, *options)
143
+ js = Opal::Builder.new.build_str(code, '(inline)').to_s
176
144
 
177
- html = "#{html}<script src='#{hl[:host]}:#{hl[:port]}/#{file_name}.js'></script>"
178
- end
179
-
180
- html
181
- else
182
- js = Connect.build Connect.javascript(self, method, *options)
145
+ Connect.write_entry_file(self, method, *options) if Connect.options[:livereload]
183
146
 
184
- "#{public_send(method, *options, &block)}<script>#{js}</script>"
185
- end
147
+ "#{public_send(method, *options, &block)}<script>#{js}</script>"
186
148
  end
187
149
  end
188
150
  end
@@ -196,9 +158,9 @@ module Opal
196
158
  if block_given?
197
159
  @_setup_block = block
198
160
  Connect.options[:setup_blocks] << @_setup_block
199
- else
200
- @_setup_block
201
161
  end
162
+
163
+ @_setup_block
202
164
  end
203
165
 
204
166
  # Load a new plugin into the current class. A plugin can be a module
@@ -244,101 +206,57 @@ module Opal
244
206
  @files ||= []
245
207
  end
246
208
 
247
- def build(code)
248
- builder = Opal::Builder.new
249
-
250
- builder.build_str(code, '(inline)').to_s
251
- end
252
-
253
- def javascript(klass, method, *options)
209
+ def javascript(klass, method, *opts)
254
210
  return unless klass
255
211
 
256
- js = []
257
- javascript = Connect.options[:javascript]
258
-
259
- if javascript.length
260
- javascript.uniq.each do |block|
261
- js << klass.instance_exec(&block)
262
- end
263
- end
212
+ js = []
213
+ options[:javascript].uniq.each { |block| js << klass.instance_exec(&block) }
264
214
 
265
215
  %{
266
- #{js.join(';')}
267
-
268
216
  Document.ready? do
217
+ #{js.join(';')}
269
218
  klass = #{klass.class.name}.new
270
-
271
- if klass.respond_to?(:#{method})
272
- klass.__send__(:#{method}, *JSON.parse(Base64.decode64('#{Base64.encode64 options.to_json}')))
273
- end
274
-
275
- Opal::Connect.start_events unless $connect_events_started
219
+ klass.__send__(:#{method}, *JSON.parse(Base64.decode64('#{Base64.encode64 opts.to_json}'))) if klass.respond_to?(:#{method})
276
220
  end
277
- } if klass.class.name
221
+ }
278
222
  end
279
223
 
280
224
  def write_entry_file(klass = false, method = false, *options)
281
- path = "#{Dir.pwd}/.connect/entry.js"
282
-
283
- required_files = Connect.files.uniq.map do |file|
284
- "`require('#{file}')`"
285
- end.join(';')
286
-
287
- client_options = Connect.options.hash.select do |key, _|
288
- CLIENT_OPTIONS.include? key.to_s
289
- end
290
-
291
- client_options = Base64.encode64 client_options.to_json
225
+ path = "#{Dir.pwd}/.connect/entry.rb"
226
+ files = Connect.files.dup.uniq.map { |file| "require '#{file}'" }.join(';')
227
+ entry = Connect.options[:entry]
228
+ client_options = Base64.encode64 Connect.client_options.to_json
229
+ plugins = plugin_paths.dup.map { |plugin_path| plugin_path = "require '#{plugin_path}'" }.join(';')
292
230
 
293
231
  code = %{
294
- options = JSON.parse(Base64.decode64('#{client_options}'));
295
- options.each do |key, value|
296
- Opal::Connect.options[key] = value
297
- end
232
+ require 'opal/connect'
233
+ #{plugins}
234
+ options = JSON.parse(Base64.decode64('#{client_options}'))
235
+ options.each { |key, value| Opal::Connect.options[key] = value }
236
+ #{entry}
237
+ #{files}
238
+ Opal::Connect.setup
298
239
  }
299
- code = "#{code} Opal::Connect.options[:plugins].each { |plug| Opal::Connect.plugin plug };"
300
-
301
- if Connect.respond_to? :templates
302
- templates = Base64.encode64 Connect.templates.hash.to_json
303
- code = "#{code} Opal::Connect.templates = JSON.parse(Base64.decode64('#{templates}'));"
304
- end
305
-
306
- code = %{#{code} Opal::Connect.server_methods = JSON.parse(
307
- Base64.decode64('#{Base64.encode64 Connect.server_methods.to_json}')
308
- );}
309
-
310
- code = "#{code} #{Connect.options[:entry]}" if Connect.options[:entry]
311
-
312
240
 
313
- if !Connect.options[:hot_reload]
314
- code = "#{code} #{required_files}"
315
- else
316
- code << %{
317
- `if (module.hot) {`
318
- `module.hot.accept()`
319
-
320
- if Opal::Connect.respond_to? :teardown_events
321
- Opal::Connect.teardown_events
322
- connect_events = $connect_events[Opal::Connect]
323
- $connect_events = Opal::Connect::ConnectCache.new
324
-
325
- if connect_events
326
- $connect_events[Opal::Connect] = connect_events
327
- end
241
+ FileUtils.mkdir_p(File.dirname(path))
242
+ File.write(path, code)
243
+ end
328
244
 
329
- $connect_events_started = false
330
- end
245
+ def plugin_paths
246
+ plugins_path = Connect.options[:plugins_path]
247
+ plugins = []
331
248
 
332
- #{required_files}
333
- #{Connect.javascript(klass, method, *options)}
334
- `}`
335
- }
249
+ ConnectPlugins.plugins.each do |name, _|
250
+ if plugins_path && File.exist?("#{plugins_path}/#{name}.rb")
251
+ plugins << "#{plugins_path}/#{name}"
252
+ else
253
+ plugins << "opal/connect/plugins/#{name}"
254
+ end
336
255
  end
337
256
 
338
- code = "#{code} Opal::Connect.options[:setup_blocks].each { |b| Class.new { include Opal::Connect }.new.instance_exec(&b) }"
257
+ Connect.options[:requires].each { |plugin_path| plugins << plugin_path }
339
258
 
340
- FileUtils.mkdir_p(File.dirname(path))
341
- File.write(path, build(code))
259
+ plugins
342
260
  end
343
261
  end
344
262
  end
data/opal-connect.gemspec CHANGED
@@ -18,9 +18,11 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "opal", ">= 0.9.2"
21
+ spec.add_dependency "opal", ">= 0.10.0.beta3"
22
22
  spec.add_dependency "opal-jquery", ">= 0.4.1"
23
23
  spec.add_dependency "oga", ">= 2.2"
24
+
24
25
  spec.add_development_dependency "bundler", "~> 1.7"
25
26
  spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "opal-rspec", ">= 0.5.0"
26
28
  end
data/package.json ADDED
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "opal-connect",
3
+ "version": "0.0.1",
4
+ "description": "",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "devDependencies": {
12
+ "expose-loader": "^0.7.1",
13
+ "jquery": "^2.2.3",
14
+ "livereload": "^0.4.1",
15
+ "opal-webpack": "1.0.6",
16
+ "webpack": "2.1.0-beta.7",
17
+ "webpack-dev-server": "2.0.0-beta",
18
+ "webpack-livereload-plugin": "^0.8.1"
19
+ }
20
+ }
data/webpack.config.js ADDED
@@ -0,0 +1,36 @@
1
+ const webpack = require('webpack');
2
+ const path = require("path");
3
+ const LiveReloadPlugin = require('webpack-livereload-plugin');
4
+ const stubs = process.env.CONNECT_STUBS.split(',');
5
+
6
+ console.log(process.env.OPAL_STUBS)
7
+
8
+ module.exports = {
9
+ entry: {
10
+ opal: './.connect/opal.js',
11
+ connect: './.connect/entry.rb',
12
+ },
13
+ output: {
14
+ path: path.resolve(__dirname, ".connect", "output"),
15
+ filename: '[name].js'
16
+ },
17
+ module: {
18
+ test: /\.rb$/,
19
+ loaders: [
20
+ {
21
+ exclude: /node_modules|\.connect\/(opal|cache)/,
22
+ loader: "opal-webpack",
23
+ query: { dynamic_require_severity: 'ignore' }
24
+ }
25
+ ]
26
+ },
27
+ watchOptions: { poll: true },
28
+ plugins: [
29
+ new LiveReloadPlugin({ ignore: '.connect' })
30
+ ],
31
+ opal: {
32
+ stubs: stubs,
33
+ cacheDirectory: '.connect/cache'
34
+ },
35
+ devtool: 'inline-source-map'
36
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opal-connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - cj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.9.2
19
+ version: 0.10.0.beta3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.9.2
26
+ version: 0.10.0.beta3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: opal-jquery
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: opal-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.5.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.5.0
83
97
  description: Connect Opal to Ruby.
84
98
  email:
85
99
  - cjlazell@gmail.com
@@ -90,10 +104,17 @@ files:
90
104
  - ".gitignore"
91
105
  - Gemfile
92
106
  - LICENSE.txt
107
+ - Makefile
93
108
  - README.md
94
109
  - Rakefile
110
+ - app/app.rb
111
+ - app/components/example.rb
112
+ - app/config/boot.rb
113
+ - app/config/connect.rb
114
+ - config.ru
95
115
  - lib/opal-connect.rb
96
116
  - lib/opal/connect.rb
117
+ - lib/opal/connect/entry.rb.erb
97
118
  - lib/opal/connect/plugins/abilities.rb
98
119
  - lib/opal/connect/plugins/current_user.rb
99
120
  - lib/opal/connect/plugins/dom.rb
@@ -103,9 +124,12 @@ files:
103
124
  - lib/opal/connect/plugins/pjax.rb
104
125
  - lib/opal/connect/plugins/scope.rb
105
126
  - lib/opal/connect/plugins/server.rb
127
+ - lib/opal/connect/puts.rb
106
128
  - lib/opal/connect/rake_task.rb
107
129
  - lib/opal/connect/version.rb
108
130
  - opal-connect.gemspec
131
+ - package.json
132
+ - webpack.config.js
109
133
  homepage: ''
110
134
  licenses:
111
135
  - MIT