roundtrip_xml 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roundtrip_xml/dsl_runtime.rb +4 -0
- data/lib/roundtrip_xml/lifecycle_callbacks.rb +17 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b66ffe342320a79c7fb825dbebae93eaccddff7
|
4
|
+
data.tar.gz: 7146698f8df820a77acc96867db1eba4dc871977
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 434771c5f9aa088b1d7c903e07f072666dcd01c41ad0ac7ff13621dd66132e10c9593ec7ec5ba19b71645e63ba593699d58f83994009c692a94a2749907f28fc
|
7
|
+
data.tar.gz: e68e725d70a5b2d55d562172b85bca720005bb7194a104fc3827f9467a3b16211eee04a4b48a5018b4d305f7a948bdf1beb6478fb1acb926478783139933904d
|
@@ -6,12 +6,15 @@ require 'roundtrip_xml/base_cleanroom'
|
|
6
6
|
require 'roundtrip_xml/utils'
|
7
7
|
require 'roundtrip_xml/sexp_dsl_builder'
|
8
8
|
require 'roundtrip_xml/extractor'
|
9
|
+
require 'roundtrip_xml/lifecycle_callbacks'
|
9
10
|
require 'tree'
|
10
11
|
require 'set'
|
11
12
|
# Class which evaluates DSL and read XML files to populate the namespace with classes
|
12
13
|
class DslRuntime
|
13
14
|
include Utils
|
15
|
+
include LifecycleCallbacks
|
14
16
|
def initialize()
|
17
|
+
super
|
15
18
|
@classes = {}
|
16
19
|
@root_classes = Set.new
|
17
20
|
end
|
@@ -37,6 +40,7 @@ class DslRuntime
|
|
37
40
|
def write_dsl(xml, root_class_name, root_method, helpers = nil, &block)
|
38
41
|
roxml_root = fetch(root_class_name).from_xml xml
|
39
42
|
|
43
|
+
trigger :after_roxml_created, roxml_root
|
40
44
|
extractor = Extractor.new roxml_root.send(root_method), self, root_class_name, helpers
|
41
45
|
|
42
46
|
new_objs = extractor.convert_roxml_objs
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module LifecycleCallbacks
|
2
|
+
|
3
|
+
def initialize
|
4
|
+
@callbacks = {}
|
5
|
+
end
|
6
|
+
def on (event, &callback)
|
7
|
+
callbacks[event] ||= []
|
8
|
+
callbacks[event] << callback
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
attr_accessor :callbacks
|
13
|
+
def trigger(event, *args)
|
14
|
+
@callbacks ||= {}
|
15
|
+
callbacks[event] && callbacks[event].each {|cb| cb.call *args}
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roundtrip_xml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Usick
|
@@ -163,6 +163,7 @@ files:
|
|
163
163
|
- lib/roundtrip_xml/dsl_runtime.rb
|
164
164
|
- lib/roundtrip_xml/extractor.rb
|
165
165
|
- lib/roundtrip_xml/extractor2.rb
|
166
|
+
- lib/roundtrip_xml/lifecycle_callbacks.rb
|
166
167
|
- lib/roundtrip_xml/plain_accessors.rb
|
167
168
|
- lib/roundtrip_xml/root_cleanroom.rb
|
168
169
|
- lib/roundtrip_xml/roxml_builder.rb
|