ipxact-ruby 0.13.1 → 0.13.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.1
1
+ 0.13.2
@@ -114,7 +114,8 @@ module IPXACT::Parser::ComponentData
114
114
  def self.select_component(component_id, component_docs)
115
115
  if component_id.kind_of?(Array) && component_id.size == 2
116
116
  # A version must have been specified
117
- raise ArgumentError, 'Component could not be found!' unless component_docs.has_key? component_id
117
+ raise ArgumentError, "Component '#{component_id}' could not be found!" \
118
+ unless component_docs.has_key? component_id
118
119
  component_name, component_version = component_id
119
120
  else
120
121
  component_name = component_id
@@ -167,11 +168,21 @@ module IPXACT::Parser::ComponentData
167
168
  component_reference = entry[1][:reference]
168
169
  local_variables = entry[1][:variables]
169
170
 
170
- constraint = constraints.select{|constraint| constraint[0] == component_reference.name}.first
171
- if constraint.nil?
172
- acc[local_instance_name] = parse_component([component_reference.name, component_reference.version], local_instance_name, local_variables, component_docs, design_docs, constraints)
171
+ if constraint = constraints.find{|constraint| constraint[0] == component_reference.name}
172
+ acc[local_instance_name] = parse_component(constraint,
173
+ local_instance_name,
174
+ local_variables,
175
+ component_docs,
176
+ design_docs, constraints)
173
177
  else
174
- acc[local_instance_name] = parse_component(constraint, local_instance_name, local_variables, component_docs, design_docs, constraints)
178
+ acc[local_instance_name] = parse_component([
179
+ component_reference.name,
180
+ component_reference.version
181
+ ],
182
+ local_instance_name,
183
+ local_variables,
184
+ component_docs,
185
+ design_docs, constraints)
175
186
  end
176
187
  acc
177
188
  end
@@ -205,17 +216,21 @@ module IPXACT::Parser::ComponentData
205
216
  # :port_name - The subcomponent's port name.
206
217
  # :port_type - The subcomponent's port type.
207
218
  # :component_instance - The subcomponent instance.
219
+ # @raise an exception if any port connection cannot be found.
208
220
  #
209
221
  def self.parse_interconnections(design_doc, component_instances)
210
222
  design_doc.xpath("//spirit:interconnection").inject({}) do |acc, inter|
211
223
  unordered_connection = inter.xpath("./spirit:activeInterface").collect do |active_interface|
212
224
  component_instance = component_instances[active_interface['componentRef']]
213
- port = component_instance.ports.select{|port| port[:name] == active_interface['busRef']}.first
214
- {
215
- :port_name => port[:name],
216
- :port_type => port[:type],
217
- :component_instance => active_interface['componentRef']
218
- }
225
+ if port = component_instance.ports.find{|port| port[:name] == active_interface['busRef']}
226
+ {
227
+ :port_name => port[:name],
228
+ :port_type => port[:type],
229
+ :component_instance => active_interface['componentRef']
230
+ }
231
+ else
232
+ raise "Could not find port named \"#{active_interface['busRef']}\" for component \"#{component_instance.instance_name}\""
233
+ end
219
234
  end
220
235
 
221
236
  ordered_connection = reorder_connection(unordered_connection)
@@ -243,17 +258,21 @@ module IPXACT::Parser::ComponentData
243
258
  # :port_name - The corresponding subcomponent's port name.
244
259
  # :port_type - The corresponding subcomponent's port type.
245
260
  # :component_instance - The subcomponent's instance.
261
+ # @raise an exception if any port connection could not be found.
246
262
  #
247
263
  def self.parse_hierconnections(design_doc, component_instances)
248
264
  design_doc.xpath("//spirit:hierConnection").inject({}) do |acc, hier|
249
265
  interface = hier.xpath("./spirit:interface").first
250
- port = component_instances[interface['componentRef']].ports.select{|port| port[:name] == interface['busRef']}.first
251
- acc[hier['interfaceRef']] = {
252
- :port_name => interface['busRef'],
253
- :port_type => port[:type],
254
- :component_instance => interface['componentRef']
255
- }
256
- acc
266
+ if port = component_instances[interface['componentRef']].ports.find{|port| port[:name] == interface['busRef']}
267
+ acc[hier['interfaceRef']] = {
268
+ :port_name => interface['busRef'],
269
+ :port_type => port[:type],
270
+ :component_instance => interface['componentRef']
271
+ }
272
+ acc
273
+ else
274
+ raise "Could not find port with name \"#{interface['busRef']}\" in component list."
275
+ end
257
276
  end
258
277
  end
259
278
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 13
8
- - 1
9
- version: 0.13.1
8
+ - 2
9
+ version: 0.13.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Guillaume Godet-Bar
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-20 00:00:00 +01:00
17
+ date: 2011-02-15 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency