File tree Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Expand file tree Collapse file tree 2 files changed +18
-8
lines changed Original file line number Diff line number Diff line change 25
25
# @return [String]
26
26
# The String representation of the object
27
27
def to_python ( object )
28
- case object
28
+ serialized = Puppet ::Pops ::Serialization ::ToDataConverter . convert ( object , rich_data : true )
29
+ serialized_to_python ( serialized )
30
+ end
31
+
32
+ def serialized_to_python ( serialized )
33
+ case serialized
29
34
when true then 'True'
30
35
when false then 'False'
31
36
when nil then 'None'
32
- when Array then "[#{ object . map { |x | to_python ( x ) } . join ( ', ' ) } ]"
33
- when Hash then "{#{ object . map { |k , v | "#{ to_python ( k ) } : #{ to_python ( v ) } " } . join ( ', ' ) } }"
34
- else object . inspect
37
+ when Array then "[#{ serialized . map { |x | serialized_to_python ( x ) } . join ( ', ' ) } ]"
38
+ when Hash then "{#{ serialized . map { |k , v | "#{ serialized_to_python ( k ) } : #{ serialized_to_python ( v ) } " } . join ( ', ' ) } }"
39
+ else serialized . inspect
35
40
end
36
41
end
37
42
end
Original file line number Diff line number Diff line change 25
25
# @return [String]
26
26
# The String representation of the object
27
27
def to_ruby ( object )
28
- case object
29
- when Array then "[#{ object . map { |x | to_ruby ( x ) } . join ( ', ' ) } ]"
30
- when Hash then "{#{ object . map { |k , v | "#{ to_ruby ( k ) } => #{ to_ruby ( v ) } " } . join ( ', ' ) } }"
31
- else object . inspect
28
+ serialized = Puppet ::Pops ::Serialization ::ToDataConverter . convert ( object , rich_data : true )
29
+ serialized_to_ruby ( serialized )
30
+ end
31
+
32
+ def serialized_to_ruby ( serialized )
33
+ case serialized
34
+ when Array then "[#{ serialized . map { |x | serialized_to_ruby ( x ) } . join ( ', ' ) } ]"
35
+ when Hash then "{#{ serialized . map { |k , v | "#{ serialized_to_ruby ( k ) } => #{ serialized_to_ruby ( v ) } " } . join ( ', ' ) } }"
36
+ else serialized . inspect
32
37
end
33
38
end
34
39
end
You can’t perform that action at this time.
0 commit comments