pauldix-sax-machine 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
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.9"
10
+ VERSION = "0.0.10"
11
11
  end
@@ -21,10 +21,11 @@ module SAXMachine
21
21
  end
22
22
 
23
23
  def element_config_for_attribute(name, attrs)
24
- @top_level_elements.detect do |element_config|
24
+ element_configs = @top_level_elements.select do |element_config|
25
25
  element_config.name == name &&
26
26
  element_config.has_value_and_attrs_match?(attrs)
27
27
  end
28
+ element_configs.empty? ? nil : element_configs
28
29
  end
29
30
 
30
31
  def element_config_for_tag(name, attrs)
@@ -67,14 +67,16 @@ module SAXMachine
67
67
  def parse_element_attribute
68
68
  unless parsed_config?
69
69
  mark_as_parsed
70
- @object.send(@element_config.setter, @element_config.value_from_attrs(@attrs))
70
+ @element_config.each do |config|
71
+ @object.send(config.setter, config.value_from_attrs(@attrs))
72
+ end
71
73
  end
72
74
 
73
75
  @element_config = nil
74
76
  end
75
77
 
76
78
  def mark_as_parsed
77
- @parsed_configs[@element_config] = true unless @element_config.collection?
79
+ @parsed_configs[@element_config] = true unless (@element_config.respond_to?(:collection?) && @element_config.collection?)
78
80
  end
79
81
 
80
82
  def parsed_config?
@@ -209,6 +209,17 @@ describe "SAXMachine" do
209
209
  document = @klass.parse("<link foo='test'/>")
210
210
  document.link.should == 'test'
211
211
  end
212
+
213
+ it "should save two different attribute values on a single tag" do
214
+ @klass = Class.new do
215
+ include SAXMachine
216
+ element :link, :value => :foo, :as => :first
217
+ element :link, :value => :bar, :as => :second
218
+ end
219
+ document = @klass.parse("<link foo='foo value' bar='bar value'></link>")
220
+ document.first.should == "foo value"
221
+ document.second.should == "bar value"
222
+ end
212
223
  end
213
224
  end
214
225
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pauldix-sax-machine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix