isomorfeus-operation 1.0.0.delta11
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.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +44 -0
- data/lib/isomorfeus/operation/config.rb +28 -0
- data/lib/isomorfeus/operation/gherkin.rb +65 -0
- data/lib/isomorfeus/operation/handler/operation_handler.rb +54 -0
- data/lib/isomorfeus/operation/mixin.rb +58 -0
- data/lib/isomorfeus/operation/promise_run.rb +76 -0
- data/lib/isomorfeus/operation/version.rb +5 -0
- data/lib/isomorfeus-operation.rb +34 -0
- data/lib/lucid_local_operation/base.rb +11 -0
- data/lib/lucid_local_operation/mixin.rb +23 -0
- data/lib/lucid_operation/base.rb +15 -0
- data/lib/lucid_operation/mixin.rb +72 -0
- data/lib/lucid_quick_op/base.rb +15 -0
- data/lib/lucid_quick_op/mixin.rb +64 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 823378aa4e9344b3db0a2b709f4111852bae0e5652aae247e523150c99b0a16d
|
4
|
+
data.tar.gz: 2be7f1482ce6784d16e6c8bc43076b71b0b4e200f774e177ec9fb0cf895610cc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c299c24e21f3e48ab506ef300947d1e6effa73658b7e65d18d5a4fccf29658f81d6022a05cd1ea02a1f5a4c82092cfbbfd3240a39262e2c402fecb58c3d13eb8
|
7
|
+
data.tar.gz: 8173fe8f26a00fb9c2bdcb145c7f3f1e35fccf223a7eaa76af15ae519842efd18189a72cfbc404213a99b0145ce01dfb317b8dc2efcb6f6d40b9405beb5569bb
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 Jan Biedermann
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# isomorfeus-operation
|
2
|
+
|
3
|
+
there are 3 kinds of Operations:
|
4
|
+
- LucidQuickOp
|
5
|
+
- LucidOperation
|
6
|
+
- LucidLocalOperation
|
7
|
+
|
8
|
+
```ruby
|
9
|
+
class MyQuickOp < LucidQuickOp::Base
|
10
|
+
prop :a_prop
|
11
|
+
|
12
|
+
op do
|
13
|
+
props.a_prop == 'a_value'
|
14
|
+
# do something
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
MyQuickOp.promise_run(a_prop: 'a_value')
|
19
|
+
```
|
20
|
+
|
21
|
+
Quick remote procedure call, always executed on the server.
|
22
|
+
LucidOperation too is always executed on the Server. It allows to define Operations in gherkin human language style:
|
23
|
+
```
|
24
|
+
class MyOperation < LucidOperation::Base
|
25
|
+
prop :a_prop
|
26
|
+
|
27
|
+
procedure <<~TEXT
|
28
|
+
Given a bird
|
29
|
+
When it flies
|
30
|
+
Then be happy
|
31
|
+
TEXT
|
32
|
+
|
33
|
+
Given /a bird/ do
|
34
|
+
props.a_prop == 'a_value'
|
35
|
+
end
|
36
|
+
|
37
|
+
# etc ...
|
38
|
+
end
|
39
|
+
|
40
|
+
MyOperation.promise_run(a_prop: 'a_value')
|
41
|
+
```
|
42
|
+
|
43
|
+
LucidLocalOperation is the same as LucidOperation, except its always executed locally, wherever that may be.
|
44
|
+
Its barely tested so far and no other docs.
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
class << self
|
3
|
+
def cached_operation_classes
|
4
|
+
@cached_operation_classes ||= {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def cached_operation_class(class_name)
|
8
|
+
return cached_operation_classes[class_name] if cached_operation_classes.key?(class_name)
|
9
|
+
cached_operation_classes[class_name] = "::#{class_name}".constantize
|
10
|
+
end
|
11
|
+
|
12
|
+
if RUBY_ENGINE != 'opal'
|
13
|
+
def valid_operation_class_names
|
14
|
+
@valid_operation_class_names ||= Set.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid_operation_class_name?(class_name)
|
18
|
+
valid_operation_class_names.include?(class_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_valid_operation_class(klass)
|
22
|
+
class_name = klass.name
|
23
|
+
class_name = class_name.split('>::').last if class_name.start_with?('#<')
|
24
|
+
valid_operation_class_names << class_name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Operation
|
3
|
+
module Gherkin
|
4
|
+
FIRST_EXCEPTION = "First must be the first one that is used and can only used once!"
|
5
|
+
FINALLY_EXCEPTION = "Finally, except for Ensure and Failed, must be the last one to be used and can only be used once!"
|
6
|
+
|
7
|
+
NEWLINE = /\r?\n/
|
8
|
+
OPERATION = /^\s*Operation: (.*)$/
|
9
|
+
PROCEDURE = /^\s*Procedure: (.*)$/
|
10
|
+
STAR = /^\s*\* (.*)$/
|
11
|
+
GIVEN = /^\s*Given (.*)$/
|
12
|
+
WHEN = /^\s*When (.*)$/
|
13
|
+
THEN = /^\s*Then (.*)$/
|
14
|
+
AND = /^\s*And (.*)$/
|
15
|
+
FIRST = /^\s*First (.*)$/
|
16
|
+
ENSURE = /^\s*Ensure (.*)$/
|
17
|
+
FINALLY = /^\s*Finally (.*)$/
|
18
|
+
IW_FAILING = /^\s*(?:When|If) failing (.*)$/
|
19
|
+
IF_ITT_FAILED = /^\s*If (?:that|this|it) failed (.*)$/
|
20
|
+
FAILED = /^\s*Failed (.*)$/
|
21
|
+
COMMENT = /^\s*# (.*)$/
|
22
|
+
WHITE_SPACE = /^\s*$/
|
23
|
+
|
24
|
+
def self.parse(gherkin_text)
|
25
|
+
operation = { operation: '', procedure: '', steps: [], failure: [], ensure: [] }
|
26
|
+
has_finally = false
|
27
|
+
lines = gherkin_text.split(NEWLINE)
|
28
|
+
|
29
|
+
lines.each do |line|
|
30
|
+
case line
|
31
|
+
when STAR, GIVEN, WHEN, THEN, AND
|
32
|
+
raise FINALLY_EXCEPTION if has_finally
|
33
|
+
operation[:steps] << $1.strip
|
34
|
+
when ENSURE
|
35
|
+
operation[:ensure] << $1.strip
|
36
|
+
when IW_FAILING, IF_ITT_FAILED, FAILED
|
37
|
+
operation[:failure] << $1.strip
|
38
|
+
when FIRST
|
39
|
+
raise FIRST_EXCEPTION if operation[:steps].size > 0
|
40
|
+
operation[:steps] << $1.strip
|
41
|
+
when FINALLY
|
42
|
+
raise FINALLY_EXCEPTION if has_finally
|
43
|
+
operation[:steps] << $1.strip
|
44
|
+
has_finally = true
|
45
|
+
when PROCEDURE
|
46
|
+
raise 'No Operation defined!' if operation[:operation].empty?
|
47
|
+
raise 'Procedure already defined!' unless operation[:procedure].empty?
|
48
|
+
operation[:procedure] = $1.strip
|
49
|
+
when OPERATION
|
50
|
+
raise 'Operation already defined!' unless operation[:operation].empty?
|
51
|
+
operation[:operation] = $1.strip
|
52
|
+
when WHITE_SPACE, COMMENT
|
53
|
+
# nothing, just skip
|
54
|
+
else
|
55
|
+
raise "Unknown key word(s) at the beginning of the line: #{line}" unless operation[:procedure].empty?
|
56
|
+
operation[:description] = [] unless operation.key?(:description)
|
57
|
+
operation[:description] << line.strip
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
operation
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Operation
|
3
|
+
module Handler
|
4
|
+
class OperationHandler < LucidHandler::Base
|
5
|
+
on_request do |pub_sub_client, session_id, current_user, request, response|
|
6
|
+
result = { error: 'No such thing' }
|
7
|
+
# promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.to_s, props_hash)
|
8
|
+
request.keys.each do |operation_class_name|
|
9
|
+
if Isomorfeus.valid_operation_class_name?(operation_class_name)
|
10
|
+
operation_class = Isomorfeus.cached_operation_class(operation_class_name)
|
11
|
+
if operation_class
|
12
|
+
props_json = request[operation_class_name]
|
13
|
+
begin
|
14
|
+
props = Oj.load(props_json, mode: :strict)
|
15
|
+
props.merge!({pub_sub_client: pub_sub_client, session_id: session_id, current_user: current_user})
|
16
|
+
operation_promise = operation_class.promise_run(props)
|
17
|
+
if operation_promise.realized?
|
18
|
+
result = { success: 'ok' , result: operation_promise.value }
|
19
|
+
else
|
20
|
+
start = Time.now
|
21
|
+
timeout = false
|
22
|
+
while !operation_promise.realized?
|
23
|
+
if (Time.now - start) > 20
|
24
|
+
timeout = true
|
25
|
+
break
|
26
|
+
end
|
27
|
+
sleep 0.01
|
28
|
+
end
|
29
|
+
if timeout
|
30
|
+
result = { error: 'Timeout' }
|
31
|
+
else
|
32
|
+
result = { success: 'ok' , result: operation_promise.value }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
rescue Exception => e
|
36
|
+
result = if Isomorfeus.production?
|
37
|
+
{ error: { operation_class_name => 'No such thing!' }}
|
38
|
+
else
|
39
|
+
{ error: { operation_class_name => "Isomorfeus::Operation::Handler::OperationHandler: #{e.message}" }}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
result = { error: { operation_class_name => 'No such thing!' }}
|
44
|
+
end
|
45
|
+
else
|
46
|
+
result = { error: { operation_class_name => 'No such thing!' }}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
result
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Operation
|
3
|
+
module Mixin
|
4
|
+
def procedure(gherkin_text)
|
5
|
+
feature_line = gherkin_text.include?('Operation: ') ? '' : "Operation: #{self.name}\n"
|
6
|
+
scenario_line = feature_line == '' || gherkin_text.include?('Procedure: ') ? '' : " Procedure: #{self.name} executing\n"
|
7
|
+
@procedure = feature_line + scenario_line + gherkin_text
|
8
|
+
end
|
9
|
+
|
10
|
+
def gherkin
|
11
|
+
@gherkin ||= Isomorfeus::Operation::Gherkin.parse(@procedure)
|
12
|
+
end
|
13
|
+
|
14
|
+
def ensure_steps
|
15
|
+
@ensure_steps ||= []
|
16
|
+
end
|
17
|
+
|
18
|
+
def failure_steps
|
19
|
+
@failure_steps ||= []
|
20
|
+
end
|
21
|
+
|
22
|
+
def steps
|
23
|
+
@steps ||= []
|
24
|
+
end
|
25
|
+
|
26
|
+
def First(regular_expression, &block)
|
27
|
+
raise "#{self}: First already defined, can only be defined once!" if @first_defined
|
28
|
+
@first_defined = true
|
29
|
+
steps << [regular_expression, block]
|
30
|
+
end
|
31
|
+
|
32
|
+
def Given(regular_expression, &block)
|
33
|
+
steps << [regular_expression, block]
|
34
|
+
end
|
35
|
+
alias :And :Given
|
36
|
+
alias :Then :Given
|
37
|
+
alias :When :Given
|
38
|
+
|
39
|
+
def Finally(regular_expression, &block)
|
40
|
+
raise "#{self}: Finally already defined, can only be defined once!" if @finally_defined
|
41
|
+
@finally_defined = true
|
42
|
+
steps << [regular_expression, block]
|
43
|
+
end
|
44
|
+
|
45
|
+
def Ensure(regular_expression, &block)
|
46
|
+
ensure_steps << [regular_expression, block]
|
47
|
+
end
|
48
|
+
|
49
|
+
def Failed(regular_expression, &block)
|
50
|
+
failure_steps << [regular_expression, block]
|
51
|
+
end
|
52
|
+
alias :If_failing :Failed
|
53
|
+
alias :When_failing :Failed
|
54
|
+
alias :If_this_failed :Failed
|
55
|
+
alias :If_that_failed :Failed
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
module Operation
|
3
|
+
module PromiseRun
|
4
|
+
def initialize(validated_props_hash)
|
5
|
+
@props = Isomorfeus::Data::Props.new(validated_props_hash)
|
6
|
+
end
|
7
|
+
|
8
|
+
def promise_run
|
9
|
+
promise = Promise.new
|
10
|
+
original_promise = promise
|
11
|
+
operation = self
|
12
|
+
|
13
|
+
# steps
|
14
|
+
self.class.gherkin[:steps].each do |gherkin_step|
|
15
|
+
matched = false
|
16
|
+
self.class.steps.each do |step|
|
17
|
+
# step[0] -> regular_expression
|
18
|
+
# step[1] -> block
|
19
|
+
match_data = gherkin_step.match(step[0])
|
20
|
+
if match_data
|
21
|
+
matched = true
|
22
|
+
promise = promise.then do |result|
|
23
|
+
operation.step_result = result
|
24
|
+
operation.instance_exec(*match_data, &step[1])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
raise "No match found for step #{gherkin_step}!" unless matched
|
29
|
+
end
|
30
|
+
|
31
|
+
# fail track
|
32
|
+
self.class.gherkin[:failure].each do |gherkin_step|
|
33
|
+
matched = false
|
34
|
+
self.class.failure_steps.each do |step|
|
35
|
+
# step[0] -> regular_expression
|
36
|
+
# step[1] -> block
|
37
|
+
match_data = gherkin_step.match(step[0])
|
38
|
+
if match_data
|
39
|
+
matched = true
|
40
|
+
promise = promise.fail do |result|
|
41
|
+
operation.step_result = result
|
42
|
+
operation.instance_exec(*match_data, &step[1])
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
raise "No match found for failure step #{gherkin_step}!" unless matched
|
47
|
+
end
|
48
|
+
|
49
|
+
# ensure
|
50
|
+
self.class.gherkin[:ensure].each do |gherkin_step|
|
51
|
+
matched = false
|
52
|
+
self.class.ensure_steps.each do |step|
|
53
|
+
# step[0] -> regular_expression
|
54
|
+
# step[1] -> block
|
55
|
+
match_data = gherkin_step.match(step[0])
|
56
|
+
if match_data
|
57
|
+
matched = true
|
58
|
+
|
59
|
+
promise = promise.then do |result|
|
60
|
+
operation.step_result = result
|
61
|
+
operation.instance_exec(*match_data, &step[1])
|
62
|
+
end.fail do |result|
|
63
|
+
operation.step_result = result
|
64
|
+
operation.instance_exec(*match_data, &step[1])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
raise "No match found for ensure step #{gherkin_step}!" unless matched
|
69
|
+
end
|
70
|
+
|
71
|
+
original_promise.resolve
|
72
|
+
promise
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'opal'
|
2
|
+
require 'opal-autoloader'
|
3
|
+
require 'opal-activesupport'
|
4
|
+
require 'isomorfeus-redux'
|
5
|
+
require 'isomorfeus-transport'
|
6
|
+
require 'isomorfeus/operation/config'
|
7
|
+
require 'isomorfeus/operation/gherkin'
|
8
|
+
require 'isomorfeus/operation/mixin'
|
9
|
+
require 'isomorfeus/operation/promise_run'
|
10
|
+
require 'lucid_local_operation/mixin'
|
11
|
+
require 'lucid_local_operation/base'
|
12
|
+
require 'lucid_quick_op/mixin'
|
13
|
+
require 'lucid_quick_op/base'
|
14
|
+
require 'lucid_operation/mixin'
|
15
|
+
require 'lucid_operation/base'
|
16
|
+
|
17
|
+
if RUBY_ENGINE == 'opal'
|
18
|
+
Opal::Autoloader.add_load_path('data')
|
19
|
+
else
|
20
|
+
require 'oj'
|
21
|
+
require 'isomorfeus/operation/handler/operation_handler'
|
22
|
+
|
23
|
+
Opal.append_path(__dir__.untaint) unless Opal.paths.include?(__dir__.untaint)
|
24
|
+
|
25
|
+
require 'active_support/dependencies'
|
26
|
+
|
27
|
+
path = File.expand_path(File.join('isomorfeus', 'operations'))
|
28
|
+
|
29
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
30
|
+
# we also need to require them all, so classes are registered accordingly
|
31
|
+
Dir.glob("#{path}/**/*.rb").each do |file|
|
32
|
+
require file
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module LucidLocalOperation
|
2
|
+
module Mixin
|
3
|
+
def self.included(base)
|
4
|
+
if RUBY_ENGINE != 'opal'
|
5
|
+
Isomorfeus.add_valid_operation_class(base) unless base == LucidLocalOperation::Base
|
6
|
+
end
|
7
|
+
|
8
|
+
base.extend(Isomorfeus::Data::PropDeclaration)
|
9
|
+
base.extend(Isomorfeus::Operation::Mixin)
|
10
|
+
base.include(Isomorfeus::Operation::PromiseRun)
|
11
|
+
|
12
|
+
base.instance_exec do
|
13
|
+
def promise_run(props_hash)
|
14
|
+
validate_props(props_hash)
|
15
|
+
self.new(props_hash).promise_run
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_accessor :props
|
21
|
+
attr_accessor :step_result
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidOperation
|
2
|
+
class Base
|
3
|
+
include LucidOperation::Mixin
|
4
|
+
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
def self.inherited(base)
|
7
|
+
Isomorfeus.add_valid_operation_class(base)
|
8
|
+
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :session_id, default: nil
|
11
|
+
base.prop :current_user, default: nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module LucidOperation
|
2
|
+
module Mixin
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(Isomorfeus::Data::PropDeclaration)
|
5
|
+
|
6
|
+
if RUBY_ENGINE == 'opal'
|
7
|
+
base.instance_exec do
|
8
|
+
def procedure(gherkin_text)
|
9
|
+
end
|
10
|
+
|
11
|
+
def steps
|
12
|
+
end
|
13
|
+
alias :gherkin :steps
|
14
|
+
alias :ensure_steps :steps
|
15
|
+
alias :failure_steps :steps
|
16
|
+
alias :Given :steps
|
17
|
+
alias :And :steps
|
18
|
+
alias :Then :steps
|
19
|
+
alias :When :steps
|
20
|
+
alias :Ensure :steps
|
21
|
+
alias :Failed :steps
|
22
|
+
alias :If_failing :steps
|
23
|
+
alias :When_failing :steps
|
24
|
+
alias :If_this_failed :steps
|
25
|
+
alias :If_that_failed :steps
|
26
|
+
|
27
|
+
def First(regular_expression, &block)
|
28
|
+
raise "#{self}: First already defined, can only be defined once!" if @first_defined
|
29
|
+
@first_defined = true
|
30
|
+
end
|
31
|
+
|
32
|
+
def Finally(regular_expression, &block)
|
33
|
+
raise "#{self}: Finally already defined, can only be defined once!" if @finally_defined
|
34
|
+
@finally_defined = true
|
35
|
+
end
|
36
|
+
|
37
|
+
def promise_run(props_hash)
|
38
|
+
validate_props(props_hash)
|
39
|
+
props_json = Isomorfeus::Data::Props.new(props_hash).to_json
|
40
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.name, props_json).then do |response|
|
41
|
+
if response[:agent_response].key?(:error)
|
42
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
43
|
+
raise response[:agent_response][:error]
|
44
|
+
end
|
45
|
+
response[:agent_response][:result]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
else
|
50
|
+
Isomorfeus.add_valid_operation_class(base) unless base == LucidOperation::Base
|
51
|
+
base.extend(Isomorfeus::Operation::Mixin)
|
52
|
+
base.include(Isomorfeus::Operation::PromiseRun)
|
53
|
+
|
54
|
+
unless base == LucidOperation::Base
|
55
|
+
base.prop :pub_sub_client, default: nil
|
56
|
+
base.prop :session_id, default: nil
|
57
|
+
base.prop :current_user, default: nil
|
58
|
+
end
|
59
|
+
|
60
|
+
base.instance_exec do
|
61
|
+
def promise_run(props_hash)
|
62
|
+
validate_props(props_hash)
|
63
|
+
self.new(props_hash).promise_run
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_accessor :props
|
68
|
+
attr_accessor :step_result
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module LucidQuickOp
|
2
|
+
class Base
|
3
|
+
include LucidQuickOp::Mixin
|
4
|
+
|
5
|
+
if RUBY_ENGINE != 'opal'
|
6
|
+
def self.inherited(base)
|
7
|
+
Isomorfeus.add_valid_operation_class(base)
|
8
|
+
|
9
|
+
base.prop :pub_sub_client, default: nil
|
10
|
+
base.prop :session_id, default: nil
|
11
|
+
base.prop :current_user, default: nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module LucidQuickOp
|
2
|
+
module Mixin
|
3
|
+
def self.included(base)
|
4
|
+
base.extend(Isomorfeus::Data::PropDeclaration)
|
5
|
+
|
6
|
+
if RUBY_ENGINE == 'opal'
|
7
|
+
base.instance_exec do
|
8
|
+
def op
|
9
|
+
end
|
10
|
+
|
11
|
+
def promise_run(props_hash)
|
12
|
+
validate_props(props_hash)
|
13
|
+
props_json = Isomorfeus::Data::Props.new(props_hash).to_json
|
14
|
+
Isomorfeus::Transport.promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.name, props_json).then do |response|
|
15
|
+
if response[:agent_response].key?(:error)
|
16
|
+
`console.error(#{response[:agent_response][:error].to_n})`
|
17
|
+
raise response[:agent_response][:error]
|
18
|
+
end
|
19
|
+
response[:agent_response][:result]
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
else
|
24
|
+
Isomorfeus.add_valid_operation_class(base) unless base == LucidQuickOp::Base
|
25
|
+
|
26
|
+
unless base == LucidQuickOp::Base
|
27
|
+
base.prop :pub_sub_client, default: nil
|
28
|
+
base.prop :session_id, default: nil
|
29
|
+
base.prop :current_user, default: nil
|
30
|
+
end
|
31
|
+
|
32
|
+
base.instance_exec do
|
33
|
+
def op(&block)
|
34
|
+
@op = block
|
35
|
+
end
|
36
|
+
|
37
|
+
def promise_run(props_hash)
|
38
|
+
validate_props(props_hash)
|
39
|
+
self.new(props_hash).promise_run
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
attr_accessor :props
|
46
|
+
|
47
|
+
def initialize(validated_props_hash)
|
48
|
+
@props = Isomorfeus::Data::Props.new(validated_props_hash)
|
49
|
+
@on_fail_track = false
|
50
|
+
end
|
51
|
+
|
52
|
+
def promise_run
|
53
|
+
original_promise = Promise.new.then
|
54
|
+
|
55
|
+
operation = self
|
56
|
+
promise = original_promise.then do |result|
|
57
|
+
operation.instance_exec(&self.class.instance_variable_get(:@op))
|
58
|
+
end
|
59
|
+
|
60
|
+
original_promise.resolve(true)
|
61
|
+
promise
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isomorfeus-operation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.delta11
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jan Biedermann
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '5.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: oj
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.8.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.8.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: opal
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.11.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.11.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: opal-activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.3
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: opal-autoloader
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: isomorfeus-redux
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 4.0.11
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 4.0.11
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: isomorfeus-transport
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.0.delta11
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.0.delta11
|
111
|
+
description: Write operations for Isomorfeus in your natural language.
|
112
|
+
email: jan@kursator.de
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- LICENSE
|
118
|
+
- README.md
|
119
|
+
- lib/isomorfeus-operation.rb
|
120
|
+
- lib/isomorfeus/operation/config.rb
|
121
|
+
- lib/isomorfeus/operation/gherkin.rb
|
122
|
+
- lib/isomorfeus/operation/handler/operation_handler.rb
|
123
|
+
- lib/isomorfeus/operation/mixin.rb
|
124
|
+
- lib/isomorfeus/operation/promise_run.rb
|
125
|
+
- lib/isomorfeus/operation/version.rb
|
126
|
+
- lib/lucid_local_operation/base.rb
|
127
|
+
- lib/lucid_local_operation/mixin.rb
|
128
|
+
- lib/lucid_operation/base.rb
|
129
|
+
- lib/lucid_operation/mixin.rb
|
130
|
+
- lib/lucid_quick_op/base.rb
|
131
|
+
- lib/lucid_quick_op/mixin.rb
|
132
|
+
homepage: http://isomorfeus.com
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: 1.3.1
|
150
|
+
requirements: []
|
151
|
+
rubygems_version: 3.0.3
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Natural language operations for Isomorfeus.
|
155
|
+
test_files: []
|