hyper-operation 0.5.12 → 0.99.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (277) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -1
  3. data/.travis.yml +33 -0
  4. data/DOCS-POLICIES.md +93 -0
  5. data/DOCS.md +1 -1
  6. data/Gemfile +5 -1
  7. data/Gemfile.lock +379 -0
  8. data/README.md +10 -9
  9. data/Rakefile +10 -2
  10. data/hyper-operation.gemspec +34 -29
  11. data/lib/hyper-operation.rb +5 -4
  12. data/lib/hyper-operation/boot.rb +1 -1
  13. data/lib/hyper-operation/engine.rb +1 -1
  14. data/lib/hyper-operation/http.rb +309 -0
  15. data/lib/hyper-operation/railway/params_wrapper.rb +1 -0
  16. data/lib/hyper-operation/server_op.rb +83 -18
  17. data/lib/hyper-operation/transport/client_drivers.rb +71 -28
  18. data/lib/hyper-operation/transport/connection.rb +22 -20
  19. data/lib/hyper-operation/transport/hyperloop.rb +1 -1
  20. data/lib/hyper-operation/transport/hyperloop_controller.rb +6 -1
  21. data/lib/hyper-operation/transport/policy.rb +78 -13
  22. data/lib/hyper-operation/version.rb +1 -1
  23. metadata +95 -319
  24. data/CODE_OF_CONDUCT.md +0 -49
  25. data/examples/chat-app/.gitignore +0 -21
  26. data/examples/chat-app/Gemfile +0 -57
  27. data/examples/chat-app/Gemfile.lock +0 -283
  28. data/examples/chat-app/README.md +0 -3
  29. data/examples/chat-app/Rakefile +0 -6
  30. data/examples/chat-app/app/assets/config/manifest.js +0 -3
  31. data/examples/chat-app/app/assets/images/.keep +0 -0
  32. data/examples/chat-app/app/assets/javascripts/application.js +0 -3
  33. data/examples/chat-app/app/assets/javascripts/cable.js +0 -13
  34. data/examples/chat-app/app/assets/javascripts/channels/.keep +0 -0
  35. data/examples/chat-app/app/assets/stylesheets/application.css +0 -15
  36. data/examples/chat-app/app/channels/application_cable/channel.rb +0 -4
  37. data/examples/chat-app/app/channels/application_cable/connection.rb +0 -4
  38. data/examples/chat-app/app/controllers/application_controller.rb +0 -3
  39. data/examples/chat-app/app/controllers/concerns/.keep +0 -0
  40. data/examples/chat-app/app/controllers/home_controller.rb +0 -5
  41. data/examples/chat-app/app/helpers/application_helper.rb +0 -2
  42. data/examples/chat-app/app/hyperloop/components/app.rb +0 -11
  43. data/examples/chat-app/app/hyperloop/components/formatted_div.rb +0 -13
  44. data/examples/chat-app/app/hyperloop/components/input_box.rb +0 -29
  45. data/examples/chat-app/app/hyperloop/components/message.rb +0 -29
  46. data/examples/chat-app/app/hyperloop/components/messages.rb +0 -9
  47. data/examples/chat-app/app/hyperloop/components/nav.rb +0 -30
  48. data/examples/chat-app/app/hyperloop/operations/operations.rb +0 -56
  49. data/examples/chat-app/app/hyperloop/stores/message_store.rb +0 -23
  50. data/examples/chat-app/app/models/application_record.rb +0 -3
  51. data/examples/chat-app/app/models/concerns/.keep +0 -0
  52. data/examples/chat-app/app/models/models.rb +0 -2
  53. data/examples/chat-app/app/models/public/.keep +0 -0
  54. data/examples/chat-app/app/models/public/announcement.rb +0 -8
  55. data/examples/chat-app/app/policies/application_policy.rb +0 -5
  56. data/examples/chat-app/app/views/layouts/application.html.erb +0 -51
  57. data/examples/chat-app/bin/bundle +0 -3
  58. data/examples/chat-app/bin/rails +0 -9
  59. data/examples/chat-app/bin/rake +0 -9
  60. data/examples/chat-app/bin/setup +0 -34
  61. data/examples/chat-app/bin/spring +0 -17
  62. data/examples/chat-app/bin/update +0 -29
  63. data/examples/chat-app/config.ru +0 -5
  64. data/examples/chat-app/config/application.rb +0 -13
  65. data/examples/chat-app/config/boot.rb +0 -3
  66. data/examples/chat-app/config/cable.yml +0 -9
  67. data/examples/chat-app/config/database.yml +0 -25
  68. data/examples/chat-app/config/environment.rb +0 -5
  69. data/examples/chat-app/config/environments/development.rb +0 -56
  70. data/examples/chat-app/config/environments/production.rb +0 -86
  71. data/examples/chat-app/config/environments/test.rb +0 -42
  72. data/examples/chat-app/config/initializers/application_controller_renderer.rb +0 -6
  73. data/examples/chat-app/config/initializers/assets.rb +0 -11
  74. data/examples/chat-app/config/initializers/backtrace_silencers.rb +0 -7
  75. data/examples/chat-app/config/initializers/cookies_serializer.rb +0 -5
  76. data/examples/chat-app/config/initializers/filter_parameter_logging.rb +0 -4
  77. data/examples/chat-app/config/initializers/hyperloop.rb +0 -4
  78. data/examples/chat-app/config/initializers/inflections.rb +0 -16
  79. data/examples/chat-app/config/initializers/mime_types.rb +0 -4
  80. data/examples/chat-app/config/initializers/new_framework_defaults.rb +0 -24
  81. data/examples/chat-app/config/initializers/session_store.rb +0 -3
  82. data/examples/chat-app/config/initializers/wrap_parameters.rb +0 -14
  83. data/examples/chat-app/config/locales/en.yml +0 -23
  84. data/examples/chat-app/config/puma.rb +0 -47
  85. data/examples/chat-app/config/routes.rb +0 -5
  86. data/examples/chat-app/config/secrets.yml +0 -22
  87. data/examples/chat-app/config/spring.rb +0 -6
  88. data/examples/chat-app/db/seeds.rb +0 -7
  89. data/examples/chat-app/lib/assets/.keep +0 -0
  90. data/examples/chat-app/lib/tasks/.keep +0 -0
  91. data/examples/chat-app/log/.keep +0 -0
  92. data/examples/chat-app/public/404.html +0 -67
  93. data/examples/chat-app/public/422.html +0 -67
  94. data/examples/chat-app/public/500.html +0 -66
  95. data/examples/chat-app/public/apple-touch-icon-precomposed.png +0 -0
  96. data/examples/chat-app/public/apple-touch-icon.png +0 -0
  97. data/examples/chat-app/public/favicon.ico +0 -0
  98. data/examples/chat-app/public/robots.txt +0 -5
  99. data/examples/chat-app/test/controllers/.keep +0 -0
  100. data/examples/chat-app/test/fixtures/.keep +0 -0
  101. data/examples/chat-app/test/fixtures/files/.keep +0 -0
  102. data/examples/chat-app/test/helpers/.keep +0 -0
  103. data/examples/chat-app/test/integration/.keep +0 -0
  104. data/examples/chat-app/test/mailers/.keep +0 -0
  105. data/examples/chat-app/test/models/.keep +0 -0
  106. data/examples/chat-app/test/test_helper.rb +0 -10
  107. data/examples/chat-app/tmp/.keep +0 -0
  108. data/examples/chat-app/vendor/assets/javascripts/.keep +0 -0
  109. data/examples/chat-app/vendor/assets/stylesheets/.keep +0 -0
  110. data/examples/five-letter-word-game/.gitignore +0 -21
  111. data/examples/five-letter-word-game/Gemfile +0 -62
  112. data/examples/five-letter-word-game/Gemfile.lock +0 -291
  113. data/examples/five-letter-word-game/README.md +0 -24
  114. data/examples/five-letter-word-game/Rakefile +0 -6
  115. data/examples/five-letter-word-game/app/assets/config/manifest.js +0 -3
  116. data/examples/five-letter-word-game/app/assets/images/.keep +0 -0
  117. data/examples/five-letter-word-game/app/assets/javascripts/application.js +0 -4
  118. data/examples/five-letter-word-game/app/assets/javascripts/cable.js +0 -13
  119. data/examples/five-letter-word-game/app/assets/javascripts/channels/.keep +0 -0
  120. data/examples/five-letter-word-game/app/assets/stylesheets/application.css +0 -15
  121. data/examples/five-letter-word-game/app/channels/application_cable/channel.rb +0 -4
  122. data/examples/five-letter-word-game/app/channels/application_cable/connection.rb +0 -4
  123. data/examples/five-letter-word-game/app/controllers/application_controller.rb +0 -14
  124. data/examples/five-letter-word-game/app/controllers/concerns/.keep +0 -0
  125. data/examples/five-letter-word-game/app/controllers/home_controller.rb +0 -5
  126. data/examples/five-letter-word-game/app/helpers/application_helper.rb +0 -2
  127. data/examples/five-letter-word-game/app/hyperloop/components/app.rb +0 -65
  128. data/examples/five-letter-word-game/app/hyperloop/components/guesses.rb +0 -8
  129. data/examples/five-letter-word-game/app/hyperloop/components/input_word.rb +0 -13
  130. data/examples/five-letter-word-game/app/hyperloop/models/user.rb +0 -27
  131. data/examples/five-letter-word-game/app/hyperloop/operations/ops.rb +0 -115
  132. data/examples/five-letter-word-game/app/hyperloop/stores/store.rb +0 -120
  133. data/examples/five-letter-word-game/app/jobs/application_job.rb +0 -2
  134. data/examples/five-letter-word-game/app/mailers/application_mailer.rb +0 -4
  135. data/examples/five-letter-word-game/app/models/application_record.rb +0 -3
  136. data/examples/five-letter-word-game/app/models/concerns/.keep +0 -0
  137. data/examples/five-letter-word-game/app/policies/hyperloop/application_policy.rb +0 -3
  138. data/examples/five-letter-word-game/app/policies/user_policy.rb +0 -4
  139. data/examples/five-letter-word-game/app/views/layouts/application.html.erb +0 -14
  140. data/examples/five-letter-word-game/app/views/layouts/mailer.html.erb +0 -13
  141. data/examples/five-letter-word-game/app/views/layouts/mailer.text.erb +0 -1
  142. data/examples/five-letter-word-game/bin/bundle +0 -3
  143. data/examples/five-letter-word-game/bin/rails +0 -9
  144. data/examples/five-letter-word-game/bin/rake +0 -9
  145. data/examples/five-letter-word-game/bin/setup +0 -34
  146. data/examples/five-letter-word-game/bin/spring +0 -17
  147. data/examples/five-letter-word-game/bin/update +0 -29
  148. data/examples/five-letter-word-game/config.ru +0 -5
  149. data/examples/five-letter-word-game/config/application.rb +0 -12
  150. data/examples/five-letter-word-game/config/boot.rb +0 -3
  151. data/examples/five-letter-word-game/config/cable.yml +0 -9
  152. data/examples/five-letter-word-game/config/database.yml +0 -46
  153. data/examples/five-letter-word-game/config/environment.rb +0 -5
  154. data/examples/five-letter-word-game/config/environments/development.rb +0 -56
  155. data/examples/five-letter-word-game/config/environments/production.rb +0 -86
  156. data/examples/five-letter-word-game/config/environments/test.rb +0 -42
  157. data/examples/five-letter-word-game/config/initializers/application_controller_renderer.rb +0 -6
  158. data/examples/five-letter-word-game/config/initializers/assets.rb +0 -15
  159. data/examples/five-letter-word-game/config/initializers/backtrace_silencers.rb +0 -7
  160. data/examples/five-letter-word-game/config/initializers/cookies_serializer.rb +0 -5
  161. data/examples/five-letter-word-game/config/initializers/filter_parameter_logging.rb +0 -4
  162. data/examples/five-letter-word-game/config/initializers/hyperloop.rb +0 -19
  163. data/examples/five-letter-word-game/config/initializers/inflections.rb +0 -16
  164. data/examples/five-letter-word-game/config/initializers/mime_types.rb +0 -4
  165. data/examples/five-letter-word-game/config/initializers/new_framework_defaults.rb +0 -24
  166. data/examples/five-letter-word-game/config/initializers/session_store.rb +0 -3
  167. data/examples/five-letter-word-game/config/initializers/wrap_parameters.rb +0 -14
  168. data/examples/five-letter-word-game/config/locales/en.yml +0 -23
  169. data/examples/five-letter-word-game/config/puma.rb +0 -47
  170. data/examples/five-letter-word-game/config/routes.rb +0 -5
  171. data/examples/five-letter-word-game/config/secrets.yml +0 -22
  172. data/examples/five-letter-word-game/config/spring.rb +0 -6
  173. data/examples/five-letter-word-game/db/schema.rb +0 -28
  174. data/examples/five-letter-word-game/db/seeds.rb +0 -7
  175. data/examples/five-letter-word-game/lib/assets/.keep +0 -0
  176. data/examples/five-letter-word-game/lib/tasks/.keep +0 -0
  177. data/examples/five-letter-word-game/log/.keep +0 -0
  178. data/examples/five-letter-word-game/public/404.html +0 -67
  179. data/examples/five-letter-word-game/public/422.html +0 -67
  180. data/examples/five-letter-word-game/public/500.html +0 -66
  181. data/examples/five-letter-word-game/public/apple-touch-icon-precomposed.png +0 -0
  182. data/examples/five-letter-word-game/public/apple-touch-icon.png +0 -0
  183. data/examples/five-letter-word-game/public/favicon.ico +0 -0
  184. data/examples/five-letter-word-game/public/robots.txt +0 -5
  185. data/examples/five-letter-word-game/test/controllers/.keep +0 -0
  186. data/examples/five-letter-word-game/test/fixtures/.keep +0 -0
  187. data/examples/five-letter-word-game/test/fixtures/files/.keep +0 -0
  188. data/examples/five-letter-word-game/test/helpers/.keep +0 -0
  189. data/examples/five-letter-word-game/test/integration/.keep +0 -0
  190. data/examples/five-letter-word-game/test/mailers/.keep +0 -0
  191. data/examples/five-letter-word-game/test/models/.keep +0 -0
  192. data/examples/five-letter-word-game/test/test_helper.rb +0 -10
  193. data/examples/five-letter-word-game/tmp/.keep +0 -0
  194. data/examples/five-letter-word-game/vendor/assets/javascripts/.keep +0 -0
  195. data/examples/five-letter-word-game/vendor/assets/stylesheets/.keep +0 -0
  196. data/examples/smoke_test/.gitignore +0 -21
  197. data/examples/smoke_test/Gemfile +0 -59
  198. data/examples/smoke_test/Gemfile.lock +0 -289
  199. data/examples/smoke_test/README.md +0 -24
  200. data/examples/smoke_test/Rakefile +0 -6
  201. data/examples/smoke_test/app/assets/config/manifest.js +0 -3
  202. data/examples/smoke_test/app/assets/images/.keep +0 -0
  203. data/examples/smoke_test/app/assets/javascripts/application.js +0 -15
  204. data/examples/smoke_test/app/assets/javascripts/cable.js +0 -13
  205. data/examples/smoke_test/app/assets/javascripts/channels/.keep +0 -0
  206. data/examples/smoke_test/app/assets/stylesheets/application.css +0 -15
  207. data/examples/smoke_test/app/channels/application_cable/channel.rb +0 -4
  208. data/examples/smoke_test/app/channels/application_cable/connection.rb +0 -4
  209. data/examples/smoke_test/app/controllers/app_controller.rb +0 -5
  210. data/examples/smoke_test/app/controllers/application_controller.rb +0 -3
  211. data/examples/smoke_test/app/helpers/application_helper.rb +0 -2
  212. data/examples/smoke_test/app/hyperloop/components/hello.rb +0 -25
  213. data/examples/smoke_test/app/hyperloop/operations/operations/nested_send_to_all.rb +0 -7
  214. data/examples/smoke_test/app/hyperloop/operations/send_to_all.rb +0 -6
  215. data/examples/smoke_test/app/hyperloop/stores/messages.rb +0 -4
  216. data/examples/smoke_test/app/jobs/application_job.rb +0 -2
  217. data/examples/smoke_test/app/mailers/application_mailer.rb +0 -4
  218. data/examples/smoke_test/app/models/application_record.rb +0 -3
  219. data/examples/smoke_test/app/models/concerns/.keep +0 -0
  220. data/examples/smoke_test/app/policies/application_policy.rb +0 -8
  221. data/examples/smoke_test/app/views/layouts/application.html.erb +0 -14
  222. data/examples/smoke_test/app/views/layouts/mailer.html.erb +0 -13
  223. data/examples/smoke_test/app/views/layouts/mailer.text.erb +0 -1
  224. data/examples/smoke_test/bin/bundle +0 -3
  225. data/examples/smoke_test/bin/rails +0 -9
  226. data/examples/smoke_test/bin/rake +0 -9
  227. data/examples/smoke_test/bin/setup +0 -34
  228. data/examples/smoke_test/bin/spring +0 -17
  229. data/examples/smoke_test/bin/update +0 -29
  230. data/examples/smoke_test/config.ru +0 -5
  231. data/examples/smoke_test/config/application.rb +0 -15
  232. data/examples/smoke_test/config/boot.rb +0 -3
  233. data/examples/smoke_test/config/cable.yml +0 -9
  234. data/examples/smoke_test/config/database.yml +0 -25
  235. data/examples/smoke_test/config/environment.rb +0 -5
  236. data/examples/smoke_test/config/environments/development.rb +0 -54
  237. data/examples/smoke_test/config/environments/production.rb +0 -86
  238. data/examples/smoke_test/config/environments/test.rb +0 -42
  239. data/examples/smoke_test/config/initializers/application_controller_renderer.rb +0 -6
  240. data/examples/smoke_test/config/initializers/assets.rb +0 -11
  241. data/examples/smoke_test/config/initializers/backtrace_silencers.rb +0 -7
  242. data/examples/smoke_test/config/initializers/cookies_serializer.rb +0 -5
  243. data/examples/smoke_test/config/initializers/filter_parameter_logging.rb +0 -4
  244. data/examples/smoke_test/config/initializers/hyperloop.rb +0 -32
  245. data/examples/smoke_test/config/initializers/inflections.rb +0 -16
  246. data/examples/smoke_test/config/initializers/mime_types.rb +0 -4
  247. data/examples/smoke_test/config/initializers/new_framework_defaults.rb +0 -24
  248. data/examples/smoke_test/config/initializers/session_store.rb +0 -3
  249. data/examples/smoke_test/config/initializers/wrap_parameters.rb +0 -14
  250. data/examples/smoke_test/config/locales/en.yml +0 -23
  251. data/examples/smoke_test/config/puma.rb +0 -47
  252. data/examples/smoke_test/config/routes.rb +0 -5
  253. data/examples/smoke_test/config/secrets.yml +0 -22
  254. data/examples/smoke_test/config/spring.rb +0 -6
  255. data/examples/smoke_test/db/seeds.rb +0 -7
  256. data/examples/smoke_test/lib/assets/.keep +0 -0
  257. data/examples/smoke_test/lib/tasks/.keep +0 -0
  258. data/examples/smoke_test/log/.keep +0 -0
  259. data/examples/smoke_test/public/404.html +0 -67
  260. data/examples/smoke_test/public/422.html +0 -67
  261. data/examples/smoke_test/public/500.html +0 -66
  262. data/examples/smoke_test/public/apple-touch-icon-precomposed.png +0 -0
  263. data/examples/smoke_test/public/apple-touch-icon.png +0 -0
  264. data/examples/smoke_test/public/favicon.ico +0 -0
  265. data/examples/smoke_test/public/robots.txt +0 -5
  266. data/examples/smoke_test/test/controllers/.keep +0 -0
  267. data/examples/smoke_test/test/fixtures/.keep +0 -0
  268. data/examples/smoke_test/test/fixtures/files/.keep +0 -0
  269. data/examples/smoke_test/test/helpers/.keep +0 -0
  270. data/examples/smoke_test/test/integration/.keep +0 -0
  271. data/examples/smoke_test/test/mailers/.keep +0 -0
  272. data/examples/smoke_test/test/models/.keep +0 -0
  273. data/examples/smoke_test/test/test_helper.rb +0 -10
  274. data/examples/smoke_test/tmp/.keep +0 -0
  275. data/examples/smoke_test/vendor/assets/javascripts/.keep +0 -0
  276. data/examples/smoke_test/vendor/assets/stylesheets/.keep +0 -0
  277. data/lib/hyper-operation/call_by_class_name.rb +0 -60
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 05753e5d4f4a534d04de4875a1ba3d2a6ced3772
4
- data.tar.gz: 61a5654f0bf9e3e222bb1a8b42e942c1985cf4f8
2
+ SHA256:
3
+ metadata.gz: 8c7fa9d96880d409b3869de5ce0cde0ad9e92977cf76e7987ac508fbd3c724ba
4
+ data.tar.gz: e9a5b22277beb20b54dfedc09876ac45b65892557b48dd5e436318c93b73a32d
5
5
  SHA512:
