hyper-operation 0.5.12 → 0.99.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
data/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  <p align="center">
4
4
 
5
- <a href="http://ruby-hyperloop.io/" alt="Hyperloop" title="Hyperloop">
6
- <img width="350px" src="http://ruby-hyperloop.io/images/hyperloop-github-logo.png">
5
+ <a href="http://ruby-hyperloop.org/" alt="Hyperloop" title="Hyperloop">
6
+ <img width="350px" src="http://ruby-hyperloop.org/images/hyperloop-github-logo.png">
7
7
  </a>
8
8
 
9
9
  </p>
@@ -12,18 +12,19 @@
12
12
 
13
13
  <br>
14
14
 
15
- <a href="http://ruby-hyperloop.io/" alt="Hyperloop" title="Hyperloop">
16
- <img src="http://ruby-hyperloop.io/images/githubhyperloopbadge.png">
15
+ <a href="http://ruby-hyperloop.org/" alt="Hyperloop" title="Hyperloop">
16
+ <img src="http://ruby-hyperloop.org/images/githubhyperloopbadge.png">
17
17
  </a>
18
18
 
19
19
  <a href="https://gitter.im/ruby-hyperloop/chat" alt="Gitter chat" title="Gitter chat">
20
- <img src="http://ruby-hyperloop.io/images/githubgitterbadge.png">
20
+ <img src="http://ruby-hyperloop.org/images/githubgitterbadge.png">
21
21
  </a>
22
22
 
