cpee-eval-ruby 1.0.3 → 1.0.5

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: da15f25700974469442cef4cdd7b52e6a42c846430bdd5e0d1d1d13eb49a681c
4
- data.tar.gz: 976a7f9f849f4d8bce0eed92fdd717bbf7f6447ac2a4f7ef2a7dd4ffbc071841
3
+ metadata.gz: 577aa3b37ebdabc0e3795ce991e717caae16b93e5133c869116599fc1dcc68b6
4
+ data.tar.gz: cff8a4e9685315c2a81fdf82540fa6feb8e92418f0dc444df71b9700a7d10df9
5
5
  SHA512:
6
- metadata.gz: b3d5e23c492473deb8b3ab3c49dd69f7d6749e95a600a31ed3c7d9df0e53e7dd06e23d71b5053de602423232c86f1cfb1b55b8ae371896f46f59690a5fbfa064
7
- data.tar.gz: 40a311a0c2f834d182bdb5f50e6d35c761ffb0903fee569a68a922ca807fae4e177a5d56fe109df9a2a584a5db6464e01865d77fceb3d0ff5581a09a5c03d391
6
+ metadata.gz: 64ae1dbf57a22276c15d1526fe7fe8b58be5f65427eb32ce2d2462c0b45c28cad5ff8b6acf765498987e9b49b068816727968277ebb46aa113558a6ff5d0e3df
7
+ data.tar.gz: 83d6516896b832b841b325499a7e9d946e7dc15d0b9dc69037cb1cb1dffa5386c5d371ed19008191aa29324a5ace2843577d91e9701095c9d669f58f76572228
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-eval-ruby"
3
- s.version = "1.0.3"
3
+ s.version = "1.0.5"
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.license = "LGPL-3.0-or-later"
6
6
  s.summary = "Ruby eval for the cloud process execution engine (cpee.org)"
@@ -21,5 +21,5 @@ Gem::Specification.new do |s|
21
21
  s.homepage = 'http://cpee.org/'
22
22
 
23
23
  s.add_runtime_dependency 'riddl', '~> 1.0'
24
- s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.67'
24
+ s.add_runtime_dependency 'cpee', '~> 2.1', '>= 2.1.69'
25
25
  end
@@ -33,7 +33,29 @@ module CPEE
33
33
 
34
34
  class DoIt < Riddl::Implementation #{{{
35
35
  def exec(__struct,__code,result=nil,headers=nil)
36
- __struct.instance_eval(__code)
36
+ __ret = {}
37
+ __cat = catch WEEL::Signal::Again do
38
+ __ret[:res] = __struct.instance_eval(__code)
39
+ WEEL::Signal::Proceed
40
+ end
41
+ if __cat.nil? || __cat == WEEL::Signal::Again
42
+ __ret[:signal] << 'Signal::Again'
43
+ end
44
+ rescue => err
45
+ __ret[:signal] = 'Signal::Error'
46
+ __ret[:signal_text] = (err.backtrace ? err.backtrace[0].gsub(/([\w -_]+):(\d+):in.*/,'\\1, Line \2: ') : '') + err.message
47
+ rescue WEEL::Signal::Again
48
+ __ret[:signal] = 'Signal::Again'
49
+ rescue WEEL::Signal::Error => err
50
+ __ret[:signal] = 'Signal::Error'
51
+ __ret[:signal_text] = (err.backtrace ? err.backtrace[0].gsub(/([\w -_]+):(\d+):in.*/,'\\1, Line \2: ') : '') + err.message
52
+ rescue WEEL::Signal::Stop
53
+ __ret[:signal] = 'Signal::Stop'
54
+ rescue SyntaxError => err
55
+ __ret[:signal] = 'Signal::SyntaxError'
56
+ __ret[:signal_text] = err.message
57
+ ensure
58
+ return __ret
37
59
  end
38
60
 
39
61
  def response
@@ -49,9 +71,11 @@ module CPEE
49
71
  call_result = JSON::parse(@p.shift.value.read) if @p.any? && @p[0].name == 'call_result'
