refx-engine-p3lib 0.0.4 → 0.0.5
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/lib/refx/engine/p3lib/p3lib_hash_from_xml.rb +32 -0
- data/lib/refx/engine/p3lib/version.rb +1 -1
- data/test/test_helper.rb +1 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a8d3632aa334109feb65b60bca34ad505512354
|
4
|
+
data.tar.gz: 8b7e8567e0903e373c38117bcc0e477b442477a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c72ff8069b947c9858c5bb47756453fb22451a555fb00619259f3a1d8d55a05663c01e69ae272047386c15db136dc0c44ef4be5fc83239c57cbc3ca06fae122
|
7
|
+
data.tar.gz: 1febf5316ab8f5c2e11e2e7bb70f934a1b2015ec4b6d1663bd0f6156b8fa2ec5b97cd8b4e34592cfbac7061250a008a557430143265113ae0689fa5b7afeb4ea
|
@@ -4,7 +4,39 @@ require 'xmlsimple'
|
|
4
4
|
#
|
5
5
|
# require 'refx/engine/p3lib/p3lib_hash_from_xml'
|
6
6
|
|
7
|
+
|
8
|
+
|
9
|
+
|
7
10
|
class Hash
|
11
|
+
|
12
|
+
unless defined?(XML_PARSING)
|
13
|
+
XML_PARSING = {
|
14
|
+
"symbol" => Proc.new { |symbol| symbol.to_sym },
|
15
|
+
"date" => Proc.new { |date| ::Date.parse(date) },
|
16
|
+
"datetime" => Proc.new { |time| ::Time.parse(time).utc },
|
17
|
+
"integer" => Proc.new { |integer| integer.to_i },
|
18
|
+
"float" => Proc.new { |float| float.to_f },
|
19
|
+
"decimal" => Proc.new { |number| BigDecimal(number) },
|
20
|
+
"boolean" => Proc.new { |boolean| %w(1 true).include?(boolean.strip) },
|
21
|
+
"string" => Proc.new { |string| string.to_s },
|
22
|
+
"yaml" => Proc.new { |yaml| YAML::load(yaml) rescue yaml },
|
23
|
+
"base64Binary" => Proc.new { |bin| Base64.decode64(bin) },
|
24
|
+
# FIXME: Get rid of eval and institute a proper decorator here
|
25
|
+
"file" => Proc.new do |file, entity|
|
26
|
+
f = StringIO.new(Base64.decode64(file))
|
27
|
+
eval "def f.original_filename() '#{entity["name"]}' || 'untitled' end"
|
28
|
+
eval "def f.content_type() '#{entity["content_type"]}' || 'application/octet-stream' end"
|
29
|
+
f
|
30
|
+
end
|
31
|
+
}
|
32
|
+
|
33
|
+
XML_PARSING.update(
|
34
|
+
"double" => XML_PARSING["float"],
|
35
|
+
"dateTime" => XML_PARSING["datetime"]
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
|
8
40
|
def self.from_xml(xml, preserve_attributes = false)
|
9
41
|
typecast_xml_value(self.undasherize_keys(XmlSimple.xml_in(xml,'forcearray'=>false,'forcecontent'=>true,'keeproot'=>true,'contentkey'=>'__content__')), preserve_attributes)
|
10
42
|
end
|
data/test/test_helper.rb
CHANGED
@@ -3,9 +3,6 @@ require 'simplecov'
|
|
3
3
|
SimpleCov.start do
|
4
4
|
add_filter '/test/'
|
5
5
|
add_filter '/vendor/'
|
6
|
-
|
7
|
-
# add_group 'Libraries', 'lib/refx/engine/p3indesignfranchise/p3indesignfranchise'
|
8
|
-
# add_group 'Rpc', 'lib/refx/engine/p3indesignfranchise'
|
9
6
|
end
|
10
7
|
|
11
8
|
require 'minitest'
|
@@ -15,5 +12,4 @@ require 'minitest/pride'
|
|
15
12
|
require 'base64'
|
16
13
|
|
17
14
|
tempdir = File.join(File.dirname(__FILE__), 'tmpout')
|
18
|
-
FileUtils.
|
19
|
-
Dir.mkdir tempdir
|
15
|
+
FileUtils.rm_rf(Dir.glob(tempdir+'/*'))
|