isomorfeus-operation 1.0.0.zeta12 → 1.0.0.zeta13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6658f36d7b9bff0810c5e57f9e0aa4e72980e544dc9ea5674ac9c2e0528217a2
4
- data.tar.gz: 66b4cc58e9d866b13e78fceb709ecb1865814bf45b4fb332c4caf8bd509254e4
3
+ metadata.gz: 6db4cbfe8ccb8fc09b927687cba57d15ec20139916c762f26eee0880248b37da
4
+ data.tar.gz: 0abf87b9875035ebfac2427663c85f5b09c5ab2e1581624f7d3332ee973a78b5
5
5
  SHA512:
6
- metadata.gz: 3e1d4fa270a2711fdc5fac1b68c06ad5b946776f5f55b4b6ce0353b733d91749c9d7d6e669955f2b40bffa6dd1345cf1a78e659225b175499649a8ba0d0bda6c
7
- data.tar.gz: fc6c803efd837f7e965a18ae7001f87677d8e5887b6f58d4adbe5731fca465593366279afd32455b260c33c7da051937289dd1bd4f979b37f45aff506f13a5a0
6
+ metadata.gz: a958cb2146c8b7e2f1de81f44eefbe15f509c647e99e202d7b6eb2f2693ff291511f506211984f112d1b41a56f899f2deea17a1b2fd25892dd468ef0eea3a766
7
+ data.tar.gz: ed134f2be6909d2909b2a3ecf0f42825cf8b8ec56d181e283d90a50e245457099393c571e36911d1035e027c7690d97a9c63e89b919769eafad467472cc8e6ca
@@ -4,7 +4,7 @@ module Isomorfeus
4
4
  module Operation
5
5
  module Handler
6
6
  class OperationHandler < LucidHandler::Base
7
- on_request do |pub_sub_client, current_user, response_agent|
7
+ on_request do |response_agent|
8
8
  # promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.to_s, props_hash)
9
9
  response_agent.request.each_key do |operation_class_name|
10
10
  if Isomorfeus.valid_operation_class_name?(operation_class_name)
@@ -13,8 +13,7 @@ module Isomorfeus
13
13
  props_json = response_agent.request[operation_class_name]
14
14
  begin
15
15
  props = Oj.load(props_json, mode: :strict)
16
- props.merge!({pub_sub_client: pub_sub_client, current_user: current_user})
17
- if current_user.authorized?(operation_class, :promise_run, props)
16
+ if Isomorfeus.current_user.authorized?(operation_class, :promise_run, props)
18
17
  operation_promise = operation_class.promise_run(props)
19
18
  if operation_promise.realized?
20
19
  response_agent.agent_result = { success: 'ok' , result: operation_promise.value }
@@ -38,17 +37,13 @@ module Isomorfeus
38
37
  response_agent.error = { error: 'Access denied!' }
39
38
  end
40
39
  rescue Exception => e
41
- response_agent.error = if Isomorfeus.production?
42
- { error: { operation_class_name => 'No such thing!' }}
43
- else
44
- { error: { operation_class_name => "Isomorfeus::Operation::Handler::OperationHandler: #{e.message}" }}
45
- end
40
+ response_agent.error = { error: { operation_class_name => "Isomorfeus::Operation::Handler::OperationHandler: #{e.message}" }}
46
41
  end
47
42
  else
48
- response_agent.error = { error: { operation_class_name => 'No such thing!' }}
43
+ response_agent.error = { error: { operation_class_name => 'Could not get operation class!' }}
49
44
  end
50
45
  else
51
- response_agent.error = { error: { operation_class_name => 'No such thing!' }}
46
+ response_agent.error = { error: { operation_class_name => 'No such operation class!' }}
52
47
  end
53
48
  end
54
49
  end
@@ -1,5 +1,5 @@
1
1
  module Isomorfeus
2
2
  module Operation
3
- VERSION = '1.0.0.zeta12'
3
+ VERSION = '1.0.0.zeta13'
4
4
  end