50
72
  call_headers = JSON::parse(@p.shift.value.read) if @p.any? && @p[0].name == 'call_headers'
51
73
 
74
+ local = local[0] if local && local.is_a?(Array)
75
+
52
76
  # symbolize keys, because JSON
53
77
  dataelements.transform_keys!{|k| k.to_sym}
54
- local.first.transform_keys!{|k| k.to_sym} if local
78
+ local.transform_keys!{|k| k.to_sym} if local
55
79
  endpoints.transform_keys!{|k| k.to_sym}
56
80
  additional.transform_keys!{|k| k.to_sym}
57
81
  additional.each_value do |v|
@@ -60,32 +84,45 @@ module CPEE
60
84
 
61
85
  if status || call_result || call_headers
62
86
  struct = WEEL::ManipulateStructure.new(dataelements,endpoints,status,local,additional)
63
- exec struct, code, CPEE::EvalRuby::Translation::simplify_structurized_result(call_result), call_headers
64
- ret = []
65
- ret.push Riddl::Parameter::Simple.new('result','')
87
+ execresult = exec struct, code, CPEE::EvalRuby::Translation::simplify_structurized_result(call_result), call_headers
88
+
89
+ send = []
90
+ send << Riddl::Parameter::Simple.new('result',execresult[:res])
91
+ if execresult[:signal]
92
+ send << Riddl::Parameter::Simple.new('signal',execresult[:signal])
93
+ send << Riddl::Parameter::Simple.new('signal_text',execresult[:signal_text] || '')
94
+ @status = 555
95
+ end
66
96
 
67
97
  res = {}
68
98
  struct.changed_data.each do |e|
69
99
  res[e] = struct.data[e]
70
100
  end
71
101
  if res.any?
72
- ret.push Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(data)) if mode == :full
73
- ret.push Riddl::Parameter::Complex.new('changed_dataelements','application/json',JSON::generate(res))
102
+ send << Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(data)) if mode == :full
103
+ send << Riddl::Parameter::Complex.new('changed_dataelements','application/json',JSON::generate(res))
74
104
  end
75
105
  res = {}
76
106
  struct.changed_endpoints.each do |e|
77
107
  res[e] = struct.endpoints[e]
78
108
  end
79
109
  if res.any?
80
- ret.push Riddl::Parameter::Complex.new('endpoints','application/json',JSON::generate(endpoints)) if mode == :full
81
- ret.push Riddl::Parameter::Complex.new('changed_endpoints','application/json',JSON::generate(res))
110
+ send << Riddl::Parameter::Complex.new('endpoints','application/json',JSON::generate(endpoints)) if mode == :full
111
+ send << Riddl::Parameter::Complex.new('changed_endpoints','application/json',JSON::generate(res))
82
112
  end
83
- ret.push Riddl::Parameter::Complex.new('changed_status','application/json',JSON::generate(status)) if struct.changed_status
84
- ret
113
+ send << Riddl::Parameter::Complex.new('changed_status','application/json',JSON::generate(status)) if struct.changed_status
114
+ send
85
115
  else
86
116
  struct = WEEL::ReadStructure.new(dataelements,endpoints,local,additional)
87
- res = exec struct, code
88
- Riddl::Parameter::Simple.new('result',res)
117
+ execresult = exec struct, code
118
+ send = []
119
+ send << Riddl::Parameter::Simple.new('result',execresult[:res])
120
+ if execresult[:signal]
121
+ send << Riddl::Parameter::Simple.new('signal',execresult[:signal])
122
+ send << Riddl::Parameter::Simple.new('signal_text',execresult[:signal_text] || '')
123
+ @status = 555
124
+ end
125
+ send
89
126
  end
90
127
  end
91
128
  end #}}}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpee-eval-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juergen eTM Mangler
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: '2.1'
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 2.1.67
36
+ version: 2.1.69
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '2.1'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.1.67
46
+ version: 2.1.69
47
47
  description: see http://cpee.org
48
48
  email: juergen.mangler@gmail.com
49
49
  executables: