cpee-eval-ruby 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cpee-eval-ruby.gemspec +1 -1
- data/lib/cpee-eval-ruby/implementation.rb +50 -13
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e4dd48f18c69a6f6241d950ad7914a4320bd598cf45c946f9387d14d830c30d
|
4
|
+
data.tar.gz: 0eaee079ea7cd2d29cc4cda8e384e58a710b41c2c5bafa4f0b775696c3bd3f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 106283883bded1b8e700ab113771d06eea788165e0c333f0b0aab68e115cc25341c6995fac31f8d8e992d112067690fac299d12760f2a9c8ae14d1280a44ca8a
|
7
|
+
data.tar.gz: 3d67ddb14d6bb876afaab120740c993bd336c64a0b652b81143f3565291a7f37a7bca693b3e461e1bdb332bc993b29f0f09d7edfb6a4fea504c2d043a507f148
|
data/cpee-eval-ruby.gemspec
CHANGED
@@ -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
|
-
|
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.
|
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
|
-
|
65
|
-
|
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
|
-
|
73
|
-
|
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
|
-
|
81
|
-
|
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
|
-
|
84
|
-
|
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
|
-
|
88
|
-
|
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 #}}}
|