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 +4 -4
- data/.gitignore +3 -0
- data/Gemfile +8 -0
- data/Makefile +2 -0
- data/Rakefile +8 -0
- data/app/app.rb +21 -0
- data/app/components/example.rb +29 -0
- data/app/config/boot.rb +18 -0
- data/app/config/connect.rb +7 -0
- data/config.ru +3 -0
- data/lib/opal/connect/entry.rb.erb +16 -0
- data/lib/opal/connect/plugins/current_user.rb +1 -1
- data/lib/opal/connect/plugins/dom.rb +12 -1
- data/lib/opal/connect/plugins/events.rb +2 -0
- data/lib/opal/connect/plugins/html.rb +0 -6
- data/lib/opal/connect/plugins/server.rb +6 -0
- data/lib/opal/connect/puts.rb +6 -0
- data/lib/opal/connect/rake_task.rb +24 -17
- data/lib/opal/connect/version.rb +1 -1
- data/lib/opal/connect.rb +55 -137
- data/opal-connect.gemspec +3 -1
- data/package.json +20 -0
- data/webpack.config.js +36 -0
- metadata +28 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f94e4ee7aff0175252749e2f327a3c070bb07427
|
4
|
+
data.tar.gz: 1f4431064a572782d46d161225e72303951a8c40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f05e1417b03caa119070db5aa499b20004b0ee07f27317a836de96d14478c9d52e9d670632f2fd93de5ea2249a9d0bda9737bf0f68f3fca3d00e5dcb8963d6b
|
7
|
+
data.tar.gz: f174ea1b0a29f06caf0034fb33dff9d976e5ce73be73a2e46b1f1d7b24eefad89cdba9ce0ba2c56da6213883c432f496b7301e3bec7a6f72941bf39f5cb409fc
|
data/.gitignore
CHANGED
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
data/Rakefile
CHANGED
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
|
data/app/config/boot.rb
ADDED
@@ -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/**/*'
|
data/config.ru
ADDED
@@ -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
|
@@ -1,7 +1,11 @@
|
|
1
|
-
if RUBY_ENGINE
|
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
|
@@ -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
|
@@ -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
|
-
|
15
|
+
write_opal_file
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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(
|
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
|
data/lib/opal/connect/version.rb
CHANGED
data/lib/opal/connect.rb
CHANGED
@@ -1,42 +1,43 @@
|
|
1
|
-
require
|
1
|
+
require 'opal'
|
2
2
|
require 'base64'
|
3
|
+
require "opal/connect/version"
|
3
4
|
|
4
5
|
if RUBY_ENGINE == 'opal'
|
5
|
-
|
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'
|
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
|
-
|
21
|
+
livereload: false,
|
25
22
|
url: '/connect',
|
26
23
|
plugins: [],
|
27
24
|
javascript: [],
|
28
|
-
|
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 }.
|
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
|
-
|
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
|
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
|
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
|
-
#
|
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
|
-
|
169
|
-
|
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
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
}
|
221
|
+
}
|
278
222
|
end
|
279
223
|
|
280
224
|
def write_entry_file(klass = false, method = false, *options)
|
281
|
-
path
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
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
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
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
|
-
|
314
|
-
|
315
|
-
|
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
|
-
|
330
|
-
|
245
|
+
def plugin_paths
|
246
|
+
plugins_path = Connect.options[:plugins_path]
|
247
|
+
plugins = []
|
331
248
|
|
332
|
-
|
333
|
-
|
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
|
-
|
257
|
+
Connect.options[:requires].each { |plugin_path| plugins << plugin_path }
|
339
258
|
|
340
|
-
|
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.
|
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.
|
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-
|
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.
|
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.
|
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
|