hyper-operation 1.0.alpha1.8 → 1.0.0.lap28

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -7
  3. data/.travis.yml +9 -21
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/DOCS-POLICIES.md +582 -0
  6. data/DOCS.md +869 -0
  7. data/Gemfile +1 -5
  8. data/LICENSE.txt +21 -0
  9. data/README.md +77 -0
  10. data/Rakefile +2 -1
  11. data/dciy.toml +3 -0
  12. data/hyper-operation.gemspec +15 -19
  13. data/lib/hyper-operation.rb +6 -10
  14. data/lib/hyper-operation/api.rb +4 -8
  15. data/lib/hyper-operation/boot.rb +2 -3
  16. data/lib/hyper-operation/delay_and_interval.rb +9 -0
  17. data/lib/hyper-operation/engine.rb +2 -2
  18. data/lib/hyper-operation/exception.rb +4 -30
  19. data/lib/hyper-operation/filters/acting_user.rb +1 -1
  20. data/lib/hyper-operation/http.rb +2 -2
  21. data/lib/hyper-operation/promise.rb +2 -32
  22. data/lib/hyper-operation/railway.rb +1 -1
  23. data/lib/hyper-operation/railway/dispatcher.rb +5 -8
  24. data/lib/hyper-operation/railway/params_wrapper.rb +2 -2
  25. data/lib/hyper-operation/railway/run.rb +49 -58
  26. data/lib/hyper-operation/railway/validations.rb +3 -10
  27. data/lib/hyper-operation/server_op.rb +20 -46
  28. data/lib/hyper-operation/transport/action_cable.rb +8 -8
  29. data/lib/hyper-operation/transport/client_drivers.rb +55 -96
  30. data/lib/hyper-operation/transport/connection.rb +136 -58
  31. data/lib/hyper-operation/transport/{hyperstack.rb → hyperloop.rb} +15 -28
  32. data/lib/hyper-operation/transport/{hyperstack_controller.rb → hyperloop_controller.rb} +53 -59
  33. data/lib/hyper-operation/transport/policy.rb +49 -50
  34. data/lib/hyper-operation/version.rb +2 -2
  35. data/lib/sources/{hyperstack → hyperloop}/pusher.js +0 -0
  36. metadata +73 -94
  37. data/lib/hyper-operation/async_sleep.rb +0 -23
  38. data/lib/hyper-operation/transport/connection_adapter/active_record.rb +0 -113
  39. data/lib/hyper-operation/transport/connection_adapter/active_record/auto_create.rb +0 -26
  40. data/lib/hyper-operation/transport/connection_adapter/active_record/connection.rb +0 -47
  41. data/lib/hyper-operation/transport/connection_adapter/active_record/queued_message.rb +0 -42
  42. data/lib/hyper-operation/transport/connection_adapter/redis.rb +0 -94
  43. data/lib/hyper-operation/transport/connection_adapter/redis/connection.rb +0 -85
  44. data/lib/hyper-operation/transport/connection_adapter/redis/queued_message.rb +0 -34
  45. data/lib/hyper-operation/transport/connection_adapter/redis/redis_record.rb +0 -158
  46. data/lib/hyper-operation/transport/policy_diagnostics.rb +0 -106
data/Gemfile CHANGED
@@ -1,7 +1,3 @@
1
1
  source 'https://rubygems.org'
