cpee-eval-ruby 1.0.11 → 1.0.12
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 +4 -4
- data/cpee-eval-ruby.gemspec +1 -1
- data/lib/cpee-eval-ruby/translation.rb +17 -12
- 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: 1100e6e380d5ab3d506f3a6b03b3fee539648e685fdc7c8b8b95e4aadfb96c16
|
|
4
|
+
data.tar.gz: 1f45b651b723e3ac40e8d1658847ef8a981549c1cf5d366580542a4d6a1f8b7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6373c46d96efb571764440d59dd693586e2ecf0518d758a189e4c4802e072f51a48e3eb7a269aec7076bee7bcf6714d03216b8a80f8a99cccb898d152d5c3c0b
|
|
7
|
+
data.tar.gz: efbbe6211d16390e8b5cf02e4bacd3b57c864303a3f5ad1f97ce5e3d97d9a95568ca5fbe5b5af07234eed6a3eb30d36480b7817f92bfe9fd1723b0a5ddc0215f
|
data/cpee-eval-ruby.gemspec
CHANGED
|
@@ -80,15 +80,19 @@ module CPEE
|
|
|
80
80
|
result = result[0].value
|
|
81
81
|
elsif result[0].is_a? Riddl::Parameter::Complex
|
|
82
82
|
if result[0].mimetype == 'application/json'
|
|
83
|
-
|
|
83
|
+
ttt = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
84
|
+
result = JSON::parse(ttt) rescue nil
|
|
84
85
|
elsif result[0].mimetype == 'text/csv'
|
|
85
|
-
|
|
86
|
+
ttt = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
87
|
+
result = ttt
|
|
86
88
|
elsif result[0].mimetype == 'text/yaml'
|
|
87
|
-
|
|
89
|
+
ttt = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
90
|
+
result = YAML::load(ttt) rescue nil
|
|
88
91
|
elsif result[0].mimetype == 'application/xml' || result[0].mimetype == 'text/xml'
|
|
89
|
-
|
|
92
|
+
ttt = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
93
|
+
result = XML::Smart::string(ttt) rescue nil
|
|
90
94
|
elsif result[0].mimetype == 'text/plain'
|
|
91
|
-
result = result[0].value.read
|
|
95
|
+
result = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
92
96
|
if result.start_with?("<?xml version=")
|
|
93
97
|
result = XML::Smart::string(result)
|
|
94
98
|
else
|
|
@@ -96,7 +100,7 @@ module CPEE
|
|
|
96
100
|
result = result.to_i if result == result.to_i.to_s
|
|
97
101
|
end
|
|
98
102
|
elsif result[0].mimetype == 'text/html'
|
|
99
|
-
result = result[0].value.read
|
|
103
|
+
result = (result[0].value.respond_to?(:read) ? result[0].value.read : result[0].value) rescue nil
|
|
100
104
|
result = result.to_f if result == result.to_f.to_s
|
|
101
105
|
result = result.to_i if result == result.to_i.to_s
|
|
102
106
|
else
|
|
@@ -139,7 +143,7 @@ module CPEE
|
|
|
139
143
|
def self::extract_base64(text)
|
|
140
144
|
if text.is_a?(String) && text.start_with?(/(data:[\w_\/-]+;base64,)/)
|
|
141
145
|
Base64::decode64(text.delete_prefix $1)
|
|
142
|
-
else
|
|
146
|
+
else
|
|
143
147
|
text
|
|
144
148
|
end
|
|
145
149
|
end
|
|
@@ -150,21 +154,22 @@ module CPEE
|
|
|
150
154
|
{ 'name' => r.name, 'data' => r.value }
|
|
151
155
|
elsif r.is_a? Riddl::Parameter::Complex
|
|
152
156
|
res = if r.mimetype == 'application/json'
|
|
153
|
-
ttt = r.value.read
|
|
157
|
+
ttt = r.value.respond_to?(:read) ? r.value.read : r.value
|
|
154
158
|
enc = CPEE::EvalRuby::Translation::detect_encoding(ttt)
|
|
155
159
|
enc == 'OTHER' ? ttt.inspect : (ttt.encode('UTF-8',enc) rescue CPEE::EvalRuby::Translation::convert_to_base64(ttt))
|
|
156
160
|
elsif r.mimetype == 'text/csv'
|
|
157
|
-
ttt = r.value.read
|
|
161
|
+
ttt = r.value.respond_to?(:read) ? r.value.read : r.value
|
|
158
162
|
enc = CPEE::EvalRuby::Translation::detect_encoding(ttt)
|
|
159
163
|
enc == 'OTHER' ? ttt.inspect : (ttt.encode('UTF-8',enc) rescue CPEE::EvalRuby::Translation::convert_to_base64(ttt))
|
|
160
164
|
elsif r.mimetype == 'text/plain' || r.mimetype == 'text/html'
|
|
161
|
-
ttt = r.value.read
|
|
165
|
+
ttt = r.value.respond_to?(:read) ? r.value.read : r.value
|
|
162
166
|
ttt = ttt.to_f if ttt == ttt.to_f.to_s
|
|
163
167
|
ttt = ttt.to_i if ttt == ttt.to_i.to_s
|
|
164
168
|
enc = CPEE::EvalRuby::Translation::detect_encoding(ttt)
|
|
165
169
|
enc == 'OTHER' ? ttt.inspect : (ttt.encode('UTF-8',enc) rescue CPEE::EvalRuby::Translation::convert_to_base64(ttt))
|
|
166
170
|
else
|
|
167
|
-
|
|
171
|
+
ttt = r.value.respond_to?(:read) ? r.value.read : r.value
|
|
172
|
+
CPEE::EvalRuby::Translation::convert_to_base64(ttt)
|
|
168
173
|
end
|
|
169
174
|
|
|
170
175
|
tmp = {
|
|
@@ -172,7 +177,7 @@ module CPEE
|
|
|
172
177
|
'mimetype' => r.mimetype,
|
|
173
178
|
'data' => res.to_s
|
|
174
179
|
}
|
|
175
|
-
r.value.rewind
|
|
180
|
+
r.value.rewind if r.value.respond_to? :rewind
|
|
176
181
|
tmp
|
|
177
182
|
end
|
|
178
183
|
end
|