5
5
  end
@@ -3,6 +3,10 @@ module LucidLocalOperation
3
3
  def self.included(base)
4
4
  if RUBY_ENGINE != 'opal'
5
5
  Isomorfeus.add_valid_operation_class(base) unless base == LucidLocalOperation::Base
6
+
7
+ def pub_sub_client
8
+ Isomorfeus.pub_sub_client
9
+ end
6
10
  end
7
11
 
8
12
  base.extend(LucidPropDeclaration::Mixin)
@@ -20,5 +24,9 @@ module LucidLocalOperation
20
24
 
21
25
  attr_accessor :props
22
26
  attr_accessor :step_result
27
+
28
+ def current_user
29
+ Isomorfeus.current_user
30
+ end
23
31
  end
24
32
  end
@@ -5,9 +5,6 @@ module LucidOperation
5
5
  if RUBY_ENGINE != 'opal'
6
6
  def self.inherited(base)
7
7
  Isomorfeus.add_valid_operation_class(base)
8
-
9
- base.prop :pub_sub_client, default: nil
10
- base.prop :current_user, default: Anonymous.new
11
8
  end
12
9
  end
13
10
  end
@@ -28,30 +28,30 @@ module LucidOperation
28
28
  lines.each do |line|
29
29
  case line
30
30
  when STAR, GIVEN, WHEN, THEN, AND
31
- raise FINALLY_EXCEPTION if has_finally
31
+ Isomorfeus.raise_error(message: FINALLY_EXCEPTION) if has_finally
32
32
  operation[:steps] << $1.strip
33
33
  when ENSURE
34
34
  operation[:ensure] << $1.strip
35
35
  when IW_FAILING, IF_ITT_FAILED, FAILED
36
36
  operation[:failure] << $1.strip
37
37
  when FIRST
38
- raise FIRST_EXCEPTION if operation[:steps].size > 0
38
+ Isomorfeus.raise_error(message: FIRST_EXCEPTION) if operation[:steps].size > 0
39
39
  operation[:steps] << $1.strip
40
40
  when FINALLY
41
- raise FINALLY_EXCEPTION if has_finally
41
+ Isomorfeus.raise_error(message: FINALLY_EXCEPTION) if has_finally
42
42
  operation[:steps] << $1.strip
43
43
  has_finally = true
44
44
  when PROCEDURE
45
- raise 'No Operation defined!' if operation[:operation].empty?
46
- raise 'Procedure already defined!' unless operation[:procedure].empty?
45
+ Isomorfeus.raise_error(message: 'No Operation defined!') if operation[:operation].empty?
46
+ Isomorfeus.raise_error(message: 'Procedure already defined!') unless operation[:procedure].empty?
47
47
  operation[:procedure] = $1.strip
48
48
  when OPERATION
49
- raise 'Operation already defined!' unless operation[:operation].empty?
49
+ Isomorfeus.raise_error(message: 'Operation already defined!') unless operation[:operation].empty?
50
50
  operation[:operation] = $1.strip
51
51
  when WHITE_SPACE, COMMENT
52
52
  # nothing, just skip
53
53
  else
54
- raise "Unknown key word(s) at the beginning of the line: #{line}" unless operation[:procedure].empty?
54
+ Isomorfeus.raise_error(message: "Unknown key word(s) at the beginning of the line: #{line}") unless operation[:procedure].empty?
55
55
  operation[:description] = [] unless operation.key?(:description)
56
56
  operation[:description] << line.strip
57
57
  end
@@ -27,19 +27,19 @@ module LucidOperation
27
27
  alias :If_that_failed :steps
28
28
 
29
29
  def First(regular_expression, &block)
30
- raise "#{self}: First already defined, can only be defined once!" if @first_defined
30
+ Isomorfeus.raise_error(message: "#{self}: First already defined, can only be defined once!") if @first_defined
31
31
  @first_defined = true
32
32
  end
33
33
 
34
34
  def Finally(regular_expression, &block)
