hyper-mesh 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +7 -2
  4. data/README.md +112 -87
  5. data/Rakefile +6 -1
  6. data/docs/action_cable_quickstart.md +20 -16
  7. data/docs/activerecord_api.md +23 -17
  8. data/docs/authorization-policies.md +45 -35
  9. data/docs/client_side_scoping.md +5 -5
  10. data/docs/configuration_details.md +6 -46
  11. data/docs/pusher_faker_quickstart.md +7 -68
  12. data/docs/pusher_quickstart.md +7 -68
  13. data/docs/simple_poller_quickstart.md +6 -67
  14. data/docs/todo-example.md +2 -2
  15. data/docs/word_game.md +3 -1
  16. data/docs/words-example.md +2 -3
  17. data/examples/action-cable/Gemfile +2 -1
  18. data/examples/action-cable/Gemfile.lock +73 -54
  19. data/examples/action-cable/config/initializers/{hyper_mesh.rb → hyperloop.rb} +1 -1
  20. data/examples/action-cable/config/routes.rb +1 -1
  21. data/hyper-mesh.gemspec +10 -4
  22. data/lib/active_record_base.rb +3 -3
  23. data/{examples/action-cable-production-mode/log/.keep → lib/acts_as_string.rb} +0 -0
  24. data/lib/hyper-mesh.rb +11 -19
  25. data/lib/hyper_mesh/version.rb +3 -0
  26. data/lib/hypermesh/version.rb +1 -1
  27. data/lib/reactive_record/active_record/class_methods.rb +10 -3
  28. data/lib/reactive_record/active_record/instance_methods.rb +8 -0
  29. data/lib/reactive_record/active_record/public_columns_hash.rb +8 -2
  30. data/lib/reactive_record/active_record/reactive_record/collection.rb +0 -1
  31. data/lib/reactive_record/active_record/reactive_record/dummy_value.rb +2 -1
  32. data/lib/reactive_record/active_record/reactive_record/isomorphic_base.rb +55 -63
  33. data/lib/reactive_record/active_record/reactive_record/operations.rb +51 -0
  34. data/lib/reactive_record/active_record/reactive_record/reactive_set_relationship_helpers.rb +3 -3
  35. data/lib/reactive_record/active_record/reactive_record/while_loading.rb +93 -84
  36. data/lib/reactive_record/broadcast.rb +183 -0
  37. data/lib/reactive_record/permissions.rb +2 -2
  38. data/reactive_record_test_app/Gemfile +6 -2
  39. data/reactive_record_test_app/Gemfile.lock +120 -60
  40. data/reactive_record_test_app/app/assets/javascripts/application.rb +3 -5
  41. data/reactive_record_test_app/app/assets/javascripts/bigdecimal.rb +1 -0
  42. data/reactive_record_test_app/app/assets/javascripts/reactive_record_config.js +2 -2
  43. data/reactive_record_test_app/app/controllers/application_controller.rb +3 -3
  44. data/reactive_record_test_app/app/controllers/home_controller.rb +1 -1
  45. data/reactive_record_test_app/app/models/models.rb.erb +6 -0
  46. data/reactive_record_test_app/config/application.rb +2 -0
  47. data/reactive_record_test_app/config/environments/development.rb +1 -1
  48. data/reactive_record_test_app/config/routes.rb +1 -2
  49. data/reactive_record_test_app/db/seeds.rb +6 -0
  50. data/reactive_record_test_app/script/rails +0 -0
  51. data/reactive_record_test_app/spec-opal/active-record/rendering_spec.rb +11 -2
  52. data/reactive_record_test_app/spec-opal/active-record/save_spec.rb +3 -4
  53. data/reactive_record_test_app/spec-opal/spec_helper.js.rb +1 -1
  54. data/reactive_record_test_app/spec-opal/test_spec.rb +7 -0
  55. data/reactive_record_test_app/spec_dont_run/README.md +7 -0
  56. data/reactive_record_test_app/{spec-opal/active-record → spec_dont_run/active_record_broken}/permissions_spec.rb +0 -0
  57. data/reactive_record_test_app/{spec-opal/active-record → spec_dont_run/active_record_broken}/prerendering_spec.rb +1 -0
  58. data/spec/{synchromesh/aaa-unit_tests/connection_spec.rb → batch1/aaa-unit_tests/connection_movedspec.rb} +0 -0
  59. data/spec/{synchromesh → batch1}/aaa-unit_tests/dummy_value_spec.rb +2 -2
  60. data/spec/{synchromesh → batch1}/column_types/column_type_spec.rb +2 -2
  61. data/spec/{synchromesh → batch1}/crud_access_regulation/broadcast_controls_access_spec.rb +1 -1
  62. data/spec/{synchromesh → batch1}/crud_access_regulation/model_policies_spec.rb +6 -6
  63. data/spec/batch1/misc/access_like_hash_spec.rb +43 -0
  64. data/spec/batch1/misc/while_loading_spec.rb +196 -0
  65. data/spec/{synchromesh → batch1}/policies/regulate_all_broadcasts_spec.rb +12 -12
  66. data/spec/{synchromesh → batch1}/policies/regulate_broadcast_spec.rb +25 -25
  67. data/spec/{synchromesh/integration → batch2}/authorization_spec.rb +8 -7
  68. data/spec/{synchromesh/integration → batch2}/default_scope_spec.rb +2 -2
  69. data/spec/{synchromesh/integration → batch2}/has_many_through_spec.rb +2 -2
  70. data/spec/{synchromesh/integration → batch2}/relationships_spec.rb +3 -3
  71. data/spec/{reactive_record → batch3}/auto_load_itself_spec.rb +1 -1
  72. data/spec/{reactive_record → batch3}/edge_cases_spec.rb +1 -1
  73. data/spec/{reactive_record → batch3}/finder_method_spec.rb +1 -1
  74. data/spec/{reactive_record → batch3}/many_to_many_spec.rb +2 -2
  75. data/spec/{reactive_record → batch3}/pry_rescue_xspec.rb +0 -0
  76. data/{examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css → spec/batch3/readme.txt} +0 -0
  77. data/spec/{reactive_record → batch3}/revert_spec.rb +2 -2
  78. data/spec/{reactive_record → batch3}/save_while_loading_spec.rb +1 -1
  79. data/spec/{reactive_record → batch3}/update_associations_spec.rb +2 -2
  80. data/spec/{reactive_record → batch3}/update_scopes_spec.rb +2 -2
  81. data/spec/{synchromesh/integration → batch4}/saving_during_commit_spec.rb +2 -2
  82. data/spec/{synchromesh/integration → batch4}/scope_spec.rb +30 -2
  83. data/spec/{synchromesh/examples → batch4}/scoped_todos_spec.rb +3 -3
  84. data/spec/{synchromesh/integration → batch4}/synchromesh_spec.rb +2 -2
  85. data/spec/{synchromesh/examples → examples}/dictionary.rb +2 -2
  86. data/spec/{synchromesh/examples → examples}/dictionary_with_client_scopes.rb +2 -2
  87. data/spec/{synchromesh/examples → examples}/random_examples.rb +1 -1
  88. data/spec/{reactive_record/play.rb → play_ground.rb} +0 -0
  89. data/spec/{reactive_record/factory.rb → reactive_record_factory.rb} +0 -0
  90. data/spec/spec_helper.rb +3 -2
  91. data/spec/test_app/Gemfile +8 -3
  92. data/spec/test_app/Gemfile.lock +114 -64
  93. data/spec/test_app/app/views/components.rb +1 -2
  94. data/spec/test_app/config/application.rb +2 -0
  95. data/spec/test_app/config/routes.rb +1 -1
  96. data/spec/{synchromesh/integration/test_components.rb → test_components.rb} +0 -0
  97. metadata +144 -137
  98. data/app/controllers/reactive_record/application_controller.rb +0 -4
  99. data/app/controllers/reactive_record/reactive_record_controller.rb +0 -49
  100. data/config/routes.rb +0 -7
  101. data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js +0 -50
  102. data/examples/action-cable-production-mode/public/assets/application-90043e04e9e784054fd08159fa7aafe5e23d3ffb31584b1bea1e47043c9cfb5a.js.gz +0 -0
  103. data/examples/action-cable-production-mode/public/assets/application-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css.gz +0 -0
  104. data/examples/action-cable-production-mode/tmp/.keep +0 -0
  105. data/examples/action-cable/log/.keep +0 -0
  106. data/examples/action-cable/tmp/.keep +0 -0
  107. data/examples/pusher-fake/log/.keep +0 -0
  108. data/examples/pusher-fake/tmp/.keep +0 -0
  109. data/examples/pusher/log/.keep +0 -0
  110. data/examples/pusher/tmp/.keep +0 -0
  111. data/examples/simple-poller/log/.keep +0 -0
  112. data/examples/simple-poller/tmp/.keep +0 -0
  113. data/examples/word-game/log/.keep +0 -0
  114. data/examples/word-game/tmp/.keep +0 -0
  115. data/examples/words/log/.keep +0 -0
  116. data/examples/words/tmp/.keep +0 -0
  117. data/lib/reactive_record/version.rb +0 -3
  118. data/lib/sources/hyper-mesh/pusher.js +0 -98
  119. data/lib/synchromesh/action_cable.rb +0 -39
  120. data/lib/synchromesh/client_drivers.rb +0 -357
  121. data/lib/synchromesh/configuration.rb +0 -40
  122. data/lib/synchromesh/connection.rb +0 -170
  123. data/lib/synchromesh/policy.rb +0 -504
  124. data/lib/synchromesh/synchromesh.rb +0 -159
  125. data/lib/synchromesh/synchromesh_controller.rb +0 -162
  126. data/reactive_record_test_app/README.rdoc +0 -261
  127. data/reactive_record_test_app/app/assets/javascripts/components/another_component.rb +0 -24
  128. data/reactive_record_test_app/app/assets/javascripts/components/empty_component.rb +0 -6
  129. data/reactive_record_test_app/app/assets/javascripts/components/todo_item_component.js.rb +0 -16
  130. data/reactive_record_test_app/app/assets/javascripts/components/todos_component.js.rb +0 -42
  131. data/reactive_record_test_app/app/assets/javascripts/components/todos_main_component.rb +0 -49
  132. data/reactive_record_test_app/app/assets/javascripts/react_js_test_only.js +0 -21618
  133. data/reactive_record_test_app/app/assets/javascripts/spec/reactive_record_xspec.js.rb +0 -42
  134. data/reactive_record_test_app/app/controllers/test_controller.rb +0 -7
  135. data/reactive_record_test_app/app/mailers/.gitkeep +0 -0
  136. data/reactive_record_test_app/app/models/models.rb +0 -1
  137. data/reactive_record_test_app/app/policies/application_policy.rb +0 -5
  138. data/reactive_record_test_app/app/views/components.rb +0 -4
  139. data/reactive_record_test_app/app/views/components/test.rb +0 -18
  140. data/reactive_record_test_app/app/views/home/index.html.erb +0 -1
  141. data/reactive_record_test_app/app/views/layouts/application.html.erb +0 -17
  142. data/reactive_record_test_app/config/environments/production.rb +0 -70
  143. data/reactive_record_test_app/config/environments/test.rb +0 -41
  144. data/spec/synchromesh/integration/transports_spec.rb +0 -308
  145. data/spec/synchromesh/policies/auto_connect_spec.rb +0 -60
  146. data/spec/synchromesh/policies/auto_loader_spec.rb +0 -34
  147. data/spec/synchromesh/policies/policy_methods_spec.rb +0 -85
  148. data/spec/synchromesh/policies/regulate_class_connection_spec.rb +0 -50
  149. data/spec/synchromesh/policies/regulate_instance_connection_spec.rb +0 -66
  150. data/spec/test_app/log/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b8982a6629467339b2a91000f327e77e5d1b08f9
