cpee-eval-ruby 1.0.7 → 1.0.9
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2774052deae77541d37971396fc69447e1bff85659320e055e07e14898dc570
|
4
|
+
data.tar.gz: a7ccdf82f5b562fcce960ca5a07ee95fe30d3b815b5f7a6aaab151a0758b25aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52e6f40127778af21e519a59acdf71c6381d9e14b0d86755cd0cf7c5fb5f0610bc405f7603201ba4bf370d274cbde7425217f9d18fd6da228bcc64630b678045
|
7
|
+
data.tar.gz: b40fcf232f385c29f8af0b483d4e814c4d5d80f0f57ee8a23c28fb63a2cf03c15442d20c877bb4c8548be223d7d83e0a383253fd629baa729b8a4054aeb49b00
|
data/cpee-eval-ruby.gemspec
CHANGED
@@ -24,6 +24,7 @@ require 'uri'
|
|
24
24
|
require 'redis'
|
25
25
|
require 'json'
|
26
26
|
require 'weel'
|
27
|
+
require 'charlock_holmes'
|
27
28
|
require_relative 'translation'
|
28
29
|
|
29
30
|
module CPEE
|
@@ -35,7 +36,7 @@ module CPEE
|
|
35
36
|
def exec(__struct,__code,result=nil,headers=nil)
|
36
37
|
__ret = {}
|
37
38
|
__cat = catch WEEL::Signal::Again do
|
38
|
-
__ret[:res] = __struct.instance_eval(__code)
|
39
|
+
__ret[:res] = JSON::generate(__struct.instance_eval(__code))
|
39
40
|
WEEL::Signal::Proceed
|
40
41
|
end
|
41
42
|
if __cat.nil? || __cat == WEEL::Signal::Again
|
@@ -87,7 +88,7 @@ module CPEE
|
|
87
88
|
execresult = exec struct, code, CPEE::EvalRuby::Translation::simplify_structurized_result(call_result), call_headers
|
88
89
|
|
89
90
|
send = []
|
90
|
-
send << Riddl::Parameter::
|
91
|
+
send << Riddl::Parameter::Complex.new('result','application/json',execresult[:res] || '')
|
91
92
|
if execresult[:signal]
|
92
93
|
send << Riddl::Parameter::Simple.new('signal',execresult[:signal])
|
93
94
|
send << Riddl::Parameter::Simple.new('signal_text',execresult[:signal_text] || '')
|
@@ -99,7 +100,7 @@ module CPEE
|
|
99
100
|
res[e] = struct.data[e]
|
100
101
|
end
|
101
102
|
if res.any?
|
102
|
-
send << Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(
|
103
|
+
send << Riddl::Parameter::Complex.new('dataelements','application/json',JSON::generate(dataelements)) if mode == :full
|
103
104
|
send << Riddl::Parameter::Complex.new('changed_dataelements','application/json',JSON::generate(res))
|
104
105
|
end
|
105
106
|
res = {}
|
@@ -116,7 +117,7 @@ module CPEE
|
|
116
117
|
struct = WEEL::ReadStructure.new(dataelements,endpoints,local,additional)
|
117
118
|
execresult = exec struct, code
|
118
119
|
send = []
|
119
|
-
send << Riddl::Parameter::
|
120
|
+
send << Riddl::Parameter::Complex.new('result','application/json',execresult[:res] || '')
|
120
121
|
if execresult[:signal]
|
121
122
|
send << Riddl::Parameter::Simple.new('signal',execresult[:signal])
|
122
123
|
send << Riddl::Parameter::Simple.new('signal_text',execresult[:signal_text] || '')
|
@@ -35,10 +35,7 @@
|
|
35
35
|
</message>
|
36
36
|
|
37
37
|
<message name="res">
|
38
|
-
<
|
39
|
-
<parameter name="result" type="boolean"/>
|
40
|
-
<parameter name="result" type="string"/>
|
41
|
-
</choice>
|
38
|
+
<parameter name="result" mimetype="application/json"/>
|
42
39
|
<optional>
|
43
40
|
<parameter name="signal" type="string"/>
|
44
41
|
<parameter name="signal_text" type="string"/>
|
@@ -54,10 +51,7 @@
|
|
54
51
|
</optional>
|
55
52
|
</message>
|
56
53
|
<message name="res-full">
|
57
|
-
<
|
58
|
-
<parameter name="result" type="boolean"/>
|
59
|
-
<parameter name="result" type="string"/>
|
60
|
-
</choice>
|
54
|
+
<parameter name="result" mimetype="application/json"/>
|
61
55
|
<optional>
|
62
56
|
<parameter name="signal" type="string"/>
|
63
57
|
<parameter name="signal_text" type="string"/>
|
@@ -38,15 +38,15 @@ module CPEE
|
|
38
38
|
if result && result.length == 1
|
39
39
|
if result[0].has_key? 'mimetype'
|
40
40
|
if result[0]['mimetype'] == 'application/json'
|
41
|
-
result = JSON::parse(result[0]['data']) rescue nil
|
41
|
+
result = JSON::parse(CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])) rescue nil
|
42
42
|
elsif result[0]['mimetype'] == 'text/csv'
|
43
|
-
result = result[0]['data']
|
43
|
+
result = CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])
|
44
44
|
elsif result[0]['mimetype'] == 'text/yaml'
|
45
|
-
result = YAML::load(result[0]['data']) rescue nil
|
45
|
+
result = YAML::load(CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])) rescue nil
|
46
46
|
elsif result[0]['mimetype'] == 'application/xml' || result[0]['mimetype'] == 'text/xml'
|
47
|
-
result = XML::Smart::string(result[0]['data']) rescue nil
|
47
|
+
result = XML::Smart::string(CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])) rescue nil
|
48
48
|
elsif result[0]['mimetype'] == 'text/plain'
|
49
|
-
result = result[0]['data']
|
49
|
+
result = CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])
|
50
50
|
if result.start_with?("<?xml version=")
|
51
51
|
result = XML::Smart::string(result)
|
52
52
|
else
|
@@ -54,7 +54,7 @@ module CPEE
|
|
54
54
|
result = result.to_i if result == result.to_i.to_s
|
55
55
|
end
|
56
56
|
elsif result[0]['mimetype'] == 'text/html'
|
57
|
-
result = result[0]['data']
|
57
|
+
result = CPEE::EvalRuby::Translation::extract_base64(result[0]['data'])
|
58
58
|
result = result.to_f if result == result.to_f.to_s
|
59
59
|
result = result.to_i if result == result.to_i.to_s
|
60
60
|
else
|
@@ -136,6 +136,13 @@ module CPEE
|
|
136
136
|
def self::convert_to_base64(text)
|
137
137
|
('data:' + MimeMagic.by_magic(text).type + ';base64,' + Base64::encode64(text)) rescue ('data:application/octet-stream;base64,' + Base64::encode64(text))
|
138
138
|
end
|
139
|
+
def self::extract_base64(text)
|
140
|
+
if text.is_a?(String) && text.start_with?(/(data:[\w_\/-]+;base64,)/)
|
141
|
+
Base64::decode64(text.delete_prefix $1)
|
142
|
+
else
|
143
|
+
text
|
144
|
+
end
|
145
|
+
end
|
139
146
|
|
140
147
|
def self::structurize_result(result)
|
141
148
|
result.map do |r|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cpee-eval-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juergen eTM Mangler
|
8
8
|
autorequire:
|
9
9
|
bindir: tools
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riddl
|
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: '0'
|
77
77
|
requirements: []
|
78
|
-
rubygems_version: 3.5.
|
78
|
+
rubygems_version: 3.5.22
|
79
79
|
signing_key:
|
80
80
|
specification_version: 4
|
81
81
|
summary: Ruby eval for the cloud process execution engine (cpee.org)
|