6
- metadata.gz: a79a6f25eed5763ece0a6d9324f42c595bfd1e78920ca58824dc30f32d3d37e363b25f3ea79baf89e3d42c08e79c8b245b1eb404f951f463f816a0a008c1b566
7
- data.tar.gz: 2ff2869def836d2a54b64d5776dfcb091925b15a525252c14dc6f568bb9125786ef6d6101bc656119c5e89833f0149cea3a7794f2fbf9fd9eb964ca1af7d9011
6
+ metadata.gz: a822149b518d86b889536971f9c0976b2b69aa85ba52b26053f3c4c661ff54f820a213440e77bbff1e6028df64589b2a8618d43d20b5bb869045e57f567bf323
7
+ data.tar.gz: 91791060f154b31dc31fb0223e9b42fbed20ad53cce9d1b2e148ce83eafb0c5ce693c22d56b4ca7f333b8901bac0dfee39e06c15af799f440114ac7005b06de1
data/.gitignore CHANGED
@@ -5,6 +5,8 @@ capybara-*.html
5
5
  /tmp
6
6
  /db/*.sqlite3
7
7
  /db/*.sqlite3-journal
8
+ /spec/test_app/db/*.sqlite3
9
+ /spec/test_app/db/*.sqlite3-journal
8
10
  /public/system
9
11
  /coverage/
10
12
  /spec/tmp
@@ -49,4 +51,5 @@ bower.json
49
51
  *.gem
50
52
 
51
53
  .idea
52
- *.iml
54
+ .vscode
55
+ *.iml
@@ -0,0 +1,33 @@
1
+ dist: trusty
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.4.4
6
+ - 2.5.1
7
+ - ruby-head
8
+ services:
9
+ - mysql
10
+ env:
11
+ - DRIVER=google-chrome TZ=Europe/Berlin
12
+ matrix:
13
+ fast_finish: true
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ before_install:
17
+ - if [[ "$DRIVER" == "google-chrome" ]]; then wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -; fi
18
+ - if [[ "$DRIVER" == "google-chrome" ]]; then echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list; fi
19
+ - if [[ "$DRIVER" == "google-chrome" ]]; then sudo apt-get update -qq && sudo apt-get install -qq -y google-chrome-stable; fi
20
+ - gem install bundler
21
+ before_script:
22
+ - cd spec/test_app
23
+ - bundle install --jobs=3 --retry=3
24
+ - bundle exec rails db:setup
25
+ - cd ../../
26
+ - if [[ "$DRIVER" == "google-chrome" ]]; then bundle exec chromedriver-update; fi
27
+ - if [[ "$DRIVER" == "google-chrome" ]]; then ls -lR ~/.chromedriver-helper/; fi
28
+ - if [[ "$DRIVER" == "google-chrome" ]]; then bundle exec chromedriver --version; fi
29
+ - if [[ "$DRIVER" == "google-chrome" ]]; then google-chrome --version; fi
30
+ - if [[ "$DRIVER" == "google-chrome" ]]; then which google-chrome; fi
31
+ script: bundle exec rspec
32
+ gemfile:
33
+ - gemfiles/opal_0_11_react-rails_2_4.gemfile
@@ -407,6 +407,99 @@ class MessagePolicy
407
407
  end
408
408
  ```
409
409
 
410
+ ## Regulating Scopes
411
+
412
+ Consider the following expression (evaluated on the client)
413
+
414
+ ```ruby
415
+ Order.for_vip_customers.count
416
+ ```
417
+
418
+ Even though the policy system will prevent us from looking into the actual attributes of any record, a malicioius hacker can find private information about our data if the above expression is not secured. Moreover a DOS attack could be formed by repeatedly attempting to perform a variant of `Order.all`.
419
+
420
+ To prevent this scopes and relationships can also be regulated. A scope and relationship regulation is a proc that will return either a truthy or falsy value or calls the `denied!` method. The proc is evaluated in the context of the relationship object, and the `acting_user` method is available for the proc's use in making decisions.
421
+
422
+ All the scopes in a chain are evaluated together, and permission is granted or denied as follows:
423
+
424
+ + If *any* of the regulations in a chain of scopes calls `denied!` then the remote request is aborted;
425
+ + If *any* of the regulations in a chain of scopes returns a truthy value then access is granted to the entire chain;
426
+ + If *none* of the regulations in a chain of scopes returns a truthy value then the request is aborted.
427
+
428
+ Example:
429
+
430
+ ```ruby
431
+ class Order < ApplicationRecord
432
+ regulate_scope(:for_vip_customers) { denied! unless acting_user.admin? }
433
+ regulate_scope(:active) { acting_user.admin? }
434
+ end
435
+
436
+ class User < ApplicationRecord
437
+ regulate_relationship(:orders) { self == acting_user }
438
+ end
439
+
440
+ # in component code
441
+
442
+ user.orders.count # valid if user is the acting user because the orders regulation returned true
443
+ # but will raise error if acting_user is not == user
444
+ user.orders.active.count # valid if user is the acting user or if current user is an administrator
445
+ user.orders.for_vip_customers # fails unless acting user is an admin
446
+ ```
447
+
448
+ By default all relationships and scopes (including `all` and `unscoped` have a regulation that returns nil, so unless you explicitly provide a regulation that returns true, the client can not access any scopes.
449
+
450
+ There are some short hand ways to define regulations as well:
451
+
452
+ #### Constant Regulations
453
+
454
+ If the regulation always does the same thing you can specify what to do without the block:
455
+
456
+ ```ruby
457
+ regulate_scope my_scope: :always_allow # any truthy value works
458
+ regulate_scope my_scope: :denied! # :deny or :denied work as well
459
+ regulate_relationship many_of_those: :denied! # works the same on relationships
460
+ ```
461
+
462
+ Always denying a regulation effectively makes it inaccessible except on the server.
463
+
464
+ Likewise be careful of always returning true for a scope, as this means that a hacker only needs
465
+ to include this scope in the chain to gain access to the chain. So just make sure that scopes that return
466
+ true, narrow the scope down to something you would not mind anybody seeing.
467
+
468
+ For development you can easily access everything (except regulations that explicitly invoke denied!) simply by doing this:
469
+
470
+ ```ruby
471
+ class ApplicationRecord < ActiveRecord::Base
472
+ regulate_scope all: :always_allow if Rails.env.development?
473
+ regulate_scope unscoped: :always_allow if Rails.env.development?
474
+ end
475
+ ```
476
+
477
+ #### Regulations directly on scopes and has_many relationships
478
+
479
+ You can also directly add the regulation where you declare the scope or relationship using the `regulate:` option.
480
+
481
+ ```ruby
482
+ # here is a handy scope to add to ApplicationRecord that you can attach to
483
+ # any scope chain to give admin's full access
484
+ scope :admin, ->() {}, regulate: -> () { acting_user.admin? || denied! }
485
+
486
+ # customers can always see their orders, otherwise we return nil meaning "don't know yet"
487
+ has_many :orders, regulate: -> () { acting_user == self }
488
+ ```
489
+
490
+ ## Regulating server_method and finder_method methods
491
+
492
+ The server or finder method proc will be executed in the context of the appropriate object (a record for server_method, and a relationship collection for finder_method.) Attached to this object will be the current `acting_user` method, and a `denied!` method.
493
+
494
+ You can use these methods to restrict access to server and finder methods.
495
+
496
+ ```ruby
497
+ server_method :unit_cost do
498
+ denied! unless acting_user.admin? # only admin's can see this
499
+ # continue on calculating the unit cost
500
+ end
501
+ ```
502
+
410
503
  ## Browser Initiated Change policies
411
504
 
412
505
  To allow code in the browser to create, update or destroy a model, there must be a change access policy defined for that operation.
data/DOCS.md CHANGED
@@ -204,7 +204,7 @@ class QuickCheckout < Hyperloop::Operation
204
204
  param :sku, type: String
205
205
  param qty: 1, type: Integer, minimum: 1
206
206
 
207
- step { AddItemToCart(params) }
207
+ step { AddItemToCart.run(params) }
208
208
  step ValidateUserDefaultCC
209
209
  step Checkout
210
210
  end
data/Gemfile CHANGED
@@ -1,3 +1,7 @@
1
1
  source 'https://rubygems.org'
2
-
2
+ #gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
3
+ gem 'hyper-spec', path: '../hyper-spec'
4
+ gem 'hyperloop-config', path: '../hyperloop-config'
5
+ gem 'hyper-store', path: '../hyper-store'
6
+ gem 'hyper-component', path: '../hyper-component'
3
7
  gemspec
@@ -0,0 +1,379 @@
1
+ GIT
2
+ remote: https://github.com/opal/opal-jquery.git
3
+ revision: 6249dfaf406ecd7199079b4f4d9dc67cfdf4d602
4
+ branch: master
5
+ specs:
6
+ opal-jquery (0.4.3)
7
+ opal (>= 0.10.0, < 0.12.0)
8
+
9
+ PATH
10
+ remote: ../hyper-component
11
+ specs:
12
+ hyper-component (1.0.0.lap28)
13
+ hyper-store (= 1.0.0.lap28)
14
+ hyperloop-config (= 1.0.0.lap28)
15
+ libv8 (~> 6.3.0)
16
+ mini_racer (~> 0.1.15)
17
+ opal (>= 0.11.0, < 0.12.0)
18
+ opal-activesupport (~> 0.3.1)
19
+ react-rails (>= 2.4.0, < 2.5.0)
20
+
21
+ PATH
22
+ remote: ../hyper-spec
23
+ specs:
24
+ hyper-spec (1.0.0.lap28)
25
+ capybara
26
+ chromedriver-helper (= 1.2.0)
27
+ libv8 (~> 6.3.0)
28
+ method_source
29
+ mini_racer (~> 0.1.15)
30
+ opal (>= 0.11.0, < 0.12.0)
31
+ parser (>= 2.3.3.1)
32
+ pry
33
+ rspec-rails
34
+ selenium-webdriver
35
+ timecop (~> 0.8.1)
36
+ uglifier
37
+ unparser
38
+ webdrivers
39
+
40
+ PATH
41
+ remote: ../hyper-store
42
+ specs:
43
+ hyper-store (1.0.0.lap28)
44
+ hyperloop-config (= 1.0.0.lap28)
45
+ opal (>= 0.11.0, < 0.12.0)
46
+
47
+ PATH
48
+ remote: ../hyperloop-config
49
+ specs:
50
+ hyperloop-config (1.0.0.lap28)
51
+ libv8 (~> 6.3.0)
52
+ mini_racer (~> 0.1.15)
53
+ opal (>= 0.11.0, < 0.12.0)
54
+ opal-browser (~> 0.2.0)
55
+ uglifier
56
+
57
+ PATH
58
+ remote: .
59
+ specs:
60
+ hyper-operation (1.0.0.lap28)
61
+ activerecord (>= 4.0.0)
62
+ hyper-component (= 1.0.0.lap28)
63
+ mutations
64
+ opal-activesupport (~> 0.3.1)
65
+
66
+ GEM
67
+ remote: https://rubygems.org/
68
+ specs:
69
+ abstract_type (0.0.7)
70
+ actioncable (5.2.1)
71
+ actionpack (= 5.2.1)
72
+ nio4r (~> 2.0)
73
+ websocket-driver (>= 0.6.1)
74
+ actionmailer (5.2.1)
75
+ actionpack (= 5.2.1)
76
+ actionview (= 5.2.1)
77
+ activejob (= 5.2.1)
78
+ mail (~> 2.5, >= 2.5.4)
79
+ rails-dom-testing (~> 2.0)
80
+ actionpack (5.2.1)
81
+ actionview (= 5.2.1)
82
+ activesupport (= 5.2.1)
83
+ rack (~> 2.0)
84
+ rack-test (>= 0.6.3)
85
+ rails-dom-testing (~> 2.0)
86
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
87
+ actionview (5.2.1)
88
+ activesupport (= 5.2.1)
89
+ builder (~> 3.1)
90
+ erubi (~> 1.4)
91
+ rails-dom-testing (~> 2.0)
92
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
93
+ activejob (5.2.1)
94
+ activesupport (= 5.2.1)
95
+ globalid (>= 0.3.6)
96
+ activemodel (5.2.1)
97
+ activesupport (= 5.2.1)
98
+ activerecord (5.2.1)
99
+ activemodel (= 5.2.1)
100
+ activesupport (= 5.2.1)
101
+ arel (>= 9.0)
102
+ activestorage (5.2.1)
103
+ actionpack (= 5.2.1)
104
+ activerecord (= 5.2.1)
105
+ marcel (~> 0.3.1)
106
+ activesupport (5.2.1)
107
+ concurrent-ruby (~> 1.0, >= 1.0.2)
108
+ i18n (>= 0.7, < 2)
109
+ minitest (~> 5.1)
110
+ tzinfo (~> 1.1)
111
+ adamantium (0.2.0)
112
+ ice_nine (~> 0.11.0)
113
+ memoizable (~> 0.4.0)
114
+ addressable (2.5.2)
115
+ public_suffix (>= 2.0.2, < 4.0)
116
+ archive-zip (0.11.0)
117
+ io-like (~> 0.3.0)
118
+ arel (9.0.0)
119
+ ast (2.4.0)
120
+ babel-source (5.8.35)
121
+ babel-transpiler (0.7.0)
122
+ babel-source (>= 4.0, < 6)
123
+ execjs (~> 2.0)
124
+ builder (3.2.3)
125
+ capybara (3.8.0)
126
+ addressable
127
+ mini_mime (>= 0.1.3)
128
+ nokogiri (~> 1.8)
129
+ rack (>= 1.6.0)
130
+ rack-test (>= 0.6.3)
131
+ xpath (~> 3.1)
132
+ childprocess (0.9.0)
133
+ ffi (~> 1.0, >= 1.0.11)
134
+ chromedriver-helper (1.2.0)
135
+ archive-zip (~> 0.10)
136
+ nokogiri (~> 1.8)
137
+ coderay (1.1.2)
138
+ concord (0.1.5)
139
+ adamantium (~> 0.2.0)
140
+ equalizer (~> 0.0.9)
141
+ concurrent-ruby (1.0.5)
142
+ connection_pool (2.2.2)
143
+ cookiejar (0.3.3)
144
+ crass (1.0.4)
145
+ daemons (1.2.6)
146
+ database_cleaner (1.7.0)
147
+ diff-lcs (1.3)
148
+ em-http-request (1.1.5)
149
+ addressable (>= 2.3.4)
150
+ cookiejar (!= 0.3.1)
151
+ em-socksify (>= 0.3)
152
+ eventmachine (>= 1.0.3)
153
+ http_parser.rb (>= 0.6.0)
154
+ em-socksify (0.3.2)
155
+ eventmachine (>= 1.0.0.beta.4)
156
+ em-websocket (0.5.1)
157
+ eventmachine (>= 0.12.9)
158
+ http_parser.rb (~> 0.6.0)
159
+ equalizer (0.0.11)
160
+ erubi (1.7.1)
161
+ eventmachine (1.2.7)
162
+ execjs (2.7.0)
163
+ ffi (1.9.25)
164
+ globalid (0.4.1)
165
+ activesupport (>= 4.2.0)
166
+ hike (1.2.3)
167
+ http_parser.rb (0.6.0)
168
+ httpclient (2.8.3)
169
+ i18n (1.1.0)
170
+ concurrent-ruby (~> 1.0)
171
+ ice_nine (0.11.2)
172
+ interception (0.5)
173
+ io-like (0.3.0)
174
+ jquery-rails (4.3.3)
175
+ rails-dom-testing (>= 1, < 3)
176
+ railties (>= 4.2.0)
177
+ thor (>= 0.14, < 2.0)
178
+ libv8 (6.3.292.48.1)
179
+ loofah (2.2.2)
180
+ crass (~> 1.0.2)
181
+ nokogiri (>= 1.5.9)
182
+ mail (2.7.0)
183
+ mini_mime (>= 0.1.1)
184
+ marcel (0.3.2)
185
+ mimemagic (~> 0.3.2)
186
+ memoizable (0.4.2)
187
+ thread_safe (~> 0.3, >= 0.3.1)
188
+ method_source (0.9.0)
189
+ mimemagic (0.3.2)
190
+ mini_mime (1.0.1)
191
+ mini_portile2 (2.3.0)
192
+ mini_racer (0.1.15)
193
+ libv8 (~> 6.3)
194
+ minitest (5.11.3)
195
+ multi_json (1.13.1)
196
+ mutations (0.8.3)
197
+ activesupport
198
+ mysql2 (0.5.2)
199
+ nio4r (2.3.1)
200
+ nokogiri (1.8.4)
201
+ mini_portile2 (~> 2.3.0)
202
+ opal (0.11.3)
203
+ ast (>= 2.3.0)
204
+ hike (~> 1.2)
205
+ parser (= 2.3.3.1)
206
+ sourcemap (~> 0.1.0)
207
+ opal-activesupport (0.3.1)
208
+ opal (>= 0.5.0, < 1.0.0)
209
+ opal-browser (0.2.0)
210
+ opal
211
+ paggio
212
+ opal-rails (0.9.5)
213
+ jquery-rails
214
+ opal (>= 0.11.0, < 0.12)
215
+ opal-activesupport (>= 0.0.5)
216
+ opal-jquery (~> 0.4.0)
217
+ opal-sprockets (~> 0.4.2)
218
+ rails (>= 4.1, < 6.0)
219
+ sprockets-rails (>= 2.3.3, < 4.0)
220
+ opal-sprockets (0.4.2.0.11.0.3.1)
221
+ opal (~> 0.11.0)
222
+ sprockets (~> 3.1)
223
+ tilt (>= 1.4)
224
+ paggio (0.2.6)
225
+ parser (2.3.3.1)
226
+ ast (~> 2.2)
227
+ procto (0.0.3)
228
+ pry (0.11.3)
229
+ coderay (~> 1.1.0)
230
+ method_source (~> 0.9.0)
231
+ pry-rescue (1.4.5)
232
+ interception (>= 0.5)
233
+ pry
234
+ public_suffix (3.0.3)
235
+ puma (3.12.0)
236
+ pusher (1.3.1)
237
+ httpclient (~> 2.7)
238
+ multi_json (~> 1.0)
239
+ pusher-signature (~> 0.1.8)
240
+ pusher-fake (1.10.0)
241
+ em-http-request (~> 1.1)
242
+ em-websocket (~> 0.5)
243
+ multi_json (~> 1.6)
244
+ thin (~> 1.5)
245
+ pusher-signature (0.1.8)
246
+ rack (2.0.5)
247
+ rack-test (1.1.0)
248
+ rack (>= 1.0, < 3)
249
+ rails (5.2.1)
250
+ actioncable (= 5.2.1)
251
+ actionmailer (= 5.2.1)
252
+ actionpack (= 5.2.1)
253
+ actionview (= 5.2.1)
254
+ activejob (= 5.2.1)
255
+ activemodel (= 5.2.1)
256
+ activerecord (= 5.2.1)
257
+ activestorage (= 5.2.1)
258
+ activesupport (= 5.2.1)
259
+ bundler (>= 1.3.0)
260
+ railties (= 5.2.1)
261
+ sprockets-rails (>= 2.0.0)
262
+ rails-dom-testing (2.0.3)
263
+ activesupport (>= 4.2.0)
264
+ nokogiri (>= 1.6)
265
+ rails-html-sanitizer (1.0.4)
266
+ loofah (~> 2.2, >= 2.2.2)
267
+ railties (5.2.1)
268
+ actionpack (= 5.2.1)
269
+ activesupport (= 5.2.1)
270
+ method_source
271
+ rake (>= 0.8.7)
272
+ thor (>= 0.19.0, < 2.0)
273
+ rake (12.3.1)
274
+ react-rails (2.4.7)
275
+ babel-transpiler (>= 0.7.0)
276
+ connection_pool
277
+ execjs
278
+ railties (>= 3.2)
279
+ tilt
280
+ rspec (3.8.0)
281
+ rspec-core (~> 3.8.0)
282
+ rspec-expectations (~> 3.8.0)
283
+ rspec-mocks (~> 3.8.0)
284
+ rspec-core (3.8.0)
285
+ rspec-support (~> 3.8.0)
286
+ rspec-expectations (3.8.1)
287
+ diff-lcs (>= 1.2.0, < 2.0)
288
+ rspec-support (~> 3.8.0)
289
+ rspec-mocks (3.8.0)
290
+ diff-lcs (>= 1.2.0, < 2.0)
291
+ rspec-support (~> 3.8.0)
292
+ rspec-rails (3.8.0)
293
+ actionpack (>= 3.0)
294
+ activesupport (>= 3.0)
295
+ railties (>= 3.0)
296
+ rspec-core (~> 3.8.0)
297
+ rspec-expectations (~> 3.8.0)
298
+ rspec-mocks (~> 3.8.0)
299
+ rspec-support (~> 3.8.0)
300
+ rspec-steps (2.1.1)
301
+ rspec (>= 3.0, < 3.99)
302
+ rspec-support (3.8.0)
303
+ rspec-wait (0.0.9)
304
+ rspec (>= 3, < 4)
305
+ rubyzip (1.2.2)
306
+ selenium-webdriver (3.14.0)
307
+ childprocess (~> 0.5)
308
+ rubyzip (~> 1.2)
309
+ sourcemap (0.1.1)
310
+ sprockets (3.7.2)
311
+ concurrent-ruby (~> 1.0)
312
+ rack (> 1, < 3)
313
+ sprockets-rails (3.2.1)
314
+ actionpack (>= 4.0)
315
+ activesupport (>= 4.0)
316
+ sprockets (>= 3.0.0)
317
+ sqlite3 (1.3.13)
318
+ thin (1.7.2)
319
+ daemons (~> 1.0, >= 1.0.9)
320
+ eventmachine (~> 1.0, >= 1.0.4)
321
+ rack (>= 1, < 3)
322
+ thor (0.20.0)
323
+ thread_safe (0.3.6)
324
+ tilt (2.0.8)
325
+ timecop (0.8.1)
326
+ tzinfo (1.2.5)
327
+ thread_safe (~> 0.1)
328
+ uglifier (4.1.19)
329
+ execjs (>= 0.3.0, < 3)
330
+ unparser (0.2.8)
331
+ abstract_type (~> 0.0.7)
332
+ adamantium (~> 0.2.0)
333
+ concord (~> 0.1.5)
334
+ diff-lcs (~> 1.3)
335
+ equalizer (~> 0.0.9)
336
+ parser (>= 2.3.1.2, < 2.6)
337
+ procto (~> 0.0.2)
338
+ webdrivers (3.4.0)
339
+ nokogiri (~> 1.6)
340
+ rubyzip (~> 1.0)
341
+ selenium-webdriver (~> 3.0)
342
+ websocket-driver (0.7.0)
343
+ websocket-extensions (>= 0.1.0)
344
+ websocket-extensions (0.1.3)
345
+ xpath (3.1.0)
346
+ nokogiri (~> 1.8)
347
+
348
+ PLATFORMS
349
+ ruby
350
+
351
+ DEPENDENCIES
352
+ bundler
353
+ chromedriver-helper
354
+ database_cleaner
355
+ hyper-component!
356
+ hyper-operation!
357
+ hyper-spec!
358
+ hyper-store!
359
+ hyperloop-config!
360
+ mysql2
361
+ opal (>= 0.11.0, < 0.12.0)
362
+ opal-browser (~> 0.2.0)
363
+ opal-jquery!
364
+ opal-rails (~> 0.9.4)
365
+ pry-rescue
366
+ puma
367
+ pusher
368
+ pusher-fake
369
+ rails (>= 4.0.0)
370
+ rake
371
+ react-rails (>= 2.4.0, < 2.5.0)
372
+ rspec-rails
373
+ rspec-steps (~> 2.1.1)
374
+ rspec-wait
375
+ sqlite3
376
+ timecop (~> 0.8.1)
377
+
378
+ BUNDLED WITH
379
+ 1.16.1