julien51-sax-machine 0.0.15 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,38 @@
1
+ module SAXMachine
2
+ class NSStack < Hash
3
+ def initialize(parent=nil, attrs=[])
4
+ # Initialize
5
+ super()
6
+ @parent = parent
7
+
8
+ # Parse attributes
9
+ attrs.each do |attr|
10
+ if attr.kind_of?(Array)
11
+ k, v = attr
12
+ case k
13
+ when 'xmlns' then self[''] = v
14
+ when /^xmlns:(.+)/ then self[$1] = v
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ # Lookup
21
+ def [](name)
22
+ if (ns = super(name.to_s))
23
+ # I've got it
24
+ ns
25
+ elsif @parent
26
+ # Parent may have it
27
+ @parent[name]
28
+ else
29
+ # Undefined, empty namespace
30
+ ''
31
+ end
32
+ end
33
+
34
+ def pop
35
+ @parent
36
+ end
37
+ end
38
+ end
data/lib/sax-machine.rb CHANGED
@@ -7,5 +7,5 @@ require "sax-machine/sax_handler"
7
7
  require "sax-machine/sax_config"
8
8
 
9
9
  module SAXMachine
10
- VERSION = "0.0.14"
10
+ VERSION = "0.0.16"
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: julien51-sax-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix
@@ -37,6 +37,7 @@ files:
37
37
  - lib/sax-machine/sax_element_config.rb
38
38
  - lib/sax-machine/sax_document.rb
39
39
  - lib/sax-machine/sax_handler.rb
40
+ - lib/sax-machine/ns_stack.rb
40
41
  - README.textile
41
42
  - Rakefile
42
43
  - spec/spec.opts