4
- data.tar.gz: ff8f97442cfc6de5a5902c424e19d89e490a2f99
3
+ metadata.gz: 7c8cff3576c49e676da430a401c45b150f93d3cc
4
+ data.tar.gz: 803b48fed09cb018a7824ac6f39231b0817b996c
5
5
  SHA512:
6
- metadata.gz: ac64d306366dcf4eca7034e60c04ec423766d93f76d2dabef0c123d31e9447654b29046e0055daf86ef5c6b35609c9d02fec01e523f8da5fc90326e781edaabe
7
- data.tar.gz: 61ae00d5f4ecf921d4acc9037808841c5539fb4ed59dbbfac712bef62e1c2512d049a89217de410719d9fb0cd89de2c04b3162fa3a19d1423f472ca3b59810af
6
+ metadata.gz: 457e325c751d703313219941a7fefb933aa8ec1187c6f96e98315eac35a3b58ddc8ce54699d9ea42f914b4b8be2bf529692df00d3c25cf668bb1b4fe136f33a6
7
+ data.tar.gz: 9e2365e689925707fbf1debc1aabb99445a775f912503116d3dffc5dc6273a8a2cbb97f9cad8dd357e9d96db352bf33410b54ef8c914478fae250edbd460828c
data/.gitignore CHANGED
@@ -6,7 +6,7 @@
6
6
  /doc/
