lwes 0.1.0 → 0.1.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.
- data/ChangeLog +3 -0
- data/lib/lwes/struct.rb +13 -1
- data/lib/lwes/type_db.rb +2 -1
- data/lwes.gemspec +1 -1
- data/test/unit/test_type_db.rb +12 -0
- metadata +2 -2
data/ChangeLog
CHANGED
data/lib/lwes/struct.rb
CHANGED
@@ -78,7 +78,19 @@ module LWES
|
|
78
78
|
end
|
79
79
|
|
80
80
|
tmp = ::Struct.new(*(event_def.map { |(field,_)| field }))
|
81
|
-
|
81
|
+
components = klass.to_s.split(/::/)
|
82
|
+
components.each_with_index do |component, i|
|
83
|
+
if i == (components.size - 1)
|
84
|
+
tmp = parent.const_set(component, tmp)
|
85
|
+
else
|
86
|
+
parent = begin
|
87
|
+
parent.const_get(component)
|
88
|
+
rescue NameError
|
89
|
+
eval "module #{parent.name}::#{component}; end"
|
90
|
+
parent.const_get(component)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
82
94
|
tmp.const_set :TYPE_DB, db
|
83
95
|
tmp.const_set :NAME, name.to_s
|
84
96
|
ed = tmp.const_set :EVENT_DEF, {}
|
data/lib/lwes/type_db.rb
CHANGED
@@ -15,7 +15,8 @@ module LWES
|
|
15
15
|
# file, then the classes MyEvents::Event1 and MyEvents::Event2 should
|
16
16
|
# now be accessible.
|
17
17
|
def create_classes!(options = {})
|
18
|
-
|
18
|
+
classes = to_hash.keys - [ :MetaEventInfo ]
|
19
|
+
classes.sort { |a,b| a.to_s.size <=> b.to_s.size }.map do |klass|
|
19
20
|
LWES::Struct.new({ :db => self, :class => klass }.merge(options))
|
20
21
|
end
|
21
22
|
end
|
data/lwes.gemspec
CHANGED
data/test/unit/test_type_db.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
require "#{File.dirname(__FILE__)}/../test_helper"
|
2
2
|
require 'tempfile'
|
3
3
|
|
4
|
+
module Abcde
|
5
|
+
end
|
6
|
+
|
4
7
|
class TestTypeDB < Test::Unit::TestCase
|
5
8
|
|
6
9
|
def test_constants
|
@@ -58,4 +61,13 @@ class TestTypeDB < Test::Unit::TestCase
|
|
58
61
|
classes.each { |k| assert_kind_of Class, k }
|
59
62
|
end
|
60
63
|
|
64
|
+
def test_namespaced_esf
|
65
|
+
tdb = LWES::TypeDB.new("#{File.dirname(__FILE__)}/namespaced.esf")
|
66
|
+
classes = tdb.create_classes!(:parent => Abcde)
|
67
|
+
expect = %w(Abcde::A::B::C::Event
|
68
|
+
Abcde::A::B::C::Event::Bool
|
69
|
+
Abcde::A::B::C::Event::String)
|
70
|
+
assert_equal expect, classes.map { |i| i.to_s }
|
71
|
+
end
|
72
|
+
|
61
73
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lwes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik S. Chang
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-25 00:00:00 +00:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|