sax_stream 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/sax_stream/mapper.rb +22 -6
  2. metadata +4 -4
@@ -88,7 +88,15 @@ module SaxStream
88
88
  end
89
89
 
90
90
  def relation_mappings
91
- @relation_mappings ||= []
91
+ (class_relation_mappings + parent_class_values(:relation_mappings, [])).freeze
92
+ end
93
+
94
+ def mappings
95
+ parent_class_values(:mappings, {}).merge(class_mappings).freeze
96
+ end
97
+
98
+ def regex_mappings
99
+ (class_regex_mappings + parent_class_values(:regex_mappings, [])).freeze
92
100
  end
93
101
 
94
102
  def should_collect?
@@ -98,15 +106,15 @@ module SaxStream
98
106
  private
99
107
 
100
108
  def store_relation_mapping(key, mapping)
101
- relation_mappings << mapping
109
+ class_relation_mappings << mapping
102
110
  store_field_mapping(key, mapping)
103
111
  end
104
112
 
105
113
  def store_field_mapping(key, mapping)
106
114
  if key.include?('*')
107
- regex_mappings << [Regexp.new(key.gsub('*', '[^/]+')), mapping]
115
+ class_regex_mappings << [Regexp.new(key.gsub('*', '[^/]+')), mapping]
108
116
  else
109
- mappings[key] = mapping
117
+ class_mappings[key] = mapping
110
118
  end
111
119
  end
112
120
 
@@ -121,13 +129,21 @@ module SaxStream
121
129
  nil
122
130
  end
123
131
 
124
- def regex_mappings
132
+ def class_relation_mappings
133
+ @relation_mappings ||= []
134
+ end
135
+
136
+ def class_regex_mappings
125
137
  @regex_mappings ||= []
126
138
  end
127
139
 
128
- def mappings
140
+ def class_mappings
129
141
  @mappings ||= {}
130
142
  end
143
+
144
+ def parent_class_values(method_name, default)
145
+ superclass && superclass.respond_to?(method_name) ? superclass.send(method_name) : default
146
+ end
131
147
  end
132
148
 
133
149
  def []=(key, value)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sax_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-10 00:00:00.000000000 Z
12
+ date: 2012-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
16
- requirement: &70239061335640 !ruby/object:Gem::Requirement
16
+ requirement: &70349513367200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 1.5.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70239061335640
24
+ version_requirements: *70349513367200
25
25
  description: A streaming XML parser which builds objects and passes them to a collecter
26
26
  as they are ready. Based upon Nokogiri SAX parsing functionality.
27
27
  email: