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.
- checksums.yaml +5 -5
- data/.gitignore +4 -1
- data/.travis.yml +33 -0
- data/DOCS-POLICIES.md +93 -0
- data/DOCS.md +1 -1
- data/Gemfile +5 -1
- data/Gemfile.lock +379 -0
- data/README.md +10 -9
- data/Rakefile +10 -2
- data/hyper-operation.gemspec +34 -29
- data/lib/hyper-operation.rb +5 -4
- data/lib/hyper-operation/boot.rb +1 -1
- data/lib/hyper-operation/engine.rb +1 -1
- data/lib/hyper-operation/http.rb +309 -0
- data/lib/hyper-operation/railway/params_wrapper.rb +1 -0
- data/lib/hyper-operation/server_op.rb +83 -18
- data/lib/hyper-operation/transport/client_drivers.rb +71 -28
- data/lib/hyper-operation/transport/connection.rb +22 -20
- data/lib/hyper-operation/transport/hyperloop.rb +1 -1
- data/lib/hyper-operation/transport/hyperloop_controller.rb +6 -1
- data/lib/hyper-operation/transport/policy.rb +78 -13
- data/lib/hyper-operation/version.rb +1 -1
- metadata +95 -319
- data/CODE_OF_CONDUCT.md +0 -49
- data/examples/chat-app/.gitignore +0 -21
- data/examples/chat-app/Gemfile +0 -57
- data/examples/chat-app/Gemfile.lock +0 -283
- data/examples/chat-app/README.md +0 -3
- data/examples/chat-app/Rakefile +0 -6
- data/examples/chat-app/app/assets/config/manifest.js +0 -3
- data/examples/chat-app/app/assets/images/.keep +0 -0
- data/examples/chat-app/app/assets/javascripts/application.js +0 -3
- data/examples/chat-app/app/assets/javascripts/cable.js +0 -13
- data/examples/chat-app/app/assets/javascripts/channels/.keep +0 -0
- data/examples/chat-app/app/assets/stylesheets/application.css +0 -15
- data/examples/chat-app/app/channels/application_cable/channel.rb +0 -4
- data/examples/chat-app/app/channels/application_cable/connection.rb +0 -4
- data/examples/chat-app/app/controllers/application_controller.rb +0 -3
- data/examples/chat-app/app/controllers/concerns/.keep +0 -0
- data/examples/chat-app/app/controllers/home_controller.rb +0 -5
- data/examples/chat-app/app/helpers/application_helper.rb +0 -2
- data/examples/chat-app/app/hyperloop/components/app.rb +0 -11
- data/examples/chat-app/app/hyperloop/components/formatted_div.rb +0 -13
- data/examples/chat-app/app/hyperloop/components/input_box.rb +0 -29
- data/examples/chat-app/app/hyperloop/components/message.rb +0 -29
- data/examples/chat-app/app/hyperloop/components/messages.rb +0 -9
- data/examples/chat-app/app/hyperloop/components/nav.rb +0 -30
- data/examples/chat-app/app/hyperloop/operations/operations.rb +0 -56
- data/examples/chat-app/app/hyperloop/stores/message_store.rb +0 -23
- data/examples/chat-app/app/models/application_record.rb +0 -3
- data/examples/chat-app/app/models/concerns/.keep +0 -0
- data/examples/chat-app/app/models/models.rb +0 -2
- data/examples/chat-app/app/models/public/.keep +0 -0
- data/examples/chat-app/app/models/public/announcement.rb +0 -8
- data/examples/chat-app/app/policies/application_policy.rb +0 -5
- data/examples/chat-app/app/views/layouts/application.html.erb +0 -51
- data/examples/chat-app/bin/bundle +0 -3
- data/examples/chat-app/bin/rails +0 -9
- data/examples/chat-app/bin/rake +0 -9
- data/examples/chat-app/bin/setup +0 -34
- data/examples/chat-app/bin/spring +0 -17
- data/examples/chat-app/bin/update +0 -29
- data/examples/chat-app/config.ru +0 -5
- data/examples/chat-app/config/application.rb +0 -13
- data/examples/chat-app/config/boot.rb +0 -3
- data/examples/chat-app/config/cable.yml +0 -9
- data/examples/chat-app/config/database.yml +0 -25
- data/examples/chat-app/config/environment.rb +0 -5
- data/examples/chat-app/config/environments/development.rb +0 -56
- data/examples/chat-app/config/environments/production.rb +0 -86
- data/examples/chat-app/config/environments/test.rb +0 -42
- data/examples/chat-app/config/initializers/application_controller_renderer.rb +0 -6
- data/examples/chat-app/config/initializers/assets.rb +0 -11
- data/examples/chat-app/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/chat-app/config/initializers/cookies_serializer.rb +0 -5
- data/examples/chat-app/config/initializers/filter_parameter_logging.rb +0 -4
- data/examples/chat-app/config/initializers/hyperloop.rb +0 -4
- data/examples/chat-app/config/initializers/inflections.rb +0 -16
- data/examples/chat-app/config/initializers/mime_types.rb +0 -4
- data/examples/chat-app/config/initializers/new_framework_defaults.rb +0 -24
- data/examples/chat-app/config/initializers/session_store.rb +0 -3
- data/examples/chat-app/config/initializers/wrap_parameters.rb +0 -14
- data/examples/chat-app/config/locales/en.yml +0 -23
- data/examples/chat-app/config/puma.rb +0 -47
- data/examples/chat-app/config/routes.rb +0 -5
- data/examples/chat-app/config/secrets.yml +0 -22
- data/examples/chat-app/config/spring.rb +0 -6
- data/examples/chat-app/db/seeds.rb +0 -7
- data/examples/chat-app/lib/assets/.keep +0 -0
- data/examples/chat-app/lib/tasks/.keep +0 -0
- data/examples/chat-app/log/.keep +0 -0
- data/examples/chat-app/public/404.html +0 -67
- data/examples/chat-app/public/422.html +0 -67
- data/examples/chat-app/public/500.html +0 -66
- data/examples/chat-app/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/chat-app/public/apple-touch-icon.png +0 -0
- data/examples/chat-app/public/favicon.ico +0 -0
- data/examples/chat-app/public/robots.txt +0 -5
- data/examples/chat-app/test/controllers/.keep +0 -0
- data/examples/chat-app/test/fixtures/.keep +0 -0
- data/examples/chat-app/test/fixtures/files/.keep +0 -0
- data/examples/chat-app/test/helpers/.keep +0 -0
- data/examples/chat-app/test/integration/.keep +0 -0
- data/examples/chat-app/test/mailers/.keep +0 -0
- data/examples/chat-app/test/models/.keep +0 -0
- data/examples/chat-app/test/test_helper.rb +0 -10
- data/examples/chat-app/tmp/.keep +0 -0
- data/examples/chat-app/vendor/assets/javascripts/.keep +0 -0
- data/examples/chat-app/vendor/assets/stylesheets/.keep +0 -0
- data/examples/five-letter-word-game/.gitignore +0 -21
- data/examples/five-letter-word-game/Gemfile +0 -62
- data/examples/five-letter-word-game/Gemfile.lock +0 -291
- data/examples/five-letter-word-game/README.md +0 -24
- data/examples/five-letter-word-game/Rakefile +0 -6
- data/examples/five-letter-word-game/app/assets/config/manifest.js +0 -3
- data/examples/five-letter-word-game/app/assets/images/.keep +0 -0
- data/examples/five-letter-word-game/app/assets/javascripts/application.js +0 -4
- data/examples/five-letter-word-game/app/assets/javascripts/cable.js +0 -13
- data/examples/five-letter-word-game/app/assets/javascripts/channels/.keep +0 -0
- data/examples/five-letter-word-game/app/assets/stylesheets/application.css +0 -15
- data/examples/five-letter-word-game/app/channels/application_cable/channel.rb +0 -4
- data/examples/five-letter-word-game/app/channels/application_cable/connection.rb +0 -4
- data/examples/five-letter-word-game/app/controllers/application_controller.rb +0 -14
- data/examples/five-letter-word-game/app/controllers/concerns/.keep +0 -0
- data/examples/five-letter-word-game/app/controllers/home_controller.rb +0 -5
- data/examples/five-letter-word-game/app/helpers/application_helper.rb +0 -2
- data/examples/five-letter-word-game/app/hyperloop/components/app.rb +0 -65
- data/examples/five-letter-word-game/app/hyperloop/components/guesses.rb +0 -8
- data/examples/five-letter-word-game/app/hyperloop/components/input_word.rb +0 -13
- data/examples/five-letter-word-game/app/hyperloop/models/user.rb +0 -27
- data/examples/five-letter-word-game/app/hyperloop/operations/ops.rb +0 -115
- data/examples/five-letter-word-game/app/hyperloop/stores/store.rb +0 -120
- data/examples/five-letter-word-game/app/jobs/application_job.rb +0 -2
- data/examples/five-letter-word-game/app/mailers/application_mailer.rb +0 -4
- data/examples/five-letter-word-game/app/models/application_record.rb +0 -3
- data/examples/five-letter-word-game/app/models/concerns/.keep +0 -0
- data/examples/five-letter-word-game/app/policies/hyperloop/application_policy.rb +0 -3
- data/examples/five-letter-word-game/app/policies/user_policy.rb +0 -4
- data/examples/five-letter-word-game/app/views/layouts/application.html.erb +0 -14
- data/examples/five-letter-word-game/app/views/layouts/mailer.html.erb +0 -13
- data/examples/five-letter-word-game/app/views/layouts/mailer.text.erb +0 -1
- data/examples/five-letter-word-game/bin/bundle +0 -3
- data/examples/five-letter-word-game/bin/rails +0 -9
- data/examples/five-letter-word-game/bin/rake +0 -9
- data/examples/five-letter-word-game/bin/setup +0 -34
- data/examples/five-letter-word-game/bin/spring +0 -17
- data/examples/five-letter-word-game/bin/update +0 -29
- data/examples/five-letter-word-game/config.ru +0 -5
- data/examples/five-letter-word-game/config/application.rb +0 -12
- data/examples/five-letter-word-game/config/boot.rb +0 -3
- data/examples/five-letter-word-game/config/cable.yml +0 -9
- data/examples/five-letter-word-game/config/database.yml +0 -46
- data/examples/five-letter-word-game/config/environment.rb +0 -5
- data/examples/five-letter-word-game/config/environments/development.rb +0 -56
- data/examples/five-letter-word-game/config/environments/production.rb +0 -86
- data/examples/five-letter-word-game/config/environments/test.rb +0 -42
- data/examples/five-letter-word-game/config/initializers/application_controller_renderer.rb +0 -6
- data/examples/five-letter-word-game/config/initializers/assets.rb +0 -15
- data/examples/five-letter-word-game/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/five-letter-word-game/config/initializers/cookies_serializer.rb +0 -5
- data/examples/five-letter-word-game/config/initializers/filter_parameter_logging.rb +0 -4
- data/examples/five-letter-word-game/config/initializers/hyperloop.rb +0 -19
- data/examples/five-letter-word-game/config/initializers/inflections.rb +0 -16
- data/examples/five-letter-word-game/config/initializers/mime_types.rb +0 -4
- data/examples/five-letter-word-game/config/initializers/new_framework_defaults.rb +0 -24
- data/examples/five-letter-word-game/config/initializers/session_store.rb +0 -3
- data/examples/five-letter-word-game/config/initializers/wrap_parameters.rb +0 -14
- data/examples/five-letter-word-game/config/locales/en.yml +0 -23
- data/examples/five-letter-word-game/config/puma.rb +0 -47
- data/examples/five-letter-word-game/config/routes.rb +0 -5
- data/examples/five-letter-word-game/config/secrets.yml +0 -22
- data/examples/five-letter-word-game/config/spring.rb +0 -6
- data/examples/five-letter-word-game/db/schema.rb +0 -28
- data/examples/five-letter-word-game/db/seeds.rb +0 -7
- data/examples/five-letter-word-game/lib/assets/.keep +0 -0
- data/examples/five-letter-word-game/lib/tasks/.keep +0 -0
- data/examples/five-letter-word-game/log/.keep +0 -0
- data/examples/five-letter-word-game/public/404.html +0 -67
- data/examples/five-letter-word-game/public/422.html +0 -67
- data/examples/five-letter-word-game/public/500.html +0 -66
- data/examples/five-letter-word-game/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/five-letter-word-game/public/apple-touch-icon.png +0 -0
- data/examples/five-letter-word-game/public/favicon.ico +0 -0
- data/examples/five-letter-word-game/public/robots.txt +0 -5
- data/examples/five-letter-word-game/test/controllers/.keep +0 -0
- data/examples/five-letter-word-game/test/fixtures/.keep +0 -0
- data/examples/five-letter-word-game/test/fixtures/files/.keep +0 -0
- data/examples/five-letter-word-game/test/helpers/.keep +0 -0
- data/examples/five-letter-word-game/test/integration/.keep +0 -0
- data/examples/five-letter-word-game/test/mailers/.keep +0 -0
- data/examples/five-letter-word-game/test/models/.keep +0 -0
- data/examples/five-letter-word-game/test/test_helper.rb +0 -10
- data/examples/five-letter-word-game/tmp/.keep +0 -0
- data/examples/five-letter-word-game/vendor/assets/javascripts/.keep +0 -0
- data/examples/five-letter-word-game/vendor/assets/stylesheets/.keep +0 -0
- data/examples/smoke_test/.gitignore +0 -21
- data/examples/smoke_test/Gemfile +0 -59
- data/examples/smoke_test/Gemfile.lock +0 -289
- data/examples/smoke_test/README.md +0 -24
- data/examples/smoke_test/Rakefile +0 -6
- data/examples/smoke_test/app/assets/config/manifest.js +0 -3
- data/examples/smoke_test/app/assets/images/.keep +0 -0
- data/examples/smoke_test/app/assets/javascripts/application.js +0 -15
- data/examples/smoke_test/app/assets/javascripts/cable.js +0 -13
- data/examples/smoke_test/app/assets/javascripts/channels/.keep +0 -0
- data/examples/smoke_test/app/assets/stylesheets/application.css +0 -15
- data/examples/smoke_test/app/channels/application_cable/channel.rb +0 -4
- data/examples/smoke_test/app/channels/application_cable/connection.rb +0 -4
- data/examples/smoke_test/app/controllers/app_controller.rb +0 -5
- data/examples/smoke_test/app/controllers/application_controller.rb +0 -3
- data/examples/smoke_test/app/helpers/application_helper.rb +0 -2
- data/examples/smoke_test/app/hyperloop/components/hello.rb +0 -25
- data/examples/smoke_test/app/hyperloop/operations/operations/nested_send_to_all.rb +0 -7
- data/examples/smoke_test/app/hyperloop/operations/send_to_all.rb +0 -6
- data/examples/smoke_test/app/hyperloop/stores/messages.rb +0 -4
- data/examples/smoke_test/app/jobs/application_job.rb +0 -2
- data/examples/smoke_test/app/mailers/application_mailer.rb +0 -4
- data/examples/smoke_test/app/models/application_record.rb +0 -3
- data/examples/smoke_test/app/models/concerns/.keep +0 -0
- data/examples/smoke_test/app/policies/application_policy.rb +0 -8
- data/examples/smoke_test/app/views/layouts/application.html.erb +0 -14
- data/examples/smoke_test/app/views/layouts/mailer.html.erb +0 -13
- data/examples/smoke_test/app/views/layouts/mailer.text.erb +0 -1
- data/examples/smoke_test/bin/bundle +0 -3
- data/examples/smoke_test/bin/rails +0 -9
- data/examples/smoke_test/bin/rake +0 -9
- data/examples/smoke_test/bin/setup +0 -34
- data/examples/smoke_test/bin/spring +0 -17
- data/examples/smoke_test/bin/update +0 -29
- data/examples/smoke_test/config.ru +0 -5
- data/examples/smoke_test/config/application.rb +0 -15
- data/examples/smoke_test/config/boot.rb +0 -3
- data/examples/smoke_test/config/cable.yml +0 -9
- data/examples/smoke_test/config/database.yml +0 -25
- data/examples/smoke_test/config/environment.rb +0 -5
- data/examples/smoke_test/config/environments/development.rb +0 -54
- data/examples/smoke_test/config/environments/production.rb +0 -86
- data/examples/smoke_test/config/environments/test.rb +0 -42
- data/examples/smoke_test/config/initializers/application_controller_renderer.rb +0 -6
- data/examples/smoke_test/config/initializers/assets.rb +0 -11
- data/examples/smoke_test/config/initializers/backtrace_silencers.rb +0 -7
- data/examples/smoke_test/config/initializers/cookies_serializer.rb +0 -5
- data/examples/smoke_test/config/initializers/filter_parameter_logging.rb +0 -4
- data/examples/smoke_test/config/initializers/hyperloop.rb +0 -32
- data/examples/smoke_test/config/initializers/inflections.rb +0 -16
- data/examples/smoke_test/config/initializers/mime_types.rb +0 -4
- data/examples/smoke_test/config/initializers/new_framework_defaults.rb +0 -24
- data/examples/smoke_test/config/initializers/session_store.rb +0 -3
- data/examples/smoke_test/config/initializers/wrap_parameters.rb +0 -14
- data/examples/smoke_test/config/locales/en.yml +0 -23
- data/examples/smoke_test/config/puma.rb +0 -47
- data/examples/smoke_test/config/routes.rb +0 -5
- data/examples/smoke_test/config/secrets.yml +0 -22
- data/examples/smoke_test/config/spring.rb +0 -6
- data/examples/smoke_test/db/seeds.rb +0 -7
- data/examples/smoke_test/lib/assets/.keep +0 -0
- data/examples/smoke_test/lib/tasks/.keep +0 -0
- data/examples/smoke_test/log/.keep +0 -0
- data/examples/smoke_test/public/404.html +0 -67
- data/examples/smoke_test/public/422.html +0 -67
- data/examples/smoke_test/public/500.html +0 -66
- data/examples/smoke_test/public/apple-touch-icon-precomposed.png +0 -0
- data/examples/smoke_test/public/apple-touch-icon.png +0 -0
- data/examples/smoke_test/public/favicon.ico +0 -0
- data/examples/smoke_test/public/robots.txt +0 -5
- data/examples/smoke_test/test/controllers/.keep +0 -0
- data/examples/smoke_test/test/fixtures/.keep +0 -0
- data/examples/smoke_test/test/fixtures/files/.keep +0 -0
- data/examples/smoke_test/test/helpers/.keep +0 -0
- data/examples/smoke_test/test/integration/.keep +0 -0
- data/examples/smoke_test/test/mailers/.keep +0 -0
- data/examples/smoke_test/test/models/.keep +0 -0
- data/examples/smoke_test/test/test_helper.rb +0 -10
- data/examples/smoke_test/tmp/.keep +0 -0
- data/examples/smoke_test/vendor/assets/javascripts/.keep +0 -0
- data/examples/smoke_test/vendor/assets/stylesheets/.keep +0 -0
- 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.
|
6
|
-
<img width="350px" src="http://ruby-hyperloop.
|
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.
|
16
|
-
<img src="http://ruby-hyperloop.
|
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.
|
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.
|
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.
|
62
|
-
* [Hyperloop Guides](http://ruby-hyperloop.
|
63
|
-
* [Hyperloop Tutorial](http://ruby-hyperloop.
|
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
|
-
|
3
|
-
|
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
|
data/hyper-operation.gemspec
CHANGED
@@ -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 =
|
7
|
+
spec.name = 'hyper-operation'
|
8
8
|
spec.version = Hyperloop::Operation::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
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.
|
13
|
-
|
14
|
-
|
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 = [
|
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 '
|
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
|
28
|
-
spec.add_development_dependency
|
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 '
|
39
|
-
spec.add_development_dependency '
|
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 '
|
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
|
data/lib/hyper-operation.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'hyper-operation/version'
|
2
2
|
require 'hyperloop-config'
|
3
|
-
|
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/
|
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'
|
data/lib/hyper-operation/boot.rb
CHANGED
@@ -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 :
|
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
|