cpee-eval-ruby 1.0.5 → 1.0.8

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: 577aa3b37ebdabc0e3795ce991e717caae16b93e5133c869116599fc1dcc68b6
4
- data.tar.gz: cff8a4e9685315c2a81fdf82540fa6feb8e92418f0dc444df71b9700a7d10df9
3
+ metadata.gz: 84fc79790dae3221f52506e89cac2873c3b87df3b453f28fcf66e6274fbbe9ed
4
+ data.tar.gz: 024a8c81054a23b338d794898fa8f459f6b603eca6aa53fab2c507d414243c35
5
5
  SHA512:
6
- metadata.gz: 64ae1dbf57a22276c15d1526fe7fe8b58be5f65427eb32ce2d2462c0b45c28cad5ff8b6acf765498987e9b49b068816727968277ebb46aa113558a6ff5d0e3df
7
- data.tar.gz: 83d6516896b832b841b325499a7e9d946e7dc15d0b9dc69037cb1cb1dffa5386c5d371ed19008191aa29324a5ace2843577d91e9701095c9d669f58f76572228
6
+ metadata.gz: e24df120022480933494c3040f9e47589a6bb410433e152a89a91d14c9ff5e5b564f63bf341b53db84e72ab6515df36d437493103dbb1c0be94cb19bb06a0e40
7
+ data.tar.gz: 7d9d35d776ea27611803bbd3a20ea5635b0c2027df74e885ae52e21e48df0ce1d8386fd8becc6567007efa1e573d7c070db059e0370a30c586b05e9b436a9b6b
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "cpee-eval-ruby"
3
- s.version = "1.0.5"
3
+ s.version = "1.0.8"
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.69'
24
+ s.add_runtime_dependency 'weel', '~> 1.99'
25
25
  end
@@ -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::Simple.new('result',execresult[:res])
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(data)) if mode == :full
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::Simple.new('result',execresult[:res])
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
- <choice>
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
- <choice>
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|
@@ -0,0 +1 @@
1
+ 934659
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.5
4
+ version: 1.0.8
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: 2024-09-19 00:00:00.000000000 Z
11
+ date: 2024-12-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riddl
@@ -25,25 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: cpee
28
+ name: weel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 2.1.69
33
+ version: '1.99'
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '2.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 2.1.69
40
+ version: '1.99'
47
41
  description: see http://cpee.org
48
42
  email: juergen.mangler@gmail.com
49
43
  executables:
@@ -61,6 +55,7 @@ files:
61
55
  - lib/cpee-eval-ruby/implementation.xml
62
56
  - lib/cpee-eval-ruby/translation.rb
63
57
  - server/eval-ruby
58
+ - server/eval-ruby.pid
64
59
  - tools/cpee-eval-ruby
65
60
  homepage: http://cpee.org/
66
61
  licenses:
@@ -81,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
76
  - !ruby/object:Gem::Version
82
77
  version: '0'
83
78
  requirements: []
84
- rubygems_version: 3.5.11
79
+ rubygems_version: 3.5.16
85
80
  signing_key:
86
81
  specification_version: 4
87
82
  summary: Ruby eval for the cloud process execution engine (cpee.org)