35
- raise "#{self}: Finally already defined, can only be defined once!" if @finally_defined
35
+ Isomorfeus.raise_error(message: "#{self}: Finally already defined, can only be defined once!") if @finally_defined
36
36
  @finally_defined = true
37
37
  end
38
38
 
39
39
  def promise_run(props_hash = nil)
40
40
  props_hash = props_hash || props
41
41
  validate_props(props_hash)
42
- props_json = Isomorfeus::Transport::PropsProxy.new(props_hash).to_json
42
+ props_json = Isomorfeus::PropsProxy.new(props_hash).to_json
43
43
  Isomorfeus::Transport.promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.name, props_json).then do |agent|
44
44
  if agent.processed
45
45
  agent.result
@@ -47,7 +47,7 @@ module LucidOperation
47
47
  agent.processed = true
48
48
  if agent.response.key?(:error)
49
49
  `console.error(#{agent.response[:error].to_n})`
50
- raise agent.response[:error]
50
+ Isomorfeus.raise_error(message: agent.response[:error])
51
51
  end
52
52
  agent.result = agent.response[:result]
53
53
  end
@@ -59,11 +59,6 @@ module LucidOperation
59
59
  base.extend(LucidOperation::Steps)
60
60
  base.include(LucidOperation::PromiseRun)
61
61
 
62
- unless base == LucidOperation::Base
63
- base.prop :pub_sub_client, default: nil
64
- base.prop :current_user, default: Anonymous.new
65
- end
66
-
67
62
  base.instance_exec do
68
63
  def promise_run(props_hash = nil)
69
64
  props_hash = props_hash || props
@@ -74,6 +69,14 @@ module LucidOperation
74
69
 
75
70
  attr_accessor :props
76
71
  attr_accessor :step_result
72
+
73
+ def current_user
74
+ Isomorfeus.current_user
75
+ end
76
+
77
+ def pub_sub_client
78
+ Isomorfeus.pub_sub_client
79
+ end
77
80
  end
78
81
  end
79
82
  end
@@ -1,7 +1,7 @@
1
1
  module LucidOperation
2
2
  module PromiseRun
3
3
  def initialize(validated_props_hash)
4
- @props = Isomorfeus::Transport::PropsProxy.new(validated_props_hash)
4
+ @props = Isomorfeus::PropsProxy.new(validated_props_hash)
5
5
  end
6
6
 
7
7
  def promise_run
@@ -24,7 +24,7 @@ module LucidOperation
24
24
  end
25
25
  end
26
26
  end
27
- raise "No match found for step #{gherkin_step}!" unless matched
27
+ Isomorfeus.raise_error(message: "No match found for step #{gherkin_step}!") unless matched
28
28
  end
29
29
 
30
30
  # fail track
@@ -42,7 +42,7 @@ module LucidOperation
42
42
  end
43
43
  end
44
44
  end
45
- raise "No match found for failure step #{gherkin_step}!" unless matched
45
+ Isomorfeus.raise_error(message: "No match found for failure step #{gherkin_step}!") unless matched
46
46
  end
47
47
 
48
48
  # ensure
@@ -64,7 +64,7 @@ module LucidOperation
64
64
  end
65
65
  end
66
66
  end
67
- raise "No match found for ensure step #{gherkin_step}!" unless matched
67
+ Isomorfeus.raise_error(message: "No match found for ensure step #{gherkin_step}!") unless matched
68
68
  end
69
69
 
70
70
  original_promise.resolve
@@ -25,7 +25,7 @@ module LucidOperation
25
25
  end
26
26
 
27
27
  def First(regular_expression, &block)
28
- raise "#{self}: First already defined, can only be defined once!" if @first_defined
28
+ Isomorfeus.raise_error(message: "#{self}: First already defined, can only be defined once!") if @first_defined
29
29
  @first_defined = true
30
30
  steps << [regular_expression, block]
31
31
  end
@@ -38,7 +38,7 @@ module LucidOperation
38
38
  alias :When :Given
