roundtrip_xml 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7188fb3dd0404b06179bbd1d3758f8523e64a71f
4
- data.tar.gz: d287901a013caa64979736325f7d7df8168eacbc
3
+ metadata.gz: 3b66ffe342320a79c7fb825dbebae93eaccddff7
4
+ data.tar.gz: 7146698f8df820a77acc96867db1eba4dc871977
5
5
  SHA512:
6
- metadata.gz: 6e7dc8174921c05e9ed0dce8f7467f6fdfe4ffaa6725b7f654ecb89c0333bd08c4976c5b10cb1645471e854906347ee34a3bc6be1bfad518e448d6ad96d91536
7
- data.tar.gz: 99b3730a72313e3c504eb843450514ac3fa4bde81f53a57012364f5516c4482c3f34a08e86727f923d203d76080aee4d88bc3d69651095717c2ea5f5dbc64c99
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.1
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