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 CHANGED
@@ -1,2 +1,5 @@
1
+ Version 0.1.1 (erik-s-chang)
2
+ * add support for namespaced ESFs
3
+
1
4
  Version 0.1.0 (erik-s-chang)
2
5
  * remove SWIG ugliness, friendly new Rubyish API
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
- tmp = parent.const_set(klass, tmp)
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
- (to_hash.keys - [ :MetaEventInfo ]).map do |klass|
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
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = %q{lwes}
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
  s.date = Time.now
5
5
  s.authors = ["Erik S. Chang", "Frank Maritato"]
6
6
  s.email = %q{lwes-devel@lists.sourceforge.net}
@@ -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.0
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-24 00:00:00 +00:00
13
+ date: 2009-11-25 00:00:00 +00:00
14
14
  default_executable:
15
15
  dependencies: []
16
16