2
- #gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
3
- gem 'hyper-spec', path: '../hyper-spec'
4
- gem 'hyperstack-config', path: '../hyperstack-config'
5
- gem 'hyper-state', path: '../hyper-state'
6
- gem 'hyper-component', path: '../hyper-component'
2
+ gem "opal-jquery", git: "https://github.com/opal/opal-jquery.git", branch: "master"
7
3
  gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Mitch VanDuyn
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,77 @@
1
+ <div class="githubhyperloopheader">
2
+
3
+ <p align="center">
4
+
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
+ </a>
8
+
9
+ </p>
10
+
11
+ <h2 align="center">The Complete Isomorphic Ruby Framework</h2>
12
+
13
+ <br>
14
+
15
+ <a href="http://ruby-hyperloop.org/" alt="Hyperloop" title="Hyperloop">
16
+ <img src="http://ruby-hyperloop.org/images/githubhyperloopbadge.png">
17
+ </a>
18
+
19
+ <a href="https://gitter.im/ruby-hyperloop/chat" alt="Gitter chat" title="Gitter chat">
20
+ <img src="http://ruby-hyperloop.org/images/githubgitterbadge.png">
21
+ </a>
22
+
23
+ [![Build Status](https://travis-ci.org/ruby-hyperloop/hyper-operation.svg?branch=master)](https://travis-ci.org/ruby-hyperloop/hyper-operation)
24
+ [![Gem Version](https://badge.fury.io/rb/hyper-operation.svg)](https://badge.fury.io/rb/hyper-operation)
25
+
26
+ <p align="center">
27
+ <img src="http://ruby-hyperloop.org/images/HyperOperations.png" width="100" alt="Hyper-operation">
28
+ </p>
29
+
30
+ </div>
31
+
32
+ ## Hyper-Operation GEM is part of Hyperloop GEMS family
33
+
34
+ Build interactive Web applications quickly. Hyperloop encourages rapid development with clean, pragmatic design. With developer productivity as our highest goal, Hyperloop takes care of much of the hassle of Web development, so you can focus on innovation and delivering end-user value.
35
+
36
+ One language. One model. One set of tests. The same business logic and domain models running on the clients and the server. Hyperloop is fully integrated with Rails and also gives you unfettered access to the complete universe of JavaScript libraries (including React) from within your Ruby code. Hyperloop lets you build beautiful interactive user interfaces in Ruby.
37
+
38
+ Everything has a place in our architecture. Components deliver interactive user experiences, Operations encapsulate business logic, Models magically synchronize data between clients and servers, Policies govern authorization and Stores hold local state.
39
+
40
+ **Hyper-Operation** brings Operations which encapsulate business logic. In a traditional MVC architecture, Operations end up either in Controllers, Models or some other secondary construct such as service objects, helpers, or concerns. Here they are first class objects. Their job is to mutate state in the Stores and Models.
41
+
42
+ ## Getting Started
43
+
44
+ 1. Update your Gemfile:
45
+
46
+ ```ruby
47
+ #Gemfile
48
+
49
+ gem 'hyperloop'
50
+ ```
51
+
52
+ 2. At the command prompt, update your bundle :
53
+
54
+ $ bundle update
55
+
56
+ 3. Run the hyperloop install generator:
57
+
58
+ $ rails g hyperloop:install
59
+
60
+ 4. Follow the guidelines to start developing your application. You may find
61
+ the following resources handy:
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)
65
+
66
+ ## Community
67
+
68
+ #### Getting Help
69
+ Please **do not post** usage questions to GitHub Issues. For these types of questions use our [Gitter chatroom](https://gitter.im/ruby-hyperloop/chat) or [StackOverflow](http://stackoverflow.com/questions/tagged/hyperloop).
70
+
71
+ #### Submitting Bugs and Enhancements
72
+ [GitHub Issues](https://github.com/ruby-hyperloop/hyperloop/issues) is for suggesting enhancements and reporting bugs. Before submiting a bug make sure you do the following:
73
+ * Check out our [contributing guide](https://github.com/ruby-hyperloop/hyperloop/blob/master/CONTRIBUTING.md) for info on our release cycle.
74
+
75
+ ## License
76
+
77
+ Hyperloop is released under the [MIT License](http://www.opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -5,7 +5,8 @@ RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  namespace :spec do
7
7
  task :prepare do
8
- sh %(cd spec/test_app; bundle exec rails db:setup)
8
+ sh %{bundle update}
9
+ sh %{cd spec/test_app; bundle update; bundle exec rails db:setup}
9
10
  end
10
11
  end
11
12
 
data/dciy.toml ADDED
@@ -0,0 +1,3 @@
1
+ [dciy.commands]
2
+ prepare = ["rake spec:prepare"]
3
+ cibuild = ["bundle exec rake"]
@@ -5,49 +5,45 @@ require 'hyper-operation/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'hyper-operation'
8
- spec.version = Hyperstack::Operation::VERSION
8
+ spec.version = Hyperloop::Operation::VERSION
9
9
  spec.authors = ['Mitch VanDuyn', 'Jan Biedermann']
10
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-hyperstack.org'
11
+ 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}
12
+ spec.homepage = 'http://ruby-hyperloop.org'
13
13
  spec.license = 'MIT'
14
14
  # spec.metadata = {
15
- # "homepage_uri" => 'http://ruby-hyperstack.org',
16
- # "source_code_uri" => 'https://github.com/ruby-hyperstack/hyper-component'
15
+ # "homepage_uri" => 'http://ruby-hyperloop.org',
16
+ # "source_code_uri" => 'https://github.com/ruby-hyperloop/hyper-component'
17
17
  # }
18
18
 
19
- spec.files = `git ls-files -z`
20
- .split("\x0")
21
- .reject { |f| f.match(%r{^(gemfiles|examples|spec)/}) }
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(gemfiles|examples|spec)/}) }
22
20
  spec.bindir = 'exe'
23
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
22
  spec.require_paths = ['lib']
25
23
 
26
24
  spec.add_dependency 'activerecord', '>= 4.0.0'
27
- spec.add_dependency 'hyper-component', Hyperstack::Operation::VERSION
25
+ spec.add_dependency 'hyper-component', Hyperloop::Operation::VERSION
26
+ spec.add_dependency 'hyperloop-config', Hyperloop::Operation::VERSION
28
27
  spec.add_dependency 'mutations'
29
28
  spec.add_dependency 'opal-activesupport', '~> 0.3.1'
30
- spec.add_dependency 'tty-table'
31
-
32
29
  spec.add_development_dependency 'bundler'
33
- spec.add_development_dependency 'chromedriver-helper'
34
30
  spec.add_development_dependency 'database_cleaner'
35
- spec.add_development_dependency 'hyper-spec', Hyperstack::Operation::VERSION
31
+ spec.add_development_dependency 'hyper-react', Hyperloop::Operation::VERSION
32
+ spec.add_development_dependency 'hyper-spec', Hyperloop::Operation::VERSION
36
33
  spec.add_development_dependency 'mysql2'
34
+ spec.add_development_dependency 'opal', '>= 0.11.0', '< 0.12.0'
37
35
  spec.add_development_dependency 'opal-browser', '~> 0.2.0'
38
- spec.add_development_dependency 'opal-rails', '>= 0.9.4', '< 2.0'
39
- spec.add_development_dependency 'pry-rescue'
40
- spec.add_development_dependency 'pry-stack_explorer'
36
+ spec.add_development_dependency 'opal-rails', '~> 0.9.4'
37
+ spec.add_development_dependency 'mini_racer', '~> 0.1.15'
41
38
  spec.add_development_dependency 'puma'
42
39
  spec.add_development_dependency 'pusher'
43
40
  spec.add_development_dependency 'pusher-fake'
44
- spec.add_development_dependency 'rails', ENV['RAILS_VERSION'] || '>= 5.0.0', '< 7.0'
41
+ spec.add_development_dependency 'rails', '>= 4.0.0'
45
42
  spec.add_development_dependency 'rake'
46
43
  spec.add_development_dependency 'react-rails', '>= 2.4.0', '< 2.5.0'
47
- spec.add_development_dependency 'redis'
48
44
  spec.add_development_dependency 'rspec-rails'
49
45
  spec.add_development_dependency 'rspec-steps', '~> 2.1.1'
50
46
  spec.add_development_dependency 'rspec-wait'
51
- spec.add_development_dependency 'sqlite3', '~> 1.4.2' # see https://github.com/rails/rails/issues/35153
47
+ spec.add_development_dependency 'sqlite3'
52
48
  spec.add_development_dependency 'timecop', '~> 0.8.1'
53
49
  end
@@ -1,7 +1,7 @@
1
1
  require 'hyper-operation/version'
2
- require 'hyperstack-config'
2
+ require 'hyperloop-config'
3
3
 
4
- Hyperstack.import 'hyper-operation'
4
+ Hyperloop.import 'hyper-operation'
5
5
 
6
6
  if RUBY_ENGINE == 'opal'
7
7
  require 'active_support/core_ext/string'
@@ -28,10 +28,8 @@ if RUBY_ENGINE == 'opal'
28
28
  require 'hyper-operation/railway/validations'
29
29
  require 'hyper-operation/server_op'
30
30
  require 'hyper-operation/boot'
31
- require 'hyper-operation/async_sleep'
32
31
  else
33
- require 'tty-table'
34
- require 'hyperstack-config'
32
+ require 'hyperloop-config'
35
33
  require 'mutations'
36
34
  Mutations::HashFilter.register_additional_filter(Mutations::DuckFilter, :duck)
37
35
  require 'hyper-operation/filters/outbound_filter'
@@ -40,13 +38,12 @@ else
40
38
  require 'hyper-operation/transport/active_record'
41
39
  require 'hyper-operation/engine'
42
40
  require 'hyper-operation/transport/connection'
43
- require 'hyper-operation/transport/hyperstack'
41
+ require 'hyper-operation/transport/hyperloop'
44
42
  require 'hyper-operation/transport/policy'
45
- require 'hyper-operation/transport/policy_diagnostics'
46
43
  require 'hyper-operation/transport/client_drivers'
47
44
  require 'hyper-operation/transport/acting_user'
48
45
  require 'opal-activesupport'
49
- require 'hyper-operation/async_sleep'
46
+ require 'hyper-operation/delay_and_interval'
50
47
  require 'hyper-operation/exception'
51
48
  require 'hyper-operation/promise'
52
49
  require 'hyper-operation/railway'
@@ -55,9 +52,8 @@ else
55
52
  require 'hyper-operation/railway/params_wrapper'
56
53
  require 'hyper-operation/railway/run.rb'
57
54
  require 'hyper-operation/railway/validations'
58
- require 'hyper-operation/transport/hyperstack_controller'
55
+ require 'hyper-operation/transport/hyperloop_controller'
59
56
  require 'hyper-operation/server_op'
60
- require 'hyper-operation/boot'
61
57
  Opal.use_gem 'mutations', false
62
58
  Opal.append_path File.expand_path('../sources/', __FILE__).untaint
63
59
  Opal.append_path File.expand_path('../', __FILE__).untaint
@@ -1,4 +1,4 @@
1
- module Hyperstack
1
+ module Hyperloop
2
2
  class Operation
3
3
 
4
4
  def add_error(key, kind, message = nil)
@@ -46,12 +46,8 @@ module Hyperstack
46
46
  @_railway.process_params(args)
47
47
  @_railway.process_validations
48
48
  @_railway.run
49
- # return the result from dispatch in case there is an error
50
- if (dispatch_result = @_railway.dispatch).rejected?
51
- dispatch_result
52
- else
53
- @_railway.result
54
- end
49
+ @_railway.dispatch
50
+ @_railway.result
55
51
  end
56
52
  end
57
53
 
@@ -141,7 +137,7 @@ module Hyperstack
141
137
  end
142
138
 
143
139
  child.singleton_class.define_singleton_method(:_Railway) do
144
- Hyperstack::Context.set_var(self, :@_railway) do
140
+ Hyperloop::Context.set_var(self, :@_railway) do
145
141
  # overcomes a bug in Opal 0.9 which returns nil for singleton superclass
146
142
  my_super = superclass || `self.$$singleton_of`.superclass.singleton_class
147
143
  if my_super == Operation.singleton_class
@@ -1,5 +1,5 @@
1
- module Hyperstack
2
- # Tricky business here. Hyperstack::Store will define boot
1
+ module Hyperloop
2
+ # Tricky business here. Hyperloop::Store will define boot
3
3
  # if it is not already defined. It creates a minimal compatible
4
4
  # API that includes the run and on_dispatch methods. This way
5
5
  # you can use the Boot interface without loading operations.
@@ -11,7 +11,6 @@ module Hyperstack
11
11
  class Application
12
12
  Operation.inherited(Boot) if defined? Boot
13
13
  class Boot < Operation
14
- #broadcaster.receiver(self, *args, &block)
15
14
  def self.on_dispatch(&block)
16
15
  _Railway.add_receiver(&block)
17
16
  end
@@ -0,0 +1,9 @@
1
+ module Kernel
2
+ def every(time, &block)
3
+ Thread.new { loop { sleep time; block.call }}
4
+ end
5
+
6
+ def after(time, &block)
7
+ Thread.new { sleep time; block.call }
8
+ end
9
+ end
@@ -1,6 +1,6 @@
1
- module Hyperstack
1
+ module Hyperloop
2
2
  class Engine < ::Rails::Engine
3
- isolate_namespace Hyperstack
3
+ isolate_namespace Hyperloop
4
4
  config.generators do |g|
5
5
  g.test_framework :rspec, :fixture => false
6
6
  g.fixture_replacement :factory_bot, :dir => 'spec/factories'
@@ -1,39 +1,13 @@
1
- module Mutations
2
- class ErrorArray
3
- def self.new_from_error_hash(errors)
4
- new(errors.collect do |key, values|
5
- ErrorAtom.new(key, values[:symbol], values)
6
- end)
7
- end
8
- end
9
- end
10
-
11
- module Hyperstack
1
+ module Hyperloop
12
2
  class AccessViolation < StandardError
13
- attr_accessor :details
14
-
15
- def initialize(message = nil, details = nil)
16
- super("Hyperstack::AccessViolation#{':' + message.to_s if message}")
17
- @details = details
18
- end
19
-
20
- def __hyperstack_on_error(operation, params, fmted_message)
21
- Hyperstack.on_error(operation, self, params, fmted_message)
3
+ def message
4
+ "Hyperloop::Operation::AccessViolation: #{super}"
22
5
  end
23
6
  end
24
7
 
25
8
  class Operation
26
9
  class ValidationException < Mutations::ValidationException
27
- def as_json(*)
28
- errors.as_json
29
- end
30
-
31
- def initialize(errors)
32
- unless errors.is_a? Mutations::ErrorHash
33
- errors = Mutations::ErrorArray.new_from_error_hash(errors)
34
- end
35
- super(errors)
36
- end
37
10
  end
38
11
  end
12
+
39
13
  end
@@ -1,4 +1,4 @@
1
- module Hyperstack
1
+ module Hyperloop
2
2
  class ActingUser
3
3
  @default_options = {
4
4
  :nils => false # true allows an explicit nil to be valid. Overrides any other options
@@ -1,4 +1,4 @@
1
- module Hyperstack
1
+ module Hyperloop
2
2
  # {HTTP} is used to perform a `XMLHttpRequest` in ruby. It is a simple wrapper
3
3
  # around `XMLHttpRequest`
4
4
  #
@@ -161,7 +161,7 @@ module Hyperstack
161
161
  @active_requests ||= 0
162
162
  @active_requests -= 1
163
163
  if @active_requests < 0
164
- `console.log("Ooops, Hyperstack::HTTP active_requests out of sync!")`
164
+ `console.log("Ooops, Hyperloop::HTTP active_requests out of sync!")`
165
165
  @active_requests = 0
166
166
  end
167
167
  end
@@ -1,15 +1,3 @@
1
- # Caution. For now Hyperstack maintains its own copy of the Promise class.
2
- # Eventually the diff between hyperstacks version and the official Opal version
3
- # should be put into a PR.
4
-
5
- # A key feature add is the Fail Exception class which is simply there to allow
6
- # a `always` block to reject without raising an error. To use this see the run.rb
7
- # module.
8
-
9
- # Also see exception! method for the part of the code that detects the Fail exception.
10
-
11
- # See https://github.com/opal/opal/issues/1967 for details.
12
-
13
1
  class Promise
14
2
  def self.value(value)
15
3
  new.resolve(value)
@@ -23,13 +11,6 @@ class Promise
23
11
  When.new(promises)
24
12
  end
25
13
 
26
- class Fail < StandardError
27
- attr_reader :result
28
- def initialize(result)
29
- @result = result
30
- end
31
- end
32
-
33
14
  attr_reader :error, :prev, :next
34
15
 
35
16
  def initialize(action = {})
@@ -123,7 +104,6 @@ class Promise
123
104
 
124
105
  begin
125
106
  if block = @action[:success] || @action[:always]
126
- @realized = :resolve
127
107
  value = block.call(value)
128
108
  end
129
109
 
@@ -157,9 +137,6 @@ class Promise
157
137
 
158
138
  begin
159
139
  if block = @action[:failure] || @action[:always]
160
- # temporarily set values so always can determine if this
161
- # was a reject or resolve
162
- @realized = :reject
163
140
  value = block.call(value)
164
141
  end
165
142
 
@@ -187,15 +164,8 @@ class Promise
187
164
  end
188
165
 
189
166
  def exception!(error)
190
- # If the error is a Promise::Fail, then
191
- # the error becomes the error.result value
192
- # this allows code to raise an error on an
193
- # object that is not an error.
194
- if error.is_a? Promise::Fail
195
- error = error.result
196
- else
197
- @exception = true
198
- end
167
+ @exception = true
168
+
199
169
  reject!(error)
200
170
  end
201
171
 
@@ -1,4 +1,4 @@
1
- module Hyperstack
1
+ module Hyperloop
2
2
  class Operation
3
3
 
4
4
  end