hyper-mesh 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +34 -0
- data/README.md +10 -11
- data/docs/activerecord_api.md +55 -39
- data/docs/authorization-policies.md +62 -19
- data/docs/client_side_scoping.md +1 -1
- data/docs/word_game.md +26 -0
- data/examples/action-cable-production-mode/.gitignore +21 -0
- data/examples/action-cable-production-mode/Gemfile +57 -0
- data/examples/action-cable-production-mode/Gemfile.lock +231 -0
- data/examples/action-cable-production-mode/README.md +24 -0
- data/examples/action-cable-production-mode/Rakefile +6 -0
- data/examples/action-cable-production-mode/app/assets/config/manifest.js +3 -0
- data/examples/action-cable-production-mode/app/assets/images/.keep +0 -0
- data/examples/action-cable-production-mode/app/assets/javascripts/application.js +20 -0
- data/examples/action-cable-production-mode/app/assets/javascripts/cable.js +13 -0
- data/examples/action-cable-production-mode/app/assets/javascripts/channels/.keep +0 -0
- data/examples/action-cable-production-mode/app/assets/stylesheets/application.css +15 -0
- data/examples/action-cable-production-mode/app/channels/application_cable/channel.rb +4 -0
- data/examples/action-cable-production-mode/app/channels/application_cable/connection.rb +4 -0
- data/examples/action-cable-production-mode/app/controllers/application_controller.rb +3 -0
- data/examples/action-cable-production-mode/app/controllers/test_controller.rb +5 -0
- data/examples/action-cable-production-mode/app/models/models.rb +2 -0
- data/examples/action-cable-production-mode/app/models/public/application_record.rb +3 -0
- data/examples/action-cable-production-mode/app/models/public/word.rb +2 -0
- data/examples/action-cable-production-mode/app/policies/application_policy.rb +14 -0
- data/examples/action-cable-production-mode/app/views/components.rb +16 -0
- data/examples/action-cable-production-mode/app/views/components/app.rb +18 -0
- data/examples/action-cable-production-mode/app/views/layouts/application.html.erb +14 -0
- data/examples/action-cable-production-mode/bin/bundle +3 -0
- data/examples/action-cable-production-mode/bin/rails +9 -0
- data/examples/action-cable-production-mode/bin/rake +9 -0
- data/examples/action-cable-production-mode/bin/setup +34 -0
- data/examples/action-cable-production-mode/bin/spring +16 -0
- data/examples/action-cable-production-mode/bin/update +29 -0
- data/examples/action-cable-production-mode/config.ru +5 -0
- data/examples/action-cable-production-mode/config/application.rb +18 -0
- data/examples/action-cable-production-mode/config/boot.rb +3 -0
- data/examples/action-cable-production-mode/config/cable.yml +9 -0
- data/examples/action-cable-production-mode/config/database.yml +25 -0
- data/examples/action-cable-production-mode/config/environment.rb +5 -0
- data/examples/action-cable-production-mode/config/environments/development.rb +56 -0
- data/examples/action-cable-production-mode/config/environments/production.rb +89 -0
- data/examples/action-cable-production-mode/config/environments/test.rb +42 -0
- data/examples/action-cable-production-mode/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/action-cable-production-mode/config/initializers/assets.rb +11 -0
- data/examples/action-cable-production-mode/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/action-cable-production-mode/config/initializers/cookies_serializer.rb +5 -0
- data/examples/action-cable-production-mode/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/action-cable-production-mode/config/initializers/hyper_mesh.rb +4 -0
- data/examples/action-cable-production-mode/config/initializers/inflections.rb +16 -0
- data/examples/action-cable-production-mode/config/initializers/mime_types.rb +4 -0
- data/examples/action-cable-production-mode/config/initializers/new_framework_defaults.rb +24 -0
- data/examples/action-cable-production-mode/config/initializers/session_store.rb +3 -0
- data/examples/action-cable-production-mode/config/initializers/wrap_parameters.rb +14 -0
- data/examples/action-cable-production-mode/config/locales/en.yml +23 -0
- data/examples/action-cable-production-mode/config/puma.rb +47 -0
- data/examples/action-cable-production-mode/config/routes.rb +5 -0
- data/examples/action-cable-production-mode/config/secrets.yml +22 -0
- data/examples/action-cable-production-mode/config/spring.rb +6 -0
- data/examples/action-cable-production-mode/db/migrate/20161114213840_create_words.rb +9 -0
- data/examples/action-cable-production-mode/db/schema.rb +34 -0
- data/examples/action-cable-production-mode/db/seeds.rb +7 -0
- data/examples/action-cable-production-mode/lib/assets/.keep +0 -0
- data/examples/action-cable-production-mode/lib/tasks/.keep +0 -0
- data/examples/action-cable-production-mode/log/.keep +0 -0
- data/examples/action-cable-production-mode/public/404.html +67 -0
- data/examples/action-cable-production-mode/public/422.html +67 -0
- data/examples/action-cable-production-mode/public/500.html +66 -0
- data/examples/action-cable-production-mode/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/action-cable-production-mode/public/apple-touch-icon.png +0 -0
- data/examples/action-cable-production-mode/public/assets/.sprockets-manifest-3e9abd3ee8ba47c39a55b61ae37ed9e1.json +1 -0
- data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js +50 -0
- data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js.gz +0 -0
- data/examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css +0 -0
- data/examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz +0 -0
- data/examples/action-cable-production-mode/public/favicon.ico +0 -0
- data/examples/action-cable-production-mode/public/robots.txt +5 -0
- data/examples/action-cable-production-mode/test/controllers/.keep +0 -0
- data/examples/action-cable-production-mode/test/fixtures/.keep +0 -0
- data/examples/action-cable-production-mode/test/fixtures/files/.keep +0 -0
- data/examples/action-cable-production-mode/test/fixtures/words.yml +7 -0
- data/examples/action-cable-production-mode/test/helpers/.keep +0 -0
- data/examples/action-cable-production-mode/test/integration/.keep +0 -0
- data/examples/action-cable-production-mode/test/mailers/.keep +0 -0
- data/examples/action-cable-production-mode/test/models/.keep +0 -0
- data/examples/action-cable-production-mode/test/models/word_test.rb +7 -0
- data/examples/action-cable-production-mode/test/test_helper.rb +10 -0
- data/examples/action-cable-production-mode/tmp/.keep +0 -0
- data/examples/action-cable-production-mode/vendor/assets/javascripts/.keep +0 -0
- data/examples/action-cable-production-mode/vendor/assets/stylesheets/.keep +0 -0
- data/examples/action-cable/app/views/layouts/application.html.erb +1 -1
- data/examples/pusher-fake/app/views/layouts/application.html.erb +1 -1
- data/examples/pusher/app/views/layouts/application.html.erb +1 -1
- data/examples/simple-poller/app/views/layouts/application.html.erb +1 -1
- data/examples/word-game/.gitignore +21 -0
- data/examples/word-game/Gemfile +57 -0
- data/examples/word-game/Gemfile.lock +241 -0
- data/examples/word-game/README.md +24 -0
- data/examples/word-game/Rakefile +6 -0
- data/examples/word-game/app/assets/config/manifest.js +3 -0
- data/examples/word-game/app/assets/images/.keep +0 -0
- data/examples/word-game/app/assets/javascripts/application.js +20 -0
- data/examples/word-game/app/assets/javascripts/cable.js +13 -0
- data/examples/word-game/app/assets/javascripts/channels/.keep +0 -0
- data/examples/word-game/app/assets/stylesheets/application.css +15 -0
- data/examples/word-game/app/channels/application_cable/channel.rb +4 -0
- data/examples/word-game/app/channels/application_cable/connection.rb +4 -0
- data/examples/word-game/app/controllers/application_controller.rb +3 -0
- data/examples/word-game/app/controllers/concerns/.keep +0 -0
- data/examples/word-game/app/helpers/application_helper.rb +2 -0
- data/examples/word-game/app/jobs/application_job.rb +2 -0
- data/examples/word-game/app/mailers/application_mailer.rb +4 -0
- data/examples/word-game/app/models/application_record.rb +3 -0
- data/examples/word-game/app/models/concerns/.keep +0 -0
- data/examples/word-game/app/models/models.rb +2 -0
- data/examples/word-game/app/models/public/.keep +0 -0
- data/examples/word-game/app/policies/application_policy.rb +14 -0
- data/examples/word-game/app/views/components.rb +16 -0
- data/examples/word-game/app/views/components/.keep +0 -0
- data/examples/word-game/app/views/layouts/application.html.erb +14 -0
- data/examples/{action-cable → word-game}/app/views/layouts/mailer.html.erb +0 -0
- data/examples/{action-cable → word-game}/app/views/layouts/mailer.text.erb +0 -0
- data/examples/word-game/bin/bundle +3 -0
- data/examples/word-game/bin/rails +9 -0
- data/examples/word-game/bin/rake +9 -0
- data/examples/word-game/bin/setup +34 -0
- data/examples/word-game/bin/spring +16 -0
- data/examples/word-game/bin/update +29 -0
- data/examples/word-game/config.ru +5 -0
- data/examples/word-game/config/application.rb +20 -0
- data/examples/word-game/config/boot.rb +3 -0
- data/examples/word-game/config/cable.yml +9 -0
- data/examples/word-game/config/database.yml +25 -0
- data/examples/word-game/config/environment.rb +5 -0
- data/examples/word-game/config/environments/development.rb +56 -0
- data/examples/word-game/config/environments/production.rb +86 -0
- data/examples/word-game/config/environments/test.rb +42 -0
- data/examples/word-game/config/initializers/application_controller_renderer.rb +6 -0
- data/examples/word-game/config/initializers/assets.rb +11 -0
- data/examples/word-game/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/word-game/config/initializers/cookies_serializer.rb +5 -0
- data/examples/word-game/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/word-game/config/initializers/hyper_mesh.rb +4 -0
- data/examples/word-game/config/initializers/inflections.rb +16 -0
- data/examples/word-game/config/initializers/mime_types.rb +4 -0
- data/examples/word-game/config/initializers/new_framework_defaults.rb +24 -0
- data/examples/word-game/config/initializers/session_store.rb +3 -0
- data/examples/word-game/config/initializers/wrap_parameters.rb +14 -0
- data/examples/word-game/config/locales/en.yml +23 -0
- data/examples/word-game/config/puma.rb +47 -0
- data/examples/word-game/config/routes.rb +4 -0
- data/examples/word-game/config/secrets.yml +22 -0
- data/examples/word-game/config/spring.rb +6 -0
- data/examples/word-game/db/seeds.rb +7 -0
- data/examples/word-game/lib/assets/.keep +0 -0
- data/examples/word-game/lib/tasks/.keep +0 -0
- data/examples/word-game/log/.keep +0 -0
- data/examples/word-game/public/404.html +67 -0
- data/examples/word-game/public/422.html +67 -0
- data/examples/word-game/public/500.html +66 -0
- data/examples/word-game/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/word-game/public/apple-touch-icon.png +0 -0
- data/examples/word-game/public/favicon.ico +0 -0
- data/examples/word-game/public/robots.txt +5 -0
- data/examples/word-game/test/controllers/.keep +0 -0
- data/examples/word-game/test/fixtures/.keep +0 -0
- data/examples/word-game/test/fixtures/files/.keep +0 -0
- data/examples/word-game/test/helpers/.keep +0 -0
- data/examples/word-game/test/integration/.keep +0 -0
- data/examples/word-game/test/mailers/.keep +0 -0
- data/examples/word-game/test/models/.keep +0 -0
- data/examples/word-game/test/test_helper.rb +10 -0
- data/examples/word-game/tmp/.keep +0 -0
- data/examples/word-game/vendor/assets/javascripts/.keep +0 -0
- data/examples/word-game/vendor/assets/stylesheets/.keep +0 -0
- data/lib/active_record_base.rb +20 -1
- data/lib/hyper-mesh.rb +1 -0
- data/lib/hypermesh/version.rb +1 -1
- data/lib/kernel/itself.rb +5 -0
- data/lib/reactive_record/active_record/class_methods.rb +87 -11
- data/lib/reactive_record/active_record/instance_methods.rb +4 -2
- data/lib/reactive_record/active_record/reactive_record/collection.rb +9 -12
- data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +52 -52
- data/lib/reactive_record/active_record/reactive_record/while_loading.rb +2 -3
- data/lib/reactive_record/scope_description.rb +8 -3
- data/lib/synchromesh/client_drivers.rb +1 -9
- data/lib/synchromesh/connection.rb +2 -2
- data/lib/synchromesh/synchromesh.rb +4 -4
- data/spec/reactive_record/auto_load_itself_spec.rb +24 -0
- data/spec/reactive_record/finder_method_spec.rb +67 -0
- data/spec/reactive_record/save_while_loading_spec.rb +44 -0
- data/spec/reactive_record/update_associations_spec.rb +0 -1
- data/spec/reactive_record/update_scopes_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -0
- data/spec/synchromesh/examples/random_examples.rb +33 -0
- metadata +176 -10
- data/examples/pusher-fake/app/views/layouts/mailer.html.erb +0 -13
- data/examples/pusher-fake/app/views/layouts/mailer.text.erb +0 -1
- data/examples/pusher/app/views/layouts/mailer.html.erb +0 -13
- data/examples/pusher/app/views/layouts/mailer.text.erb +0 -1
- data/examples/simple-poller/app/views/layouts/mailer.html.erb +0 -13
- data/examples/simple-poller/app/views/layouts/mailer.text.erb +0 -1
@@ -6,17 +6,22 @@ module ReactiveRecord
|
|
6
6
|
class ScopeDescription
|
7
7
|
def initialize(model, name, opts)
|
8
8
|
sself = self
|
9
|
-
model.singleton_class.send(:define_method, "_#{name}_synchromesh_scope_description_") do
|
10
|
-
sself
|
11
|
-
end
|
12
9
|
@filter_proc = filter_proc(opts)
|
13
10
|
@name = name
|
11
|
+
model.singleton_class.send(:define_method, "_#{@name}_synchromesh_scope_description_") do
|
12
|
+
sself
|
13
|
+
end
|
14
14
|
@model = model
|
15
15
|
build_joins opts[:joins]
|
16
16
|
end
|
17
17
|
|
18
|
+
attr_reader :name
|
19
|
+
|
18
20
|
def self.find(target_model, name)
|
21
|
+
name = name.gsub(/!$/,'')
|
19
22
|
target_model.send "_#{name}_synchromesh_scope_description_"
|
23
|
+
rescue
|
24
|
+
nil
|
20
25
|
end
|
21
26
|
|
22
27
|
def filter?
|
@@ -171,7 +171,6 @@ module HyperMesh
|
|
171
171
|
def merge_current_values(br)
|
172
172
|
current_values = Hash[*@previous_changes.collect do |attr, values|
|
173
173
|
value = attr == :id ? record[:id] : values.first
|
174
|
-
begin
|
175
174
|
if br.attributes.key?(attr) &&
|
176
175
|
br.attributes[attr] != br.convert(attr, value) &&
|
177
176
|
br.attributes[attr] != br.convert(attr, values.last)
|
@@ -179,16 +178,9 @@ module HyperMesh
|
|
179
178
|
"local value: #{br.attributes[attr]} remote value: #{br.convert(attr, value)}->#{br.convert(attr, values.last)}"
|
180
179
|
return nil
|
181
180
|
end
|
182
|
-
rescue Exception => e
|
183
|
-
debugger
|
184
|
-
nil
|
185
|
-
end
|
186
181
|
[attr, value]
|
187
182
|
end.compact.flatten].merge(br.attributes)
|
188
183
|
klass._react_param_conversion(current_values)
|
189
|
-
rescue Exception => e
|
190
|
-
debugger
|
191
|
-
nil
|
192
184
|
end
|
193
185
|
end
|
194
186
|
end
|
@@ -350,7 +342,7 @@ module HyperMesh
|
|
350
342
|
elsif opts[:transport] == :simple_poller
|
351
343
|
opts[:auto_connect].each { |channel| IncomingBroadcast.add_connection(*channel) }
|
352
344
|
every(opts[:seconds_between_poll]) do
|
353
|
-
get_queued_data(:read, nil, headers: {'X-SYNCHROMESH-SILENT-REQUEST'
|
345
|
+
get_queued_data(:read, nil, headers: {'X-SYNCHROMESH-SILENT-REQUEST' => true })
|
354
346
|
end
|
355
347
|
end
|
356
348
|
end
|
@@ -2,7 +2,7 @@ module HyperMesh
|
|
2
2
|
module AutoCreate
|
3
3
|
def needs_init?
|
4
4
|
return true unless connection.tables.include?(table_name)
|
5
|
-
return false
|
5
|
+
return false unless HyperMesh.on_server?
|
6
6
|
return true if defined?(Rails::Server)
|
7
7
|
return true unless Connection.root_path
|
8
8
|
uri = URI("#{Connection.root_path}server_up")
|
@@ -104,7 +104,7 @@ module HyperMesh
|
|
104
104
|
attr_accessor :transport
|
105
105
|
|
106
106
|
def active
|
107
|
-
|
107
|
+
if HyperMesh.on_server?
|
108
108
|
expired.delete_all
|
109
109
|
refresh_connections if needs_refresh?
|
110
110
|
end
|
@@ -89,7 +89,7 @@ module HyperMesh
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.send(channel, data)
|
92
|
-
if
|
92
|
+
if !on_server?
|
93
93
|
send_to_server(channel, data)
|
94
94
|
elsif transport == :pusher
|
95
95
|
pusher.trigger("#{HyperMesh.channel}-#{data[1][:channel]}", *data)
|
@@ -98,8 +98,8 @@ module HyperMesh
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
-
def self.
|
102
|
-
|
101
|
+
def self.on_server?
|
102
|
+
Rails.const_defined? 'Server'
|
103
103
|
end
|
104
104
|
|
105
105
|
def self.send_to_server(channel, data)
|
@@ -145,7 +145,7 @@ module HyperMesh
|
|
145
145
|
|
146
146
|
def self.after_commit(operation, model)
|
147
147
|
InternalPolicy.regulate_broadcast(model) do |data|
|
148
|
-
if HyperMesh.
|
148
|
+
if !HyperMesh.on_server? && Connection.root_path
|
149
149
|
HyperMesh.send_to_server(data[:channel], [operation, data])
|
150
150
|
else
|
151
151
|
Connection.send_to_channel(data[:channel], [operation, data])
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'synchromesh/integration/test_components'
|
3
|
+
|
4
|
+
describe "HyperMesh.load", js: true do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# spec_helper resets the policy system after each test so we have to setup
|
8
|
+
# before each test
|
9
|
+
stub_const 'TestApplication', Class.new
|
10
|
+
stub_const 'TestApplicationPolicy', Class.new
|
11
|
+
TestApplicationPolicy.class_eval do
|
12
|
+
always_allow_connection
|
13
|
+
regulate_all_broadcasts { |policy| policy.send_all }
|
14
|
+
end
|
15
|
+
size_window(:small, :portrait)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "uses itself to force loading" do
|
19
|
+
user = FactoryGirl.create(:user, first_name: 'Ima')
|
20
|
+
expect_promise do
|
21
|
+
HyperMesh.load { User.find_by_first_name('Ima') }.then { |user| user.id }
|
22
|
+
end.to eq(user.id)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'synchromesh/integration/test_components'
|
3
|
+
require 'rspec-steps'
|
4
|
+
|
5
|
+
|
6
|
+
RSpec::Steps.steps "finder_method", js: true do
|
7
|
+
|
8
|
+
before(:step) do
|
9
|
+
# spec_helper resets the policy system after each test so we have to setup
|
10
|
+
# before each test
|
11
|
+
stub_const 'TestApplication', Class.new
|
12
|
+
stub_const 'TestApplicationPolicy', Class.new
|
13
|
+
TestApplicationPolicy.class_eval do
|
14
|
+
always_allow_connection
|
15
|
+
regulate_all_broadcasts { |policy| policy.send_all }
|
16
|
+
end
|
17
|
+
isomorphic do
|
18
|
+
Todo.class_eval do
|
19
|
+
class << self
|
20
|
+
attr_accessor :current_random_value
|
21
|
+
end
|
22
|
+
finder_method :random_item do |i|
|
23
|
+
find(current_random_value + i.to_i)
|
24
|
+
end
|
25
|
+
scope :test_scope, -> { all }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
size_window(:small, :portrait)
|
29
|
+
5.times { FactoryGirl.create(:todo) }
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the correct value" do
|
33
|
+
Todo.current_random_value = 1
|
34
|
+
expect_promise do
|
35
|
+
HyperMesh.load { Todo.random_item(2) }.then { |todo| todo.id }
|
36
|
+
end.to eq(3)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "returns the correct value on the server too" do
|
40
|
+
Todo.current_random_value = 1
|
41
|
+
expect(Todo.random_item(2).id).to eq(3)
|
42
|
+
end
|
43
|
+
|
44
|
+
it "will not reload the value unless forced" do
|
45
|
+
Todo.current_random_value = 2
|
46
|
+
expect_promise do
|
47
|
+
HyperMesh.load { Todo.random_item(2) }.then { |todo| todo.id }
|
48
|
+
end.to eq(3)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "can be forced to reload the value" do
|
52
|
+
expect_promise do
|
53
|
+
current_value = Todo.random_item(2).id
|
54
|
+
HyperMesh.load do
|
55
|
+
new_value = Todo.random_item(2).id
|
56
|
+
Todo.random_item!(2) if current_value == new_value
|
57
|
+
new_value
|
58
|
+
end
|
59
|
+
end.to eq(4)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "can apply to a nested scope" do
|
63
|
+
expect_promise do
|
64
|
+
HyperMesh.load { Todo.test_scope.random_item(2) }.then { |todo| todo.id }
|
65
|
+
end.to eq(4)
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'synchromesh/integration/test_components'
|
3
|
+
|
4
|
+
describe "save while loading", js: true do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
# spec_helper resets the policy system after each test so we have to setup
|
8
|
+
# before each test
|
9
|
+
stub_const 'TestApplication', Class.new
|
10
|
+
stub_const 'TestApplicationPolicy', Class.new
|
11
|
+
TestApplicationPolicy.class_eval do
|
12
|
+
always_allow_connection
|
13
|
+
regulate_all_broadcasts { |policy| policy.send_all }
|
14
|
+
#allow_change(to: User, on: [:update]) { true }
|
15
|
+
allow_change(to: :all, on: [:create, :update, :destroy]) { true }
|
16
|
+
end
|
17
|
+
size_window(:small, :portrait)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "with new and create" do
|
21
|
+
user = FactoryGirl.create(:user, first_name: 'Ima')
|
22
|
+
expect_promise do
|
23
|
+
TodoItem.create(user: User.find_by_first_name('Ima'))
|
24
|
+
end.to include('success' => true)
|
25
|
+
expect(user.todo_items).to eq([TodoItem.first])
|
26
|
+
end
|
27
|
+
it "with push" do
|
28
|
+
user = FactoryGirl.create(:user, first_name: 'Ima')
|
29
|
+
expect_promise do
|
30
|
+
User.find(1).todo_items << TodoItem.new
|
31
|
+
User.find(1).save
|
32
|
+
end.to include('success' => true)
|
33
|
+
expect(user.todo_items).to eq([TodoItem.first])
|
34
|
+
end
|
35
|
+
it "with assignment" do
|
36
|
+
user = FactoryGirl.create(:user, first_name: 'Ima')
|
37
|
+
expect_promise do
|
38
|
+
todo = TodoItem.new
|
39
|
+
todo.user = User.find_by_first_name('Ima')
|
40
|
+
todo.save
|
41
|
+
end.to include('success' => true)
|
42
|
+
expect(user.todo_items).to eq([TodoItem.first])
|
43
|
+
end
|
44
|
+
end
|
@@ -139,7 +139,6 @@ RSpec::Steps.steps "updating associations", js: true do
|
|
139
139
|
ReactiveRecord.load do
|
140
140
|
User.find_by_first_name("Jan").todo_items.collect { |item| item.itself }.first
|
141
141
|
end.then do | first |
|
142
|
-
ReactiveRecord::Collection.hypertrace instrument: :all
|
143
142
|
first.destroy.then do |response|
|
144
143
|
User.find_by_first_name("Jan").todo_items.all
|
145
144
|
end
|
@@ -44,7 +44,7 @@ RSpec::Steps.steps "updating scopes", js: true do
|
|
44
44
|
while count > 0
|
45
45
|
expect(page).to have_content("TodoItem.count = #{count}")
|
46
46
|
evaluate_ruby do
|
47
|
-
ReactiveRecord.load { TodoItem.last
|
47
|
+
ReactiveRecord.load { TodoItem.last }.then { |todo| todo.destroy }
|
48
48
|
end
|
49
49
|
count -= 1
|
50
50
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -37,6 +37,39 @@ describe "random examples", js: true do
|
|
37
37
|
pause
|
38
38
|
end
|
39
39
|
|
40
|
+
it "pass a native hash as a param" do
|
41
|
+
mount "Tester" do
|
42
|
+
|
43
|
+
class React::RenderingContext
|
44
|
+
def self.remove_nodes_from_args(args)
|
45
|
+
args[0].each do |key, value|
|
46
|
+
begin
|
47
|
+
value.as_node if value.is_a?(Element)
|
48
|
+
rescue Exception
|
49
|
+
end
|
50
|
+
end if args[0] && args[0].is_a?(Hash)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class HelloWorld < React::Component::Base
|
55
|
+
param :hash
|
56
|
+
render do
|
57
|
+
debugger
|
58
|
+
"hash[key] = #{`#{params.hash['key']}`}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
class Tester < React::Component::Base
|
63
|
+
def render
|
64
|
+
HelloWorld(hash: `{key: 'the key'}`)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
page.should have_content("hash[key] = 'the key'")
|
69
|
+
pause
|
70
|
+
end
|
71
|
+
|
72
|
+
|
40
73
|
it "can destroy on the fly" do
|
41
74
|
|
42
75
|
5.times do |i|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyper-mesh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mitch VanDuyn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -586,6 +586,7 @@ files:
|
|
586
586
|
- ".rspec"
|
587
587
|
- ".rubocop.yml"
|
588
588
|
- ".travis.yml"
|
589
|
+
- CHANGELOG.md
|
589
590
|
- CODE_OF_CONDUCT.md
|
590
591
|
- Gemfile
|
591
592
|
- LICENSE.txt
|
@@ -606,7 +607,92 @@ files:
|
|
606
607
|
- docs/pusher_quickstart.md
|
607
608
|
- docs/simple_poller_quickstart.md
|
608
609
|
- docs/todo-example.md
|
610
|
+
- docs/word_game.md
|
609
611
|
- docs/words-example.md
|
612
|
+
- examples/action-cable-production-mode/.gitignore
|
613
|
+
- examples/action-cable-production-mode/Gemfile
|
614
|
+
- examples/action-cable-production-mode/Gemfile.lock
|
615
|
+
- examples/action-cable-production-mode/README.md
|
616
|
+
- examples/action-cable-production-mode/Rakefile
|
617
|
+
- examples/action-cable-production-mode/app/assets/config/manifest.js
|
618
|
+
- examples/action-cable-production-mode/app/assets/images/.keep
|
619
|
+
- examples/action-cable-production-mode/app/assets/javascripts/application.js
|
620
|
+
- examples/action-cable-production-mode/app/assets/javascripts/cable.js
|
621
|
+
- examples/action-cable-production-mode/app/assets/javascripts/channels/.keep
|
622
|
+
- examples/action-cable-production-mode/app/assets/stylesheets/application.css
|
623
|
+
- examples/action-cable-production-mode/app/channels/application_cable/channel.rb
|
624
|
+
- examples/action-cable-production-mode/app/channels/application_cable/connection.rb
|
625
|
+
- examples/action-cable-production-mode/app/controllers/application_controller.rb
|
626
|
+
- examples/action-cable-production-mode/app/controllers/test_controller.rb
|
627
|
+
- examples/action-cable-production-mode/app/models/models.rb
|
628
|
+
- examples/action-cable-production-mode/app/models/public/application_record.rb
|
629
|
+
- examples/action-cable-production-mode/app/models/public/word.rb
|
630
|
+
- examples/action-cable-production-mode/app/policies/application_policy.rb
|
631
|
+
- examples/action-cable-production-mode/app/views/components.rb
|
632
|
+
- examples/action-cable-production-mode/app/views/components/app.rb
|
633
|
+
- examples/action-cable-production-mode/app/views/layouts/application.html.erb
|
634
|
+
- examples/action-cable-production-mode/bin/bundle
|
635
|
+
- examples/action-cable-production-mode/bin/rails
|
636
|
+
- examples/action-cable-production-mode/bin/rake
|
637
|
+
- examples/action-cable-production-mode/bin/setup
|
638
|
+
- examples/action-cable-production-mode/bin/spring
|
639
|
+
- examples/action-cable-production-mode/bin/update
|
640
|
+
- examples/action-cable-production-mode/config.ru
|
641
|
+
- examples/action-cable-production-mode/config/application.rb
|
642
|
+
- examples/action-cable-production-mode/config/boot.rb
|
643
|
+
- examples/action-cable-production-mode/config/cable.yml
|
644
|
+
- examples/action-cable-production-mode/config/database.yml
|
645
|
+
- examples/action-cable-production-mode/config/environment.rb
|
646
|
+
- examples/action-cable-production-mode/config/environments/development.rb
|
647
|
+
- examples/action-cable-production-mode/config/environments/production.rb
|
648
|
+
- examples/action-cable-production-mode/config/environments/test.rb
|
649
|
+
- examples/action-cable-production-mode/config/initializers/application_controller_renderer.rb
|
650
|
+
- examples/action-cable-production-mode/config/initializers/assets.rb
|
651
|
+
- examples/action-cable-production-mode/config/initializers/backtrace_silencers.rb
|
652
|
+
- examples/action-cable-production-mode/config/initializers/cookies_serializer.rb
|
653
|
+
- examples/action-cable-production-mode/config/initializers/filter_parameter_logging.rb
|
654
|
+
- examples/action-cable-production-mode/config/initializers/hyper_mesh.rb
|
655
|
+
- examples/action-cable-production-mode/config/initializers/inflections.rb
|
656
|
+
- examples/action-cable-production-mode/config/initializers/mime_types.rb
|
657
|
+
- examples/action-cable-production-mode/config/initializers/new_framework_defaults.rb
|
658
|
+
- examples/action-cable-production-mode/config/initializers/session_store.rb
|
659
|
+
- examples/action-cable-production-mode/config/initializers/wrap_parameters.rb
|
660
|
+
- examples/action-cable-production-mode/config/locales/en.yml
|
661
|
+
- examples/action-cable-production-mode/config/puma.rb
|
662
|
+
- examples/action-cable-production-mode/config/routes.rb
|
663
|
+
- examples/action-cable-production-mode/config/secrets.yml
|
664
|
+
- examples/action-cable-production-mode/config/spring.rb
|
665
|
+
- examples/action-cable-production-mode/db/migrate/20161114213840_create_words.rb
|
666
|
+
- examples/action-cable-production-mode/db/schema.rb
|
667
|
+
- examples/action-cable-production-mode/db/seeds.rb
|
668
|
+
- examples/action-cable-production-mode/lib/assets/.keep
|
669
|
+
- examples/action-cable-production-mode/lib/tasks/.keep
|
670
|
+
- examples/action-cable-production-mode/log/.keep
|
671
|
+
- examples/action-cable-production-mode/public/404.html
|
672
|
+
- examples/action-cable-production-mode/public/422.html
|
673
|
+
- examples/action-cable-production-mode/public/500.html
|
674
|
+
- examples/action-cable-production-mode/public/apple-touch-icon-precomposed.png
|
675
|
+
- examples/action-cable-production-mode/public/apple-touch-icon.png
|
676
|
+
- examples/action-cable-production-mode/public/assets/.sprockets-manifest-3e9abd3ee8ba47c39a55b61ae37ed9e1.json
|
677
|
+
- examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js
|
678
|
+
- examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js.gz
|
679
|
+
- examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css
|
680
|
+
- examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz
|
681
|
+
- examples/action-cable-production-mode/public/favicon.ico
|
682
|
+
- examples/action-cable-production-mode/public/robots.txt
|
683
|
+
- examples/action-cable-production-mode/test/controllers/.keep
|
684
|
+
- examples/action-cable-production-mode/test/fixtures/.keep
|
685
|
+
- examples/action-cable-production-mode/test/fixtures/files/.keep
|
686
|
+
- examples/action-cable-production-mode/test/fixtures/words.yml
|
687
|
+
- examples/action-cable-production-mode/test/helpers/.keep
|
688
|
+
- examples/action-cable-production-mode/test/integration/.keep
|
689
|
+
- examples/action-cable-production-mode/test/mailers/.keep
|
690
|
+
- examples/action-cable-production-mode/test/models/.keep
|
691
|
+
- examples/action-cable-production-mode/test/models/word_test.rb
|
692
|
+
- examples/action-cable-production-mode/test/test_helper.rb
|
693
|
+
- examples/action-cable-production-mode/tmp/.keep
|
694
|
+
- examples/action-cable-production-mode/vendor/assets/javascripts/.keep
|
695
|
+
- examples/action-cable-production-mode/vendor/assets/stylesheets/.keep
|
610
696
|
- examples/action-cable/.gitignore
|
611
697
|
- examples/action-cable/Gemfile
|
612
698
|
- examples/action-cable/Gemfile.lock
|
@@ -630,8 +716,6 @@ files:
|
|
630
716
|
- examples/action-cable/app/views/components.rb
|
631
717
|
- examples/action-cable/app/views/components/app.rb
|
632
718
|
- examples/action-cable/app/views/layouts/application.html.erb
|
633
|
-
- examples/action-cable/app/views/layouts/mailer.html.erb
|
634
|
-
- examples/action-cable/app/views/layouts/mailer.text.erb
|
635
719
|
- examples/action-cable/bin/bundle
|
636
720
|
- examples/action-cable/bin/rails
|
637
721
|
- examples/action-cable/bin/rake
|
@@ -708,8 +792,6 @@ files:
|
|
708
792
|
- examples/pusher-fake/app/views/components.rb
|
709
793
|
- examples/pusher-fake/app/views/components/app.rb
|
710
794
|
- examples/pusher-fake/app/views/layouts/application.html.erb
|
711
|
-
- examples/pusher-fake/app/views/layouts/mailer.html.erb
|
712
|
-
- examples/pusher-fake/app/views/layouts/mailer.text.erb
|
713
795
|
- examples/pusher-fake/bin/bundle
|
714
796
|
- examples/pusher-fake/bin/rails
|
715
797
|
- examples/pusher-fake/bin/rake
|
@@ -785,8 +867,6 @@ files:
|
|
785
867
|
- examples/pusher/app/views/components.rb
|
786
868
|
- examples/pusher/app/views/components/app.rb
|
787
869
|
- examples/pusher/app/views/layouts/application.html.erb
|
788
|
-
- examples/pusher/app/views/layouts/mailer.html.erb
|
789
|
-
- examples/pusher/app/views/layouts/mailer.text.erb
|
790
870
|
- examples/pusher/bin/bundle
|
791
871
|
- examples/pusher/bin/rails
|
792
872
|
- examples/pusher/bin/rake
|
@@ -862,8 +942,6 @@ files:
|
|
862
942
|
- examples/simple-poller/app/views/components.rb
|
863
943
|
- examples/simple-poller/app/views/components/app.rb
|
864
944
|
- examples/simple-poller/app/views/layouts/application.html.erb
|
865
|
-
- examples/simple-poller/app/views/layouts/mailer.html.erb
|
866
|
-
- examples/simple-poller/app/views/layouts/mailer.text.erb
|
867
945
|
- examples/simple-poller/bin/bundle
|
868
946
|
- examples/simple-poller/bin/rails
|
869
947
|
- examples/simple-poller/bin/rake
|
@@ -920,6 +998,87 @@ files:
|
|
920
998
|
- examples/simple-poller/tmp/.keep
|
921
999
|
- examples/simple-poller/vendor/assets/javascripts/.keep
|
922
1000
|
- examples/simple-poller/vendor/assets/stylesheets/.keep
|
1001
|
+
- examples/word-game/.gitignore
|
1002
|
+
- examples/word-game/Gemfile
|
1003
|
+
- examples/word-game/Gemfile.lock
|
1004
|
+
- examples/word-game/README.md
|
1005
|
+
- examples/word-game/Rakefile
|
1006
|
+
- examples/word-game/app/assets/config/manifest.js
|
1007
|
+
- examples/word-game/app/assets/images/.keep
|
1008
|
+
- examples/word-game/app/assets/javascripts/application.js
|
1009
|
+
- examples/word-game/app/assets/javascripts/cable.js
|
1010
|
+
- examples/word-game/app/assets/javascripts/channels/.keep
|
1011
|
+
- examples/word-game/app/assets/stylesheets/application.css
|
1012
|
+
- examples/word-game/app/channels/application_cable/channel.rb
|
1013
|
+
- examples/word-game/app/channels/application_cable/connection.rb
|
1014
|
+
- examples/word-game/app/controllers/application_controller.rb
|
1015
|
+
- examples/word-game/app/controllers/concerns/.keep
|
1016
|
+
- examples/word-game/app/helpers/application_helper.rb
|
1017
|
+
- examples/word-game/app/jobs/application_job.rb
|
1018
|
+
- examples/word-game/app/mailers/application_mailer.rb
|
1019
|
+
- examples/word-game/app/models/application_record.rb
|
1020
|
+
- examples/word-game/app/models/concerns/.keep
|
1021
|
+
- examples/word-game/app/models/models.rb
|
1022
|
+
- examples/word-game/app/models/public/.keep
|
1023
|
+
- examples/word-game/app/policies/application_policy.rb
|
1024
|
+
- examples/word-game/app/views/components.rb
|
1025
|
+
- examples/word-game/app/views/components/.keep
|
1026
|
+
- examples/word-game/app/views/layouts/application.html.erb
|
1027
|
+
- examples/word-game/app/views/layouts/mailer.html.erb
|
1028
|
+
- examples/word-game/app/views/layouts/mailer.text.erb
|
1029
|
+
- examples/word-game/bin/bundle
|
1030
|
+
- examples/word-game/bin/rails
|
1031
|
+
- examples/word-game/bin/rake
|
1032
|
+
- examples/word-game/bin/setup
|
1033
|
+
- examples/word-game/bin/spring
|
1034
|
+
- examples/word-game/bin/update
|
1035
|
+
- examples/word-game/config.ru
|
1036
|
+
- examples/word-game/config/application.rb
|
1037
|
+
- examples/word-game/config/boot.rb
|
1038
|
+
- examples/word-game/config/cable.yml
|
1039
|
+
- examples/word-game/config/database.yml
|
1040
|
+
- examples/word-game/config/environment.rb
|
1041
|
+
- examples/word-game/config/environments/development.rb
|
1042
|
+
- examples/word-game/config/environments/production.rb
|
1043
|
+
- examples/word-game/config/environments/test.rb
|
1044
|
+
- examples/word-game/config/initializers/application_controller_renderer.rb
|
1045
|
+
- examples/word-game/config/initializers/assets.rb
|
1046
|
+
- examples/word-game/config/initializers/backtrace_silencers.rb
|
1047
|
+
- examples/word-game/config/initializers/cookies_serializer.rb
|
1048
|
+
- examples/word-game/config/initializers/filter_parameter_logging.rb
|
1049
|
+
- examples/word-game/config/initializers/hyper_mesh.rb
|
1050
|
+
- examples/word-game/config/initializers/inflections.rb
|
1051
|
+
- examples/word-game/config/initializers/mime_types.rb
|
1052
|
+
- examples/word-game/config/initializers/new_framework_defaults.rb
|
1053
|
+
- examples/word-game/config/initializers/session_store.rb
|
1054
|
+
- examples/word-game/config/initializers/wrap_parameters.rb
|
1055
|
+
- examples/word-game/config/locales/en.yml
|
1056
|
+
- examples/word-game/config/puma.rb
|
1057
|
+
- examples/word-game/config/routes.rb
|
1058
|
+
- examples/word-game/config/secrets.yml
|
1059
|
+
- examples/word-game/config/spring.rb
|
1060
|
+
- examples/word-game/db/seeds.rb
|
1061
|
+
- examples/word-game/lib/assets/.keep
|
1062
|
+
- examples/word-game/lib/tasks/.keep
|
1063
|
+
- examples/word-game/log/.keep
|
1064
|
+
- examples/word-game/public/404.html
|
1065
|
+
- examples/word-game/public/422.html
|
1066
|
+
- examples/word-game/public/500.html
|
1067
|
+
- examples/word-game/public/apple-touch-icon-precomposed.png
|
1068
|
+
- examples/word-game/public/apple-touch-icon.png
|
1069
|
+
- examples/word-game/public/favicon.ico
|
1070
|
+
- examples/word-game/public/robots.txt
|
1071
|
+
- examples/word-game/test/controllers/.keep
|
1072
|
+
- examples/word-game/test/fixtures/.keep
|
1073
|
+
- examples/word-game/test/fixtures/files/.keep
|
1074
|
+
- examples/word-game/test/helpers/.keep
|
1075
|
+
- examples/word-game/test/integration/.keep
|
1076
|
+
- examples/word-game/test/mailers/.keep
|
1077
|
+
- examples/word-game/test/models/.keep
|
1078
|
+
- examples/word-game/test/test_helper.rb
|
1079
|
+
- examples/word-game/tmp/.keep
|
1080
|
+
- examples/word-game/vendor/assets/javascripts/.keep
|
1081
|
+
- examples/word-game/vendor/assets/stylesheets/.keep
|
923
1082
|
- examples/words/.gitignore
|
924
1083
|
- examples/words/Gemfile
|
925
1084
|
- examples/words/Gemfile.lock
|
@@ -988,6 +1147,7 @@ files:
|
|
988
1147
|
- lib/enumerable/pluck.rb
|
989
1148
|
- lib/hyper-mesh.rb
|
990
1149
|
- lib/hypermesh/version.rb
|
1150
|
+
- lib/kernel/itself.rb
|
991
1151
|
- lib/opal/equality_patches.rb
|
992
1152
|
- lib/opal/parse_patch.rb
|
993
1153
|
- lib/opal/set_patches.rb
|
@@ -1121,12 +1281,15 @@ files:
|
|
1121
1281
|
- spec/factories/test_models.rb
|
1122
1282
|
- spec/factories/todo.rb
|
1123
1283
|
- spec/factories/user.rb
|
1284
|
+
- spec/reactive_record/auto_load_itself_spec.rb
|
1124
1285
|
- spec/reactive_record/edge_cases_spec.rb
|
1125
1286
|
- spec/reactive_record/factory.rb
|
1287
|
+
- spec/reactive_record/finder_method_spec.rb
|
1126
1288
|
- spec/reactive_record/many_to_many_spec.rb
|
1127
1289
|
- spec/reactive_record/play.rb
|
1128
1290
|
- spec/reactive_record/pry_rescue_xspec.rb
|
1129
1291
|
- spec/reactive_record/revert_spec.rb
|
1292
|
+
- spec/reactive_record/save_while_loading_spec.rb
|
1130
1293
|
- spec/reactive_record/update_associations_spec.rb
|
1131
1294
|
- spec/reactive_record/update_scopes_spec.rb
|
1132
1295
|
- spec/spec_helper.rb
|
@@ -1249,12 +1412,15 @@ test_files:
|
|
1249
1412
|
- spec/factories/test_models.rb
|
1250
1413
|
- spec/factories/todo.rb
|
1251
1414
|
- spec/factories/user.rb
|
1415
|
+
- spec/reactive_record/auto_load_itself_spec.rb
|
1252
1416
|
- spec/reactive_record/edge_cases_spec.rb
|
1253
1417
|
- spec/reactive_record/factory.rb
|
1418
|
+
- spec/reactive_record/finder_method_spec.rb
|
1254
1419
|
- spec/reactive_record/many_to_many_spec.rb
|
1255
1420
|
- spec/reactive_record/play.rb
|
1256
1421
|
- spec/reactive_record/pry_rescue_xspec.rb
|
1257
1422
|
- spec/reactive_record/revert_spec.rb
|
1423
|
+
- spec/reactive_record/save_while_loading_spec.rb
|
1258
1424
|
- spec/reactive_record/update_associations_spec.rb
|
1259
1425
|
- spec/reactive_record/update_scopes_spec.rb
|
1260
1426
|
- spec/spec_helper.rb
|