39
39
 
40
40
  def Finally(regular_expression, &block)
41
- raise "#{self}: Finally already defined, can only be defined once!" if @finally_defined
41
+ Isomorfeus.raise_error(message: "#{self}: Finally already defined, can only be defined once!") if @finally_defined
42
42
  @finally_defined = true
43
43
  steps << [regular_expression, block]
44
44
  end
@@ -5,9 +5,6 @@ module LucidQuickOp
5
5
  if RUBY_ENGINE != 'opal'
6
6
  def self.inherited(base)
7
7
  Isomorfeus.add_valid_operation_class(base)
8
-
9
- base.prop :pub_sub_client, default: nil
10
- base.prop :current_user, default: Anonymous.new
11
8
  end
12
9
  end
13
10
  end
@@ -11,7 +11,7 @@ module LucidQuickOp
11
11
  def promise_run(props_hash = nil)
12
12
  props_hash = props_hash || props
13
13
  validate_props(props_hash)
14
- props_json = Isomorfeus::Transport::PropsProxy.new(props_hash).to_json
14
+ props_json = Isomorfeus::PropsProxy.new(props_hash).to_json
15
15
  Isomorfeus::Transport.promise_send_path('Isomorfeus::Operation::Handler::OperationHandler', self.name, props_json).then do |agent|
16
16
  if agent.processed
17
17
  agent.result
@@ -19,7 +19,7 @@ module LucidQuickOp
19
19
  agent.processed = true
20
20
  if agent.response.key?(:error)
21
21
  `console.error(#{agent.response[:error].to_n})`
22
- raise agent.response[:error]
22
+ Isomorfeus.raise_error(message: agent.response[:error])
23
23
  end
24
24
  agent.result = agent.response[:result]
25
25
  end
@@ -29,11 +29,6 @@ module LucidQuickOp
29
29
  else
30
30
  Isomorfeus.add_valid_operation_class(base) unless base == LucidQuickOp::Base
31
31
 
32
- unless base == LucidQuickOp::Base
33
- base.prop :pub_sub_client, default: nil
34
- base.prop :current_user, default: Anonymous.new
35
- end
36
-
37
32
  base.instance_exec do
38
33
  def op(&block)
39
34
  @op = block
@@ -51,7 +46,7 @@ module LucidQuickOp
51
46
  attr_accessor :props
52
47
 
53
48
  def initialize(validated_props_hash)
54
- @props = Isomorfeus::Transport::PropsProxy.new(validated_props_hash)
49
+ @props = Isomorfeus::PropsProxy.new(validated_props_hash)
55
50
  @on_fail_track = false
56
51
  end
57
52
 
@@ -66,5 +61,13 @@ module LucidQuickOp
66
61
  original_promise.resolve(true)
67
62
  promise
68
63
  end
64
+
65
+ def current_user
66
+ Isomorfeus.current_user
67
+ end
68
+
69
+ def pub_sub_client
70
+ Isomorfeus.pub_sub_client
71
+ end
69
72
  end
70
73
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isomorfeus-operation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.zeta12
4
+ version: 1.0.0.zeta13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Biedermann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-19 00:00:00.000000000 Z
11
+ date: 2020-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 16.12.9
75
+ version: 16.12.14
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 16.12.9
82
+ version: 16.12.14
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: isomorfeus-redux
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - '='
102
102
  - !ruby/object:Gem::Version
103
- version: 1.0.0.zeta12
103
+ version: 1.0.0.zeta13
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - '='
109
109
  - !ruby/object:Gem::Version
110
- version: 1.0.0.zeta12
110
+ version: 1.0.0.zeta13
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: isomorfeus
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - '='
116
116
  - !ruby/object:Gem::Version
117
- version: 1.0.0.zeta12
117
+ version: 1.0.0.zeta13
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
- version: 1.0.0.zeta12
124
+ version: 1.0.0.zeta13
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: opal-webpack-loader
127
127
  requirement: !ruby/object:Gem::Requirement