7
7
  /pkg/
8
8
  /spec/reports/
9
- /tmp/
9
+ tmp/
10
10
  /spec/test_app/tmp/
11
11
  /spec/test_app/db/test.sqlite3
12
12
  /spec/test_app/log/test.log
@@ -25,3 +25,4 @@ reactive_record_test_app/log/
25
25
  reactive_record_test_app/tmp/
26
26
  reactive_record_test_app/.sass-cache
27
27
  .DS_Store
28
+ public/assets/*
data/Gemfile CHANGED
@@ -1,5 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
  # Specify your gem's dependencies in synchromesh.gemspec
3
- gem 'hyper-trace'
4
- gem 'opal-browser'
3
+ # gem 'hyper-trace'
4
+ # gem 'opal-browser'
5
+ # gem 'hyper-operation', path: '../hyper-operation' #git: 'https://github.com/ruby-hyperloop/hyper-operation.git' #
6
+ # gem 'hyper-component', path: '../hyper-component'
7
+ # gem 'hyper-react', path: '../hyper-react'
8
+ # gem 'hyper-store', path: '../hyper-store'
9
+ # gem 'hyperloop-config', path: '../hyperloop-config'
5
10
  gemspec
data/README.md CHANGED
@@ -1,26 +1,29 @@
1
- # ![](https://avatars3.githubusercontent.com/u/15810526?v=3&s=40&raw=true)HyperMesh
1
+ # ![](https://github.com/Serzhenka/hyper-loop-logos/blob/master/hyper-mesh_150.png?raw=true)Hyper-model
2
2
 
3
3
  [![Join the chat at https://gitter.im/reactrb/chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/reactrb/chat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4
4
  [![Gem Version](https://badge.fury.io/rb/hyper-mesh.svg)](https://badge.fury.io/rb/hyper-mesh)
5
5
 
6
- HyperMesh gives your HyperReact components CRUD access to your server side ActiveRecord models, using the standard ActiveRecord API.
7
- In addition HyperMesh implements push notifications (via a number of possible
8
- technologies) so changes to records on the server are dynamically pushed to all authorised clients.
6
+ TODO There is no functional change. Config stuff goes in hyper-operation readme. AR interface stuff goes in hyper-model
7
+ policies you have to think about... probably a seperate doc that both refer to, maybe with sections that say "Active Record only" or something like that."
9
8
 
10
- *Its Isomorphic Ruby in action.*
9
+ In Hyperloop, your ActiveRecord Models are available in your Isomorphic code.
11
10
 
12
- In other words one browser creates, updates, or destroys a model, and the changes are persisted in
13
- active record models and then broadcast to all other authorised clients.
11
+ Components, Operations, and Stores have CRUD access to your server side ActiveRecord Models, using the standard ActiveRecord API.
12
+
13
+ In addition, Hyperloop implements push notifications (via a number of possible technologies) so changes to records on the server are dynamically pushed to all authorized clients.
14
+
15
+ *It's Isomorphic Ruby in action.*
16
+
17
+ In other words, one browser creates, updates, or destroys a Model, and the changes are persisted in ActiveRecord models and then broadcast to all other authorized clients.
14
18
 
15
19
  ## Overview
16
20
 
17
- + HyperMesh is built on top of HyperReact.
18
- + HyperReact is a Ruby DSL (Domain Specific Language) to build [React.js](https://facebook.github.io/react/) UI components in Ruby. As data changes on the client (either from user interactions or external events) HyperReact re-draws whatever parts of the display is needed.
19
- + HyperMesh provides a [flux dispatcher and data store](https://facebook.github.io/flux/docs/overview.html) backed by [Rails Active Record models](http://guides.rubyonrails.org/active_record_basics.html).
20
- You access your model data in your HyperReact components just like you would on the server or in an ERB or HAML view file.
21
- + If an optional push transport is connected HyperMesh broadcasts any changes made to your ActiveRecord models as they are persisted on the server.
21
+ + The `hyper-model` gem provides ActiveRecord Models to Hyperloop's Isomorphic architecture.
22
+ + You access your Model data in your Components, Operations, and Stores just like you would on the server or in an ERB or HAML view file.
23
+ + If an optional push transport is connected Hyperloop broadcasts any changes made to your ActiveRecord models as they are persisted on the server or updated by one of the authorized clients.
24
+ + Some Models can be designated as *server-only* which means they are not available to the Isomorphic code.
22
25
 
23
- For example consider a simple model called `Dictionary` which might be part of Wiktionary type app.
26
+ For example, consider a simple model called `Dictionary` which might be part of Wiktionary type app.
24
27
 
25
28
  ```ruby
26
29
  class Dictionary < ActiveRecord::Base
@@ -34,10 +37,10 @@ class Dictionary < ActiveRecord::Base
34
37
  end
35
38
  ```
36
39
 
37
- Here is a very simple HyperReact component that shows a random word from the dictionary:
40
+ Here is a very simple Hyperloop Component that shows a random word from the dictionary:
38
41
 
39
42
  ```ruby
40
- class WordOfTheDay < React::Component::Base
43
+ class WordOfTheDay < Hyperloop::Component
41
44
 
42
45
  def pick_entry!
43
46
  # pick a random word and assign the selected record to entry
@@ -64,7 +67,9 @@ class WordOfTheDay < React::Component::Base
64
67
  end
65
68
  ```
66
69
 
67
- For more complete examples with *push* updates checkout any of the apps in the `examples` directory, or build your own in 5 minutes following one of the quickstart guides:
70
+ For complete examples with *push* updates, see any of the apps in the `examples` directory, or build your own in 5 minutes following one of the quickstart guides:
71
+
72
+ TODO links below
68
73
 
69
74
  + [Rails 5 with ActionCable](/docs/action_cable_quickstart.md)
70
75
  + [Using Pusher.com](/docs/pusher_quickstart.md)
@@ -75,32 +80,45 @@ For more complete examples with *push* updates checkout any of the apps in the `
75
80
 
76
81
  The easiest way to install is to use the `hyper-rails` gem.
77
82
 
83
+ TODO check install uses `--hyper-model`
84
+
78
85
  1. Add `gem 'hyper-rails'` to your Rails `Gemfile` development section.
79
86
  2. Install the Gem: `bundle install`
80
- 3. Run the generator: `bundle exec rails g hyperloop:install --hyper-mesh` (or use `--all` to install all hyperloop gems)
87
+ 3. Run the generator: `bundle exec rails g hyperloop:install --hyper-model` (or use `--all` to install all hyperloop gems)
81
88
  4. Update the bundle: `bundle update`
82
89
 
83
- You will find a `public` folder has been added to the `app/models` folder. To access a model on the client, move it into the public directory. If you are on Rails 5, you will also need to move the `application_record.rb` into the public directory.
90
+ TODO check validity and ensure generator does this move
91
+
92
+ You will find a `hyperloop/models` folder has been added to the Rails. To access a model on the client, move it into the `hyperloop/models` folder. If you are on Rails 5, you will also need to move the `application_record.rb` into this folder.
93
+
94
+ You will also find an `app/policies` folder with a simple access policy suited for development. Policies are how you will provide detailed access control to your Isomorphic models. More details [here](/docs/authorization-policies.md).
84
95
 
85
- You will also find an `app/policies` folder with a simple access policy suited for development. Policies are how you will provide detailed access control to to your public models. More details [here](/docs/authorization-policies.md).
96
+ TODO fix link above
86
97
 
87
- Once you have run the hyperloop installer you can move models to the `app/models/public` directory and they will be accessible on both the server and client.
98
+ To summarize:
99
+
100
+ + Your Isomorphic Models are moved to `hyperloop/models`. These are accessible to your Components, Operations, and Stores from either the server or the client.
101
+ + If you need to have server-only Models, they remain in `app/models`. These models are **not** accessible to your Isomorphic code.
88
102
 
89
103
  ## Setting up the Push Transport
90
104
 
91
- To have changes to your models on the server broadcast to authorized clients, add a HyperMesh initializer file and specify a transport. For example to setup a simple polled transport add this file:
105
+ To have changes to your Models on the server broadcast to authorized clients, add a Hyperloop initializer file and specify a transport. For example to setup a simple polled transport add this file:
106
+
107
+ TODO check below
92
108
 
93
109
  ```ruby
94
- # config/initializers/hyper_mesh.rb
95
- HyperMesh.configuration do |config|
110
+ # config/initializers/hyperloop.rb
111
+ Hyperloop.configuration do |config|
96
112
  config.transport = :simple_poller
97
113
  end
98
114
  ```
99
115
 
100
- After restarting, and reloading your browsers you will see changes broadcast to the clients. You can also play with this by firing up a rails console, and creating, changing or destroying models at the console.
116
+ After restarting, and reloading your browsers you will see changes broadcast to the clients. You can also play with this by firing up a rails console, and creating, changing or destroying Models at the console.
101
117
 
102
118
  For setting up the other possible transports following one of these guides:
103
119
 
120
+ TODO fix links below
121
+
104
122
  + [Rails 5 with ActionCable](/docs/action_cable_quickstart.md)
105
123
  + [Using Pusher.com](/docs/pusher_quickstart.md)
106
124
  + [Using Pusher-Faker](/docs/pusher_faker_quickstart.md)
@@ -108,19 +126,25 @@ For setting up the other possible transports following one of these guides:
108
126
 
109
127
  ## Advanced Configuration
110
128
 
129
+ TODO fix links below
130
+
111
131
  The above guides will work in most cases, but for complete details on configuration settings go [here](/docs/configuration_details.md)
112
132
 
113
133
  ## ActiveRecord API
114
134
 
115
- HyperMesh uses a large subset of the ActiveRecord API modified only when necessary to accommodate the asynchronous nature of the client. You can access your ActiveRecord models just like you would in models, controllers, or in ERB or HAML view templates.
135
+ Hyperloop uses a large subset of the ActiveRecord API, modified only when necessary to accommodate the asynchronous nature of the client. You can access your ActiveRecord models just like you would in Models, Controllers, or in ERB or HAML view templates.
136
+
137
+ TODO fix links below
116
138
 
117
139
  See this [guide](/docs/activerecord_api.md) for details.
118
140
 
119
- **Warning** currently the `attributes` method is supported, but please do not use it as some details of the semantics will be changing in an upcoming release. Instead of `foo.attributes[:xyz]` use `foo.send('xyz')` for now.
141
+ **Note** currently the `attributes` method is supported, but please do not use it as some details of the semantics will be changing in an upcoming release. Instead of `foo.attributes[:xyz]` use `foo.send('xyz')` for now.
120
142
 
121
143
  ## Client Side Scoping
122
144
 
123
- By default scopes will be recalculated on the server. For simple scopes that do not use joins or includes no additional action needs to be taken to make scopes work with HyperMesh. For scopes that do use joins, or if you want to offload the scoping computation from the server to the client read more [here.](docs/client_side_scoping.md)
145
+ By default scopes will be recalculated on the server. For simple scopes that do not use joins or includes no additional action needs to be taken to make scopes work with Hyperloop. For scopes that do use joins, or if you want to offload the scoping computation from the server to the client read more [here.](docs/client_side_scoping.md)
146
+
147
+ TODO fix link above
124
148
 
125
149
  ## Authorization
126
150
 
@@ -129,54 +153,55 @@ Each application defines a number of *channels* and *authorization policies* for
129
153
  Policies are defined with *Policy* classes. These are similar and compatible with [Pundit](https://github.com/elabs/pundit) but
130
154
  you do not need to use the pundit gem (but can if you want.)
131
155
 
156
+ TODO fix links below
157
+
132
158
  For complete details see [Authorization Policies](docs/authorization-policies.md)
133
159
 
134
160
  ## Common Errors
135
161
 
136
- - No policy class:
137
- If you don't define a policy file, nothing will happen because nothing will get connected.
138
- By default HyperMesh will look for a `ApplicationPolicy` class.
162
+ - **No policy class**
163
+ If you don't define a policy file, nothing will happen because nothing will get connected. By default Hyperloop will look for a `ApplicationPolicy` class.
139
164
 
140
- - Wrong version of pusher-fake (pusher-fake/base vs. pusher-fake/rspec)
141
- See the Pusher-Fake gem repo for details.
165
+ - **Wrong version of pusher-fake** (pusher-fake/base vs. pusher-fake/rspec) See the Pusher-Fake gem repo for details.
142
166
 
143
167
  - Forgetting to add `require pusher` in application.js file
144
168
  this results in an error like this:
145
- ```text
146
- Exception raised while rendering #<TopLevelRailsComponent:0x53e>
147
- ReferenceError: Pusher is not defined
148
- ```
149
- To resolve make sure you `require 'pusher'` in your application.js file if using pusher. **DO NOT** require pusher from your components manifest as this will cause prerendering to fail.
150
-
151
- - No create/update/destroy policies
152
- You must explicitly allow changes to the models to be made by the client. If you don't you will
153
- see 500 responses from the server when you try to update. To open all access do this in
154
- your application policy: `allow_change(to: :all, on: [:create, :update, :destroy]) { true }`
155
-
156
- - Cannot connect to real pusher account:
157
- If you are trying to use a real pusher account (not pusher-fake) but see errors like this
158
- ```text
159
- pusher.self.js?body=1:62 WebSocket connection to
160
- 'wss://127.0.0.1/app/PUSHER_API_KEY?protocol=7&client=js&version=3.0.0&flash=false'
161
- failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
162
- ```
163
- Check to see if you are including the pusher-fake gem.
164
- HyperMesh will always try to use pusher-fake if it sees the gem included. Remove it and you should be good to go. See [issue #5](https://github.com/hyper-react/HyperMesh/issues/5) for more details.
165
-
166
- - Cannot connect with ActionCable. Make sure that `config.action_cable.allowed_request_origins` includes the url you use for development (including the port) and that you are using `Puma`.
167
-
168
- - Attributes are not being converted from strings, or do not have their default values
169
- Eager loading is probably turned off. HyperMesh needs to eager load `models/public` so it can find all the column information for all public models.
170
-
171
- - When starting rails you get a message on the rails console `couldn't find file 'browser'`
172
- Hyper-React v0.10.0 removed the dependency on opal-browser. You will have to add the 'opal-browser' gem to your Gemfile.
173
-
174
- - On page load you get a message yacking about super class mismatch for `DummyValue`
175
- You are still have the old `reactive-record` gem in your Gemfile, remove it from your gemfile and your components.rb manifest.
176
-
177
- - On page load you get a message yacking about no method `session` for `nil`
178
- You are still referencing the old reactive-ruby or reactrb gems either directly or indirectly though a gem like reactrb-router. Replace any gems like
179
- `reactrb-router` with `hyper-router`. You can also just remove `reactrb`, as `hyper-react` will be included by the `hyper-mesh` gem.
169
+ ```text
170
+ Exception raised while rendering #<TopLevelRailsComponent:0x53e>
171
+ ReferenceError: Pusher is not defined
172
+ ```
173
+ To resolve make sure you `require 'pusher'` in your application.js file if using pusher. DO NOT require pusher from your components manifest as this will cause prerendering to fail.
174
+
175
+ - **No create/update/destroy policies**
176
+ You must explicitly allow changes to the Models to be made by the client. If you don't you will see 500 responses from the server when you try to update. To open all access do this in your application policy: `allow_change(to: :all, on: [:create, :update, :destroy]) { true }`
177
+
178
+ - **Cannot connect to real pusher account**
179
+ If you are trying to use a real pusher account (not pusher-fake) but see errors like this
180
+ ```text
181
+ pusher.self.js?body=1:62 WebSocket connection to
182
+ 'wss://127.0.0.1/app/PUSHER_API_KEY?protocol=7&client=js&version=3.0.0&flash=false'
183
+ failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
184
+ ```
185
+ Check to see if you are including the pusher-fake gem.
186
+ Hyperloop will always try to use pusher-fake if it sees the gem included. Remove it and you should be good to go. See [issue #5](https://github.com/hyper-react/HyperMesh/issues/5) for more details.
187
+
188
+ - **Cannot connect with ActionCable.**
189
+ Make sure that `config.action_cable.allowed_request_origins` includes the url you use for development (including the port) and that you are using `Puma`.
190
+
191
+ - **Attributes are not being converted from strings, or do not have their default values**
192
+ Eager loading is probably turned off. Hyperloop needs to eager load `hyperloop/models` so it can find all the column information for all Isomorphic models.
193
+
194
+ - **When starting rails you get a message on the rails console `couldn't find file 'browser'`**
195
+ The `hyper-component` v0.10.0 gem removed the dependency on opal-browser. You will have to add the 'opal-browser' gem to your Gemfile.
196
+
197
+ - **On page load you get a message about super class mismatch for `DummyValue`**
198
+ You are still have the old `reactive-record` gem in your Gemfile, remove it from your gemfile and your components manifest.
199
+
200
+ - **On page load you get a message about no method `session` for `nil`**
201
+ You are still referencing the old reactive-ruby or reactrb gems either directly or indirectly though a gem like reactrb-router. Replace any gems like `reactrb-router` with `hyper-router`. You can also just remove `reactrb`, as `hyper-model` will be included by the `hyper-model` gem.
202
+
203
+ - **You keep seeing the message `WebSocket connection to 'ws://localhost:3000/cable' failed: WebSocket is closed before the connection is established.`** every few seconds in the console.
204
+ There are probably lots of reasons for this, but it means ActionCable can't get itself going. One reason is that you are trying to run with Passenger instead of Puma, and trying to use `async` mode in cable.yml file. `async` mode requires Puma.
180
205
 
181
206
  ## Debugging
182
207
 
@@ -184,59 +209,57 @@ Sometimes you need to figure out what connections are available, or what attribu
184
209
 
185
210
  Its usually all to do with your policies, but perhaps you just need a little investigation.
186
211
 
187
- You can bring up a console within the controller context by browsing `localhost:3000/rr/console`
212
+ TODO check rr has become hyperloop (as below)
188
213
 
189
- *Note: change `rr` to wherever you are mounting HyperMesh in your routes file.*
214
+ You can bring up a console within the controller context by browsing `localhost:3000/hyperloop/console`
190
215
 
191
- *Note: in rails 4, you will need to add the gem 'web-console' to your development section*
216
+ **Note: change `rr` to wherever you are mounting Hyperloop in your routes file.**
217
+
218
+ **Note: in rails 4, you will need to add the gem 'web-console' to your development section**
192
219
 
193
220
  Within the context you have access to `session.id` and current `acting_user` which you will need, plus some helper methods to reduce typing
194
221
 
195
222
  - Getting auto connection channels:
196
223
  `channels(session_id = session.id, user = acting_user)`
197
- e.g. `channels` returns all channels connecting to this session and user
198
- providing nil as the acting_user will test if connections can be made without there being a logged in user.
224
+ e.g. `channels` returns all channels connecting to this session and user providing nil as the acting_user will test if connections can be made without there being a logged in user.
199
225
 
200
226
  - Can a specific class connection be made:
201
227
  `can_connect?(channel, user = acting_user)`
202
- e.g. `can_connect? Todo` returns true if current acting_user can connect to the Todo class
203
- You can also provide the class name as a string.
228
+ e.g. `can_connect? Todo` returns true if current acting_user can connect to the Todo class. You can also provide the class name as a string.
204
229
 
205
230
  - Can a specific instance connection be made:
206
231
  `can_connect?(channel, user = acting_user)`
207
- e.g. `can_connect? Todo.first` returns true if current acting_user can connect to the first Todo model.
208
- You can also provide the instance in the form 'Todo-123'
232
+ e.g. `can_connect? Todo.first` returns true if current acting_user can connect to the first Todo Model. You can also provide the instance in the form 'Todo-123'
209
233
 
210
- - What attributes are accessible for a model instance:
234
+ - What attributes are accessible for a Model instance:
211
235
  `viewable_attributes(instance, user = acting_user)`
212
236
 
213
237
  - Can the attribute be viewed:
214
238
  `view_permitted?(instance, attribute, user = acting_user)`
215
239
 
216
- - Can a model be created/updated/destroyed:
240
+ - Can a Model be created/updated/destroyed:
217
241
  `create_permitted?(instance, user = acting_user)`
218
242
  e.g. `create_permitted?(Todo.new, nil)` can anybody save a new todo?
219
243
  e.g. `destroy_permitted?(Todo.last)` can the acting_user destroy the last Todo
220
244
 
221
- You can of course simulate server side changes to your models through this console like any other console. For example
245
+ You can of course simulate server side changes to your Models through this console like any other console. For example
222
246
 
223
- `Todo.new.save` will broadcast the changes to the Todo model to any authorized channels.
247
+ `Todo.new.save` will broadcast the changes to the Todo Model to any authorized channels.
224
248
 
225
249
  ## Development
226
250
 
227
- HyperMesh is the merger of `reactive-record` and `synchromesh` gems. As such a lot of the internal names are still using either ReactiveRecord or Synchromesh module names.
251
+ `hyper-model` is the merger of `reactive-record`, `synchromesh` and `hyper-mesh` gems. As such a lot of the internal names are still using either ReactiveRecord or Synchromesh module names.
228
252
 
229
- The original `ReactiveRecord` specs were written in opal-rspec. These are being migrated to
230
- use server rspec with isomorphic helpers. There are about 170 of the original tests left and to run these you
253
+ The original `ReactiveRecord` specs were written in opal-rspec. These are being migrated to use server rspec with isomorphic helpers. There are about 150 of the original tests left and to run these you
231
254
 
232
- 1. cd to `reactive_record_spec/test_app`
255
+ 1. cd to `reactive_record_test_app`
233
256
  2. do a bundle install/update as needed,
234
- 3. `rake db:reset db:test:prepare`,
257
+ 3. `bundle exec rake db:reset`,
235
258
  4. start the server: `bundle exec rails s`,
236
259
  5. then visit `localhost:3000/spec-opal`.
237
260
 
238
- If you want to help **PLEASE** consider spending an hour and migrate a spec file to the new format. You can
239
- find examples by looking in the `spec/reactive_record/` directory and matching to the original file in
261
+ If you want to help **PLEASE** consider spending an hour and migrate a spec file to the new format. You can find examples by looking in the `spec/reactive_record/` directory and matching to the original file in
262
+
240
263
  `reactive_record_test_app/spec_dont_run/moved_to_main_spec_dir`
241
264
 
242
265
  The remaining tests are run in the more traditional `bundle exec rake`
@@ -251,6 +274,8 @@ You can run the specs in firefox by adding `DRIVER=ff` (best for debugging.) Yo
251
274
 
252
275
  ## Contributing
253
276
 
277
+ TODO fix links
278
+
254
279
  Bug reports and pull requests are welcome on GitHub at https://github.com/reactive-ruby/HyperMesh. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
255
280
 
256
281
  ## License
data/Rakefile CHANGED
@@ -3,4 +3,9 @@ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task :default do
7
+ sh 'DRIVER=pg bundle exec rspec spec/batch1 -f d'
8
+ sh 'DRIVER=pg bundle exec rspec spec/batch2 -f d'
9
+ sh 'DRIVER=pg bundle exec rspec spec/batch3 -f d'
10
+ sh 'DRIVER=pg bundle exec rspec spec/batch4 -f d'
11
+ end
@@ -6,9 +6,9 @@ Action Cable is a production ready transport built into Rails 5.
6
6
 
7
7
  You need to be on rails 5 to use ActionCable. Make sure you upgrade to rails 5 first.
8
8
 
9
- #### 2 Add HyperLoop gems
9
+ #### 2 Add Hyperloop gems
10
10
 
11
- If you have not already installed the `hyper-react` and `hyper-mesh` gems, then do so now using the [hyper-rails](https://github.com/ruby-hyperloop/hyper-rails) gem.
11
+ If you have not already installed the `hyper-component` and `hyper-model` gems, then do so now using the [hyper-rails](https://github.com/ruby-hyperloop/hyper-rails) gem.
12
12
 
13
13
  - add `gem 'hyper-rails'` to your gem file (in the development section)
14
14
  - run `bundle install`
@@ -17,17 +17,19 @@ If you have not already installed the `hyper-react` and `hyper-mesh` gems, then
17
17
 
18
18
  #### 3 Set the transport
19
19
 
20
- Once you have HyperMesh installed then add this initializer:
20
+ TODO check below
21
+
22
+ Once you have Hyperloop installed then add this initializer:
21
23
  ```ruby
22
- #config/initializers/hyper_mesh.rb
23
- HyperMesh.configuration do |config|
24
+ #config/initializers/hyperloop.rb
25
+ Hyperloop.configuration do |config|
24
26
  config.transport = :action_cable
25
27
  end
26
28
  ```
27
29
 
28
30
  #### 4 Setup ActionCable
29
31
 
30
- If you are already using ActionCable in your app that is fine, as HyperMesh will not interfere with your existing connections.
32
+ If you are already using ActionCable in your app that is fine, as Hyperloop will not interfere with your existing connections.
31
33
 
32
34
  Otherwise go through the following steps to setup ActionCable.
33
35
 
@@ -35,7 +37,7 @@ Otherwise go through the following steps to setup ActionCable.
35
37
 
36
38
  Typically `app/assets/javascripts/application.js` will finish with a `require_tree .` and this will pull in the `cable.js` file which will pull in `action_cable.js`
37
39
 
38
- However at a minimum if `application.js` simply does a `require action_cable` that will be sufficient for HyperMesh.
40
+ However at a minimum if `application.js` simply does a `require action_cable` that will be sufficient for Hyperloop.
39
41
 
40
42
  ##### Make sure you have a cable.yml file
41
43
 
@@ -52,39 +54,39 @@ production:
52
54
  url: redis://localhost:6379/1
53
55
  ```
54
56
 
55
- ##### Set allowed request origins (optional)
57
+ #### Set allowed request origins (optional)
56
58
 
57
- By default action cable will only allow connections from localhost:3000 in development. If you are going to something other than localhost:3000 you need to add something like this to your config:
59
+ **By default action cable will only allow connections from localhost:3000 in development.** If you are going to something other than localhost:3000 you need to add something like this to your config:
58
60
 
59
61
  ```ruby
60
62
  # config/environments/development.rb
61
63
  Rails.application.configure do
62
- config.action_cable.allowed_request_origins = ['http://localhost:3000', 'http://localhost:4000']
64
+ config.action_cable.allowed_request_origins = ['http://localhost:3000', 'http://localhost:5000']
63
65
  end
64
66
  ```
65
67
 
66
68
  #### 5 Try It Out
67
69
 
68
- If you don't already have a model to play with, add one now:
70
+ If you don't already have a model to play with, add one now:
69
71
 
70
72
  `bundle exec rails generate model Word text:string`
71
73
 
72
74
  `bundle exec rake db:migrate`
73
75
 
74
- Move `app/models/word.rb` to `app/models/public/word.rb` and move
75
- `app/models/application_record.rb` to `app/models/public/application_record.rb`
76
+ Move `app/models/word.rb` to `app/hyperloop/models/word.rb` and move
77
+ `app/models/application_record.rb` to `app/hyperloop/models/application_record.rb`
76
78
 
77
79
  **Leave** `app/models/model.rb` where it is. This is your models client side manifest file.
78
80
 
79
- Whatever model(s) you will plan to access on the client need to moved to the `app/models/public` directory. This allows reactive-record to build a client side proxy for the models. Models not moved will be completely invisible on the client side.
81
+ Whatever model(s) you will plan to access on the client need to moved to the `app/hyperloop/models` directory. This allows Hyperloop to build a client side proxy for the Models. Models not moved will be completely invisible on the client or in your Isomorphic code.
80
82
 
81
- **Important** in rails 5 there is also a base `ApplicationRecord` class, that all other models are built from. This class must be moved to the public directory as well.
83
+ **Important** in rails 5 there is also a base `ApplicationRecord` class, that all other models are built from. This class must be moved to `app/hyperloop/models` directory as well.
82
84
 
83
85
  If you don't already have a simple component to play with, here is a simple one (make sure you added the Word model):
84
86
 
85
87
  ```ruby
86
88
  # app/views/components/app.rb
87
- class App < React::Component::Base
89
+ class App < Hyperloop::Component
88
90
 
89
91
  def add_new_word
90
92
  # for fun we will use setgetgo.com to get random words!
@@ -128,3 +130,5 @@ Fire up rails with `bundle exec rails s` and open your app in a couple of browse
128
130
  You can also fire up a rails console, and then for example do a `Word.new(text: "Hello").save` and again see any browsers updating.
129
131
 
130
132
  If you want to go into more details with the example check out [words-example](/docs/words-example.md)
133
+
134
+ TODO check link above