23
+ [![Build Status](https://travis-ci.org/ruby-hyperloop/hyper-operation.svg?branch=master)](https://travis-ci.org/ruby-hyperloop/hyper-operation)
23
24
  [![Gem Version](https://badge.fury.io/rb/hyper-operation.svg)](https://badge.fury.io/rb/hyper-operation)
24
25
 
25
26
  <p align="center">
26
- <img src="http://ruby-hyperloop.io/images/HyperOperations.png" width="100" alt="Hyper-operation">
27
+ <img src="http://ruby-hyperloop.org/images/HyperOperations.png" width="100" alt="Hyper-operation">
27
28
  </p>
28
29
 
29
30
  </div>
@@ -58,9 +59,9 @@ gem 'hyperloop'
58
59
 
59
60
  4. Follow the guidelines to start developing your application. You may find
60
61
  the following resources handy:
61
- * [Getting Started with Hyperloop](http://ruby-hyperloop.io/start/components/)
62
- * [Hyperloop Guides](http://ruby-hyperloop.io/docs/architecture)
63
- * [Hyperloop Tutorial](http://ruby-hyperloop.io/tutorials)
62
+ * [Getting Started with Hyperloop](http://ruby-hyperloop.org/start/components/)
63
+ * [Hyperloop Guides](http://ruby-hyperloop.org/docs/architecture)
64
+ * [Hyperloop Tutorial](http://ruby-hyperloop.org/tutorials)
64
65
 
65
66
  ## Community
66
67
 
data/Rakefile CHANGED
@@ -1,4 +1,12 @@
1
1
  require "bundler/gem_tasks"
2
- task :default do
3
- sh "DRIVER=ff bundle exec rspec"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ namespace :spec do
7
+ task :prepare do
8
+ sh %(cd spec/test_app; bundle exec rails db:setup)
9
+ end
4
10
  end
11
+
12
+ task :default => :spec
@@ -4,43 +4,48 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'hyper-operation/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "hyper-operation"
7
+ spec.name = 'hyper-operation'
8
8
  spec.version = Hyperloop::Operation::VERSION
9
- spec.authors = ["catmando"]
10
- spec.email = ["mitch@catprint.com"]
9
+ spec.authors = ['Mitch VanDuyn', 'Jan Biedermann']
10
+ spec.email = ['mitch@catprint.com', 'jan@kursator.com']
11
+ spec.summary = 'HyperOperations are the swiss army knife of the HyperStack'
12
+ spec.homepage = 'http://ruby-hyperloop.org'
13
+ spec.license = 'MIT'
14
+ # spec.metadata = {
15
+ # "homepage_uri" => 'http://ruby-hyperloop.org',
16
+ # "source_code_uri" => 'https://github.com/ruby-hyperloop/hyper-component'
17
+ # }
11
18
 
12
- spec.summary = %q{Compose your business logic into isomorphic commands that sanitize and validate input. Write safe, reusable, and maintainable code for Ruby and Rails app}
13
- spec.homepage = "http://ruby-hyperloop.io"
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
19
+ spec.files = `git ls-files -z`
20
+ .split("\x0")
21
+ .reject { |f| f.match(%r{^(gemfiles|examples|spec)/}) }
22
+ spec.bindir = 'exe'
18
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
- spec.require_paths = ["lib"]
24
+ spec.require_paths = ['lib']
20
25
 
26
+ spec.add_dependency 'activerecord', '>= 4.0.0'
27
+ spec.add_dependency 'hyper-component', Hyperloop::Operation::VERSION
21
28
  spec.add_dependency 'mutations'
22
- spec.add_dependency 'hyper-component', '>= 0.12.2'
23
- spec.add_dependency 'hyperloop-config', '>= 0.9.7'
24
- spec.add_dependency 'opal-activesupport'
25
- spec.add_dependency 'activerecord', '>= 0.3.0'
29
+ spec.add_dependency 'opal-activesupport', '~> 0.3.1'
26
30
 
27
- spec.add_development_dependency "bundler", "~> 1.8"
28
- spec.add_development_dependency "rake", "~> 10.0"
29
- spec.add_development_dependency 'hyper-spec'
30
- spec.add_development_dependency 'rspec-rails'
31
- spec.add_development_dependency 'rails', '~>5.0.0'
32
- spec.add_development_dependency 'opal-rails'
33
- spec.add_development_dependency 'hyper-react'
34
- spec.add_development_dependency 'opal-browser'
35
- spec.add_development_dependency 'sqlite3', '1.3.10'
36
- spec.add_development_dependency 'mysql2'
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'chromedriver-helper'
37
33
  spec.add_development_dependency 'database_cleaner'
38
- spec.add_development_dependency 'pry'
39
- spec.add_development_dependency 'rspec-wait'
34
+ spec.add_development_dependency 'hyper-spec', Hyperloop::Operation::VERSION
35
+ spec.add_development_dependency 'mysql2'
36
+ spec.add_development_dependency 'opal', '>= 0.11.0', '< 0.12.0'
37
+ spec.add_development_dependency 'opal-browser', '~> 0.2.0'
38
+ spec.add_development_dependency 'opal-rails', '~> 0.9.4'
39
+ spec.add_development_dependency 'pry-rescue'
40
40
  spec.add_development_dependency 'puma'
41
- spec.add_development_dependency 'rspec-steps'
42
41
  spec.add_development_dependency 'pusher'
43
42
  spec.add_development_dependency 'pusher-fake'
44
- spec.add_development_dependency 'timecop', '~>0.8.1'
45
-
43
+ spec.add_development_dependency 'rails', '>= 4.0.0'
44
+ spec.add_development_dependency 'rake'
45
+ spec.add_development_dependency 'react-rails', '>= 2.4.0', '< 2.5.0'
46
+ spec.add_development_dependency 'rspec-rails'
47
+ spec.add_development_dependency 'rspec-steps', '~> 2.1.1'
48
+ spec.add_development_dependency 'rspec-wait'
49
+ spec.add_development_dependency 'sqlite3'
50
+ spec.add_development_dependency 'timecop', '~> 0.8.1'
46
51
  end
@@ -1,14 +1,15 @@
1
- require "hyper-operation/version"
1
+ require 'hyper-operation/version'
2
2
  require 'hyperloop-config'
3
- Hyperloop.import 'browser/interval', client_only: true
3
+
4
4
  Hyperloop.import 'hyper-operation'
5
5
 
6
6
  if RUBY_ENGINE == 'opal'
7
7
  require 'active_support/core_ext/string'
8
8
  require 'mutations'
9
+ Mutations::HashFilter.register_additional_filter(Mutations::DuckFilter, :duck)
9
10
  require 'hyper-operation/filters/outbound_filter'
10
11
  require 'hyper-component'
11
- require 'hyper-operation/call_by_class_name'
12
+ require 'hyper-operation/http'
12
13
  require 'hyper-operation/transport/client_drivers'
13
14
  class HashWithIndifferentAccess < Hash
14
15
  end
@@ -30,6 +31,7 @@ if RUBY_ENGINE == 'opal'
30
31
  else
31
32
  require 'hyperloop-config'
32
33
  require 'mutations'
34
+ Mutations::HashFilter.register_additional_filter(Mutations::DuckFilter, :duck)
33
35
  require 'hyper-operation/filters/outbound_filter'
34
36
  require 'hyper-component'
35
37
  require 'active_record'
@@ -44,7 +46,6 @@ else
44
46
  require 'hyper-operation/delay_and_interval'
45
47
  require 'hyper-operation/exception'
46
48
  require 'hyper-operation/promise'
47
- require 'hyper-operation/call_by_class_name'
48
49
  require 'hyper-operation/railway'
49
50
  require 'hyper-operation/api'
50
51
  require 'hyper-operation/railway/dispatcher'
@@ -19,6 +19,6 @@ module Hyperloop
19
19
  _run(*args)
20
20
  end
21
21
  end
22
- Boot.receivers.each { |r| Boot.on_dispatch &r } if Boot.respond_to? :receivers
22
+ Boot.receivers.each { |r| Boot.on_dispatch(&r) } if Boot.respond_to? :receivers
23
23
  end
24
24
  end
@@ -3,7 +3,7 @@ module Hyperloop
3
3
  isolate_namespace Hyperloop
4
4
  config.generators do |g|
5
5
  g.test_framework :rspec, :fixture => false
6
- g.fixture_replacement :factory_girl, :dir => 'spec/factories'
6
+ g.fixture_replacement :factory_bot, :dir => 'spec/factories'
7
7
  g.assets false
8
8
  g.helper false
9
9
  end
@@ -0,0 +1,309 @@
1
+ module Hyperloop
2
+ # {HTTP} is used to perform a `XMLHttpRequest` in ruby. It is a simple wrapper
3
+ # around `XMLHttpRequest`
4
+ #
5
+ # # Making requests
6
+ #
7
+ # To create a simple request, {HTTP} exposes class level methods to specify
8
+ # the HTTP action you wish to perform. Each action accepts the url for the
9
+ # request, as well as optional arguments passed as a hash:
10
+ #
11
+ # HTTP.get("/users/1.json")
12
+ # HTTP.post("/users", payload: data)
13
+ #
14
+ # The supported `HTTP` actions are:
15
+ #
16
+ # * {HTTP.get}
17
+ # * {HTTP.post}
18
+ # * {HTTP.put}
19
+ # * {HTTP.delete}
20
+ # * {HTTP.patch}
21
+ # * {HTTP.head}
22
+ #
23
+ # # Handling responses
24
+ #
25
+ # Responses can be handled using either a simple block callback, or using a
26
+ # {Promise} returned by the request.
27
+ #
28
+ # ## Using a block
29
+ #
30
+ # All HTTP action methods accept a block which can be used as a simple
31
+ # handler for the request. The block will be called for both successful as well
32
+ # as unsuccessful requests.
33
+ #
34
+ # HTTP.get("/users/1") do |request|
35
+ # puts "the request has completed!"
36
+ # end
37
+ #
38
+ # This `request` object will simply be the instance of the {HTTP} class which
39
+ # wraps the native `XMLHttpRequest`. {HTTP#ok?} can be used to quickly determine
40
+ # if the request was successful.
41
+ #
42
+ # HTTP.get("/users/1") do |request|
43
+ # if request.ok?
44
+ # puts "request was success"
45
+ # else
46
+ # puts "something went wrong with request"
47
+ # end
48
+ # end
49
+ #
50
+ # The {HTTP} instance will always be the only object passed to the block.
51
+ #
52
+ # ## Using a Promise
53
+ #
54
+ # If no block is given to one of the action methods, then a {Promise} is
55
+ # returned instead. See the standard library for more information on Promises.
56
+ #
57
+ # HTTP.get("/users/1").then do |req|
58
+ # puts "response ok!"
59
+ # end.fail do |req|
60
+ # puts "response was not ok"
61
+ # end
62
+ #
63
+ # When using a {Promise}, both success and failure handlers will be passed the
64
+ # {HTTP} instance.
65
+ #
66
+ # # Accessing Response Data
67
+ #
68
+ # All data returned from an HTTP request can be accessed via the {HTTP} object
69
+ # passed into the block or promise handlers.
70
+ #
71
+ # - {#ok?} - returns `true` or `false`, if request was a success (or not).
72
+ # - {#body} - returns the raw text response of the request
73
+ # - {#status_code} - returns the raw {HTTP} status code as integer
74
+ # - {#json} - tries to convert the body response into a JSON object
75
+ class HTTP
76
+ # All valid {HTTP} action methods this class accepts.
77
+ #
78
+ # @see HTTP.get
79
+ # @see HTTP.post
80
+ # @see HTTP.put
81
+ # @see HTTP.delete
82
+ # @see HTTP.patch
83
+ # @see HTTP.head
84
+ ACTIONS = %w[get post put delete patch head]
85
+
86
+ # @!method self.get(url, options = {}, &block)
87
+ #
88
+ # Create a {HTTP} `get` request.
89
+ #
90
+ # @example
91
+ # HTTP.get("/foo") do |req|
92
+ # puts "got data: #{req.data}"
93
+ # end
94
+ #
95
+ # @param url [String] url for request
96
+ # @param options [Hash] any request options
97
+ # @yield [self] optional block to handle response
98
+ # @return [Promise, nil] optionally returns a promise
99
+
100
+ # @!method self.post(url, options = {}, &block)
101
+ #
102
+ # Create a {HTTP} `post` request. Post data can be supplied using the
103
+ # `payload` options. Usually this will be a hash which will get serialized
104
+ # into a native javascript object.
105
+ #
106
+ # @example
107
+ # HTTP.post("/bar", payload: data) do |req|
108
+ # puts "got response"
109
+ # end
110
+ #
111
+ # @param url [String] url for request
112
+ # @param options [Hash] optional request options
113
+ # @yield [self] optional block to yield for response
114
+ # @return [Promise, nil] returns a {Promise} unless block given
115
+
116
+ # @!method self.put(url, options = {}, &block)
117
+
118
+ # @!method self.delete(url, options = {}, &block)
119
+
120
+ # @!method self.patch(url, options = {}, &block)
121
+
122
+ # @!method self.head(url, options = {}, &block)
123
+
124
+ ACTIONS.each do |action|
125
+ define_singleton_method(action) do |url, options = {}, &block|
126
+ new.send(action, url, options, block)
127
+ end
128
+
129
+ define_method(action) do |url, options = {}, &block|
130
+ send(action, url, options, block)
131
+ end
132
+ end
133
+
134
+ attr_reader :body, :error_message, :method, :status_code, :url, :xhr
135
+
136
+ def initialize
137
+ @ok = true
138
+ end
139
+
140
+ def self.active?
141
+ jquery_active_requests = 0
142
+ %x{
143
+ if (typeof jQuery !== "undefined" && typeof jQuery.active !== "undefined" && jQuery.active !== null) {
144
+ jquery_active_requests = jQuery.active;
145
+ }
146
+ }
147
+ (jquery_active_requests + @active_requests) > 0
148
+ end
149
+
150
+ def self.active_requests
151
+ @active_requests ||= 0
152
+ @active_requests
153
+ end
154
+
155
+ def self.incr_active_requests
156
+ @active_requests ||= 0
157
+ @active_requests += 1
158
+ end
159
+
160
+ def self.decr_active_requests
161
+ @active_requests ||= 0
162
+ @active_requests -= 1
163
+ if @active_requests < 0
164
+ `console.log("Ooops, Hyperloop::HTTP active_requests out of sync!")`
165
+ @active_requests = 0
166
+ end
167
+ end
168
+
169
+ def send(method, url, options, block)
170
+ @method = method
171
+ @url = url
172
+ @payload = options.delete :payload
173
+ @handler = block
174
+ %x{
175
+ var payload_to_send = null;
176
+ var content_type = null;
177
+ if (typeof(this.payload) === 'string') {
178
+ payload_to_send = this.payload;
179
+ }
180
+ else if (this.payload != nil) {
181
+ payload_to_send = this.payload.$to_json();
182
+ content_type = 'application/json';
183
+ }
184
+
185
+ var xhr = new XMLHttpRequest();
186
+
187
+ xhr.onreadystatechange = function() {
188
+ if(xhr.readyState === XMLHttpRequest.DONE) {
189
+ self.$class().$decr_active_requests();
190
+ if ((xhr.status >= 200 && xhr.status < 300) || xhr.status == 304) {
191
+ return #{succeed(`xhr.responseText`, `xhr.status`, `xhr`)};
192
+ } else {
193
+ return #{fail(`xhr`, `xhr.status`, `xhr.statusText`)};
194
+ }
195
+ }
196
+ }
197
+ xhr.open(this.method.toUpperCase(), this.url);
198
+ if (payload_to_send !== null && content_type !== null) {
199
+ xhr.setRequestHeader("Content-Type", content_type);
200
+ }
201
+ if (options["$has_key?"]("headers")) {
202
+ var headers = options['$[]']("headers");
203
+ var keys = headers.$keys();
204
+ var keys_length = keys.length;
205
+ for (var i=0; i < keys_length; i++) {
206
+ xhr.setRequestHeader( keys[i], headers['$[]'](keys[i]) );
207
+ }
208
+ }
209
+ if (payload_to_send !== null) {
210
+ self.$class().$incr_active_requests();
211
+ xhr.send(payload_to_send);
212
+ } else {
213
+ self.$class().$incr_active_requests();
214
+ xhr.send();
215
+ }
216
+ }
217
+
218
+ @handler ? self : promise
219
+ end
220
+
221
+ # Parses the http response body through json. If the response is not
222
+ # valid JSON then an error will very likely be thrown.
223
+ #
224
+ # @example Getting JSON content
225
+ # HTTP.get("api.json") do |response|
226
+ # puts response.json
227
+ # end
228
+ #
229
+ # # => {"key" => 1, "bar" => 2, ... }
230
+ #
231
+ # @return [Hash, Array] returns the parsed json
232
+ def json
233
+ @json ||= JSON.parse(@body)
234
+ end
235
+
236
+ # Returns true if the request succeeded, false otherwise.
237
+ #
238
+ # @example
239
+ # HTTP.get("/some/url") do |response|
240
+ # if response.ok?
241
+ # alert "Yay!"
242
+ # else
243
+ # alert "Aww :("
244
+ # end
245
+ #
246
+ # @return [true, false] true if request was successful
247
+ def ok?
248
+ @ok
249
+ end
250
+
251
+ # Returns the value of the specified response header.
252
+ #
253
+ # @param key [String] name of the header to get
254
+ # @return [String] value of the header
255
+ # @return [nil] if the header +key+ was not in the response
256
+ def get_header(key)
257
+ %x{
258
+ var value = #@xhr.getResponseHeader(#{key});
259
+ return (value === null) ? nil : value;
260
+ }
261
+ end
262
+
263
+ def inspect
264
+ "#<HTTP @url=#{@url} @method=#{@method}>"
265
+ end
266
+
267
+ private
268
+
269
+ def promise
270
+ return @promise if @promise
271
+
272
+ @promise = Promise.new.tap { |promise|
273
+ @handler = proc { |res|
274
+ if res.ok?
275
+ promise.resolve res
276
+ else
277
+ promise.reject res
278
+ end
279
+ }
280
+ }
281
+ end
282
+
283
+ def succeed(data, status, xhr)
284
+ %x{
285
+ #@body = data;
286
+ #@xhr = xhr;
287
+ #@status_code = xhr.status;
288
+
289
+ if (typeof(data) === 'object') {
290
+ #@json = #{ JSON.from_object `data` };
291
+ }
292
+ }
293
+
294
+ @handler.call self if @handler
295
+ end
296
+
297
+ def fail(xhr, status, error)
298
+ %x{
299
+ #@body = xhr.responseText;
300
+ #@xhr = xhr;
301
+ #@status_code = xhr.status;
302
+ }
303
+
304
+ @ok = false
305
+ @handler.call self if @handler
306
+ end
307
+ end
308
+
309
+ end