roundtrip_xml 0.2.0 → 0.2.1
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/roundtrip_xml/dsl_runtime.rb +8 -5
- data/lib/roundtrip_xml/sexp_dsl_builder.rb +2 -1
- 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: c6f9312c0f358c5e57d680d9f19cfe25667046c1
|
4
|
+
data.tar.gz: d03c4d48699d51ed0a02962f948610dd0c4e7350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd0841dd612f8ce6c81a289e5f767f78516e94f928d476bbb7480694226a1c19c7a40c0e3f01f54a7d030db594e06d076525e6994d5dfa39a7c0fecbed147450
|
7
|
+
data.tar.gz: 695dd79cc60a4d92e5810c148c4ebb790a6daaa9e94de7ff19f757f0f96d1ec0a3a3c3f375c3edd00b87eb3482337515ee06e6d63e56d3e2a35354dbdf65d864
|
@@ -48,14 +48,15 @@ class DslRuntime
|
|
48
48
|
partitions[partition] << obj
|
49
49
|
end
|
50
50
|
partitions
|
51
|
-
partitions.inject({}) do |out, (partition, objs)|
|
51
|
+
dsl = partitions.inject({}) do |out, (partition, objs)|
|
52
52
|
out[partition] = write_dsl_helper roxml_root, root_method, objs
|
53
53
|
out
|
54
54
|
end
|
55
55
|
else
|
56
|
-
write_dsl_helper roxml_root, root_method, new_objs
|
56
|
+
dsl = write_dsl_helper roxml_root, root_method, new_objs
|
57
57
|
end
|
58
58
|
|
59
|
+
dsl
|
59
60
|
end
|
60
61
|
|
61
62
|
def write_dsl_helper(root, root_method, objs)
|
@@ -73,14 +74,16 @@ class DslRuntime
|
|
73
74
|
@classes[name] = clazz
|
74
75
|
end
|
75
76
|
|
76
|
-
def evaluate_file(path, root_class)
|
77
|
+
def evaluate_file(path, root_class, templates = [])
|
77
78
|
cleanroom = RootCleanroom.new(fetch(root_class).new, self)
|
79
|
+
templates.each { |t| cleanroom.evaluate_file t }
|
78
80
|
cleanroom.evaluate_file path
|
79
81
|
|
80
82
|
end
|
81
83
|
|
82
|
-
def evaluate_raw(dsl, root_class, &block)
|
84
|
+
def evaluate_raw(dsl, root_class, templates = [], &block)
|
83
85
|
cleanroom = RootCleanroom.new(fetch(root_class).new, self)
|
86
|
+
templates.each { |t| cleanroom.evaluate_file t }
|
84
87
|
if block_given?
|
85
88
|
cleanroom.evaluate &block
|
86
89
|
else
|
@@ -124,7 +127,7 @@ class DslRuntime
|
|
124
127
|
def deserialize_class(node, config)
|
125
128
|
clazz = fetch(node.name) || new_roxml_class(config[:xml_name])
|
126
129
|
config[:attrs].each do |attr|
|
127
|
-
type_is_parent = node.parentage && node.parentage.any? {|n| n.name == attr[:opts][:as]}
|
130
|
+
type_is_parent = node.parentage && (node.parentage << node).any? {|n| n.name == attr[:opts][:as]}
|
128
131
|
if type_is_parent
|
129
132
|
add_unprocessed_attr attr, clazz
|
130
133
|
else
|
@@ -78,7 +78,8 @@ EOF
|
|
78
78
|
|
79
79
|
sexp = Sexp.from_array s
|
80
80
|
processor = Ruby2Ruby.new
|
81
|
-
processor.process(sexp)
|
81
|
+
str = processor.process(sexp)
|
82
|
+
str.gsub(/\((.*)\)/, ' \\1').gsub(/"([^'\n]+)"/, "'\\1'")
|
82
83
|
end
|
83
84
|
|
84
85
|
def write_full_dsl(root_method)
|