ipxact-ruby 0.12.1 → 0.13.0
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/VERSION +1 -1
- data/lib/ipxact.rb +4 -73
- data/lib/ipxact/component.rb +21 -19
- data/lib/ipxact/identifier.rb +92 -0
- data/lib/ipxact/parser.rb +1 -0
- data/lib/ipxact/parser/bus_data_parser.rb +2 -3
- data/lib/ipxact/parser/component_data_parser.rb +10 -10
- data/lib/ipxact/parser/identifier_parser.rb +58 -0
- data/lib/ipxact/platform.rb +5 -4
- data/spec/integration/general_spec.rb +5 -5
- data/spec/unit/component_spec.rb +9 -6
- data/spec/unit/identifier_spec.rb +66 -0
- data/spec/unit/ipxact_spec.rb +0 -48
- data/spec/unit/platform_spec.rb +2 -2
- metadata +8 -4
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.13.0
|
data/lib/ipxact.rb
CHANGED
@@ -77,7 +77,8 @@ module IPXACT
|
|
77
77
|
design_schema.validate(design_doc).size == 0
|
78
78
|
end
|
79
79
|
|
80
|
-
# Returns the component's identifier (i.e., name, library, vendor,
|
80
|
+
# Returns the component's identifier (i.e., name, library, vendor,
|
81
|
+
# version) from a design or component file.
|
81
82
|
#
|
82
83
|
# @param [String] path The path to the component's XML file
|
83
84
|
#
|
@@ -89,12 +90,7 @@ module IPXACT
|
|
89
90
|
ipxact_doc = Nokogiri::XML(ipxact_file)
|
90
91
|
ipxact_file.close
|
91
92
|
|
92
|
-
|
93
|
-
:name => ipxact_doc.xpath("./*/spirit:name").first.text,
|
94
|
-
:vendor => ipxact_doc.xpath("./*/spirit:vendor").first.text,
|
95
|
-
:library => ipxact_doc.xpath("./*/spirit:library").first.text,
|
96
|
-
:version => ipxact_doc.xpath("./*/spirit:version").first.text
|
97
|
-
}
|
93
|
+
IPXACT::Parser::IdentifierData.parse_identifier(ipxact_doc.xpath('./*'))
|
98
94
|
else
|
99
95
|
nil
|
100
96
|
end
|
@@ -189,76 +185,11 @@ module IPXACT
|
|
189
185
|
design_docs
|
190
186
|
|
191
187
|
end
|
192
|
-
|
193
|
-
# Decides whether version_a is strictly more recent than version_b. Accepts
|
194
|
-
# any relaxed version of semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
195
|
-
#
|
196
|
-
# @param [String] version_a a version number
|
197
|
-
# @param [String] version_b a version number
|
198
|
-
#
|
199
|
-
# @return [Boolean] a Boolean that states if +version_a > version_b+
|
200
|
-
#
|
201
|
-
def self.is_most_recent_version?(version_a, version_b)
|
202
|
-
split_a = version_a.split('.')
|
203
|
-
split_b = version_b.split('.')
|
204
|
-
|
205
|
-
split_a.each_with_index do |el,i|
|
206
|
-
return true if split_b.size <= i && el.to_i != 0
|
207
|
-
return true if el.to_i > split_b[i].to_i
|
208
|
-
end
|
209
|
-
|
210
|
-
false
|
211
|
-
end
|
212
|
-
|
213
|
-
# Decides whether version_a and version_b are the same version. Accepts any
|
214
|
-
# relaxed version of the semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
215
|
-
# When comparing versions with different lengths, the method will 'pad' the
|
216
|
-
# shortest version string with 0s.
|
217
|
-
#
|
218
|
-
# @example
|
219
|
-
# IPXACT::is_same_version('1.0', '1.1')
|
220
|
-
# # => false
|
221
|
-
#
|
222
|
-
# IPXACT::is_same_version('1.0', '1.0')
|
223
|
-
# # => true
|
224
|
-
#
|
225
|
-
# IPXACT::is_same_version('1.0.0', '1.0')
|
226
|
-
# # => true
|
227
|
-
#
|
228
|
-
# IPXACT::is_same_version('1.0.1', '1.0')
|
229
|
-
# # => false
|
230
|
-
#
|
231
|
-
# @return [Boolean] a Boolean that states if +version_a == version_b+
|
232
|
-
# (relaxed equivalence)
|
233
|
-
#
|
234
|
-
def self.is_same_version?(version_a, version_b)
|
235
|
-
return !(self.is_most_recent_version?(version_a, version_b) || self.is_most_recent_version?(version_b, version_a))
|
236
|
-
end
|
237
|
-
|
238
|
-
# Parses an IPXACT reference element (i.e., any +spirit:hierarchyRef+ or
|
239
|
-
# +spirit:componentRef+).
|
240
|
-
#
|
241
|
-
# @param [Nokogiri::Node] reference The IPXACT reference, as an XML
|
242
|
-
# (Nokogiri) fragment
|
243
|
-
#
|
244
|
-
# @return [Hash] a Hash with the following keys:
|
245
|
-
# +:library+ the referenced element's library;
|
246
|
-
# +:name+ the referenced element's name;
|
247
|
-
# +:vendor+ the referenced element's vendor;
|
248
|
-
# +:version+ the referenced element's version.
|
249
|
-
#
|
250
|
-
def self.parse_reference(reference)
|
251
|
-
{
|
252
|
-
:library => reference['library'],
|
253
|
-
:name => reference['name'],
|
254
|
-
:vendor => reference['vendor'],
|
255
|
-
:version => reference['version']
|
256
|
-
}
|
257
|
-
end
|
258
188
|
end
|
259
189
|
|
260
190
|
require File.join File.dirname(__FILE__), 'ipxact/parser'
|
261
191
|
require File.join File.dirname(__FILE__), 'ipxact/platform'
|
262
192
|
require File.join File.dirname(__FILE__), 'ipxact/register'
|
193
|
+
require File.join File.dirname(__FILE__), 'ipxact/identifier'
|
263
194
|
require File.join File.dirname(__FILE__), 'ipxact/pathfinder/graph_pathfinder'
|
264
195
|
|
data/lib/ipxact/component.rb
CHANGED
@@ -14,18 +14,18 @@
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
#
|
16
16
|
|
17
|
-
# {IPXACT::Component} is what an {IPXACT::Platform} is essentially made
|
18
|
-
# This class
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
17
|
+
# {IPXACT::Component} is what an {IPXACT::Platform} is essentially made
|
18
|
+
# of. This class defines 6 attributes: (#instance_name}, {#cpus},
|
19
|
+
# {#subcomponents}, {#interconnections}, {#hierconnections} and
|
20
|
+
# {#ports}. While interconnections, hierconnections and ports are mostly
|
21
|
+
# used by the {IPXACT::GraphPathFinder} class, the subcomponents are
|
22
|
+
# what most users will be querying. Subcomponents may be terminal or
|
23
|
+
# non-terminal, i.e. composed of other subcomponents. Finally, {#cpus}
|
24
|
+
# simply corresponds to the list of cpus the component is doted with.
|
25
25
|
#
|
26
26
|
# @author Guillaume Godet-Bar
|
27
27
|
#
|
28
|
-
class IPXACT::Component
|
28
|
+
class IPXACT::Component
|
29
29
|
|
30
30
|
# @return [Array<Component>] the list of subcomponents
|
31
31
|
attr_accessor :subcomponents
|
@@ -41,25 +41,27 @@ class IPXACT::Component < Hash
|
|
41
41
|
|
42
42
|
# @return [Array<Hash>] the list of cpus
|
43
43
|
attr_accessor :cpus
|
44
|
+
|
45
|
+
# @return [IPXACT::Identifier] the component's IPXACT identifier
|
46
|
+
attr_reader :ipxact_id
|
47
|
+
|
48
|
+
# @return [String] The component's instance name
|
49
|
+
attr_reader :instance_name
|
44
50
|
|
45
51
|
# Creates a new {IPXACT::Component} instance
|
46
52
|
#
|
47
53
|
# @param [String] instance_name The name that will be used for identifying
|
48
54
|
# this specific component instance component.
|
49
|
-
# @param
|
50
|
-
#
|
51
|
-
# @param [String] version The version of the component, following the typical
|
52
|
-
# relaxed semantic versioning convention +X(.Y(.Z)?)?+
|
55
|
+
# @param id_args The component's identifier. Can be either a
|
56
|
+
# {Hash} or an {IPXACT::Identifier}
|
53
57
|
#
|
54
|
-
def initialize(instance_name,
|
58
|
+
def initialize(instance_name, id_args)
|
55
59
|
@subcomponents = {}
|
56
60
|
@interconnections = {}
|
57
61
|
@hierconnections = {}
|
58
62
|
@ports = []
|
59
|
-
|
60
|
-
|
61
|
-
:vendor => vendor,
|
62
|
-
:name => name})
|
63
|
+
@ipxact_id = id_args.is_a?(Hash) ? IPXACT::Identifier.new(id_args) : id_args
|
64
|
+
@instance_name = instance_name
|
63
65
|
end
|
64
66
|
|
65
67
|
# Returns true if the component has one or more cpus
|
@@ -227,7 +229,7 @@ class IPXACT::Component < Hash
|
|
227
229
|
#
|
228
230
|
def rec_prepare_pathfinder_connections(current_nodes, current_interconnections)
|
229
231
|
if subcomponents.empty?
|
230
|
-
[current_nodes << self
|
232
|
+
[current_nodes << self.instance_name, current_interconnections]
|
231
233
|
else
|
232
234
|
subcomponents.each do |sub_name, subcomponent|
|
233
235
|
formatted_interconnections = interconnections.values.collect do |interconnect|
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
class IPXACT::Identifier
|
18
|
+
ATTRIBUTES = [
|
19
|
+
:name, :library, :vendor, :version
|
20
|
+
].freeze
|
21
|
+
|
22
|
+
ATTRIBUTES.each do |attr|
|
23
|
+
attr_accessor attr
|
24
|
+
end
|
25
|
+
|
26
|
+
def initialize(args)
|
27
|
+
ATTRIBUTES.each do |attr|
|
28
|
+
instance_variable_set("@#{attr}", args[attr] || "")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Decides whether version_a is strictly more recent than version_b. Accepts
|
33
|
+
# any relaxed version of semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
34
|
+
#
|
35
|
+
# @param [String] version_a a version number
|
36
|
+
# @param [String] version_b a version number
|
37
|
+
#
|
38
|
+
# @return [Boolean] a Boolean that states if +version_a > version_b+
|
39
|
+
#
|
40
|
+
def self.is_most_recent_version?(version_a, version_b)
|
41
|
+
split_a = version_a.split('.')
|
42
|
+
split_b = version_b.split('.')
|
43
|
+
|
44
|
+
split_a.each_with_index do |el,i|
|
45
|
+
return true if split_b.size <= i && el.to_i != 0
|
46
|
+
return true if el.to_i > split_b[i].to_i
|
47
|
+
end
|
48
|
+
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
# Decides whether version_a and version_b are the same version. Accepts any
|
53
|
+
# relaxed version of the semantic versioning markup (i.e., +X(\.Y(\.Z)?)?+).
|
54
|
+
# When comparing versions with different lengths, the method will 'pad' the
|
55
|
+
# shortest version string with 0s.
|
56
|
+
#
|
57
|
+
# @example
|
58
|
+
# IPXACT::is_same_version('1.0', '1.1')
|
59
|
+
# # => false
|
60
|
+
#
|
61
|
+
# IPXACT::is_same_version('1.0', '1.0')
|
62
|
+
# # => true
|
63
|
+
#
|
64
|
+
# IPXACT::is_same_version('1.0.0', '1.0')
|
65
|
+
# # => true
|
66
|
+
#
|
67
|
+
# IPXACT::is_same_version('1.0.1', '1.0')
|
68
|
+
# # => false
|
69
|
+
#
|
70
|
+
# @return [Boolean] a Boolean that states if +version_a == version_b+
|
71
|
+
# (relaxed equivalence)
|
72
|
+
#
|
73
|
+
def self.is_same_version?(version_a, version_b)
|
74
|
+
return !(self.is_most_recent_version?(version_a, version_b) || self.is_most_recent_version?(version_b, version_a))
|
75
|
+
end
|
76
|
+
|
77
|
+
# Overrides the default equality. Two {Identifier} are defined as
|
78
|
+
# equal when they share the same 1) name; 2) library; 3) vendor and 4)
|
79
|
+
# version (based on the result of the +is_same_version?+ method).
|
80
|
+
#
|
81
|
+
# @param [Identifier] other The other {Identifier} on which to test
|
82
|
+
# the equality.
|
83
|
+
#
|
84
|
+
# @return [Boolean]
|
85
|
+
#
|
86
|
+
def ==(other)
|
87
|
+
name == other.name &&
|
88
|
+
library == other.library &&
|
89
|
+
vendor == other.vendor &&
|
90
|
+
IPXACT::Identifier.is_same_version?(version, other.version)
|
91
|
+
end
|
92
|
+
end
|
data/lib/ipxact/parser.rb
CHANGED
@@ -24,4 +24,5 @@ end
|
|
24
24
|
require File.join File.dirname(__FILE__), 'parser/bus_data_parser'
|
25
25
|
require File.join File.dirname(__FILE__), 'parser/component_data_parser'
|
26
26
|
require File.join File.dirname(__FILE__), 'parser/platform_data_parser'
|
27
|
+
require File.join File.dirname(__FILE__), 'parser/identifier_parser'
|
27
28
|
|
@@ -33,7 +33,7 @@ module IPXACT::Parser::BusData
|
|
33
33
|
# :name - The name of the port.
|
34
34
|
# :type - The port type (i.e., :master, :mirrored_master, :slave or
|
35
35
|
# :mirrored_slave)
|
36
|
-
# :
|
36
|
+
# :bus_id - The bus ipxact identifier
|
37
37
|
# :library - The library in which the bus interface is defined.
|
38
38
|
# :port_data - Specific port data, depending on the port type.
|
39
39
|
#
|
@@ -43,8 +43,7 @@ module IPXACT::Parser::BusData
|
|
43
43
|
{
|
44
44
|
:name => bus_doc.xpath("./spirit:name").first.text,
|
45
45
|
:type => port_type,
|
46
|
-
:
|
47
|
-
:library => bus_doc.xpath("./spirit:busType").first['library'],
|
46
|
+
:bus_id => IPXACT::Parser::IdentifierData.parse_reference(bus_doc.xpath("./spirit:busType").first),
|
48
47
|
:port_data => port_data
|
49
48
|
}
|
50
49
|
end
|
@@ -73,7 +73,7 @@ module IPXACT::Parser::ComponentData
|
|
73
73
|
component_name, component_version = select_component(component_id, component_docs)
|
74
74
|
|
75
75
|
root_component = component_docs[[component_name, component_version]]
|
76
|
-
|
76
|
+
component_id = IPXACT::Parser::IdentifierData.parse_identifier(root_component.xpath("./spirit:component"))
|
77
77
|
views = root_component.xpath("//spirit:model/spirit:views/spirit:view")
|
78
78
|
|
79
79
|
instances, interconnections, hierconnections = parse_design_views(views, component_docs, design_docs, constraints)
|
@@ -86,7 +86,7 @@ module IPXACT::Parser::ComponentData
|
|
86
86
|
{ :name => a_cpu.xpath("./spirit:name").first.text }
|
87
87
|
end
|
88
88
|
|
89
|
-
component = IPXACT::Component.new(instance_name,
|
89
|
+
component = IPXACT::Component.new(instance_name, component_id)
|
90
90
|
component.interconnections = interconnections
|
91
91
|
component.hierconnections = hierconnections
|
92
92
|
component.subcomponents = instances
|
@@ -121,8 +121,8 @@ module IPXACT::Parser::ComponentData
|
|
121
121
|
component_version = component_docs.keys.select{|name, version| name == component_name} \
|
122
122
|
.collect{|name, version| version} \
|
123
123
|
.sort{|a, b|
|
124
|
-
1 if IPXACT::is_most_recent_version?(a,b)
|
125
|
-
0 if IPXACT::is_same_version?(a,b)
|
124
|
+
1 if IPXACT::Identifier::is_most_recent_version?(a,b)
|
125
|
+
0 if IPXACT::Identifier::is_same_version?(a,b)
|
126
126
|
-1
|
127
127
|
}.last
|
128
128
|
end
|
@@ -157,9 +157,9 @@ module IPXACT::Parser::ComponentData
|
|
157
157
|
def self.parse_design_views(views, component_docs, design_docs, constraints)
|
158
158
|
design_view = views.select{|view| view.xpath("./spirit:name").text == 'spirit-design' && view.xpath("./spirit:envIdentifier").text == '::Hierarchy'}
|
159
159
|
if design_view.size == 1
|
160
|
-
design_ref = IPXACT::parse_reference(design_view.first.xpath("./spirit:hierarchyRef").first)
|
160
|
+
design_ref = IPXACT::Parser::IdentifierData.parse_reference(design_view.first.xpath("./spirit:hierarchyRef").first)
|
161
161
|
|
162
|
-
design_doc = design_docs[[design_ref
|
162
|
+
design_doc = design_docs[[design_ref.name, design_ref.version]]
|
163
163
|
|
164
164
|
instances_map = parse_component_instances(design_doc)
|
165
165
|
instances = instances_map.inject({}) do |acc, entry|
|
@@ -167,9 +167,9 @@ module IPXACT::Parser::ComponentData
|
|
167
167
|
component_reference = entry[1][:reference]
|
168
168
|
local_variables = entry[1][:variables]
|
169
169
|
|
170
|
-
constraint = constraints.select{|constraint| constraint[0] == component_reference
|
170
|
+
constraint = constraints.select{|constraint| constraint[0] == component_reference.name}.first
|
171
171
|
if constraint.nil?
|
172
|
-
acc[local_instance_name] = parse_component([component_reference
|
172
|
+
acc[local_instance_name] = parse_component([component_reference.name, component_reference.version], local_instance_name, local_variables, component_docs, design_docs, constraints)
|
173
173
|
else
|
174
174
|
acc[local_instance_name] = parse_component(constraint, local_instance_name, local_variables, component_docs, design_docs, constraints)
|
175
175
|
end
|
@@ -200,7 +200,7 @@ module IPXACT::Parser::ComponentData
|
|
200
200
|
# instances (i.e. parsed components) that correspond to
|
201
201
|
# the +design_doc+'s root component's subcomponents.
|
202
202
|
# @return [Hash] a Hash that associates the interconnection's name with an
|
203
|
-
# ordered Array (see {ComponentData
|
203
|
+
# ordered Array (see {ComponentData.reorder_connection}) of
|
204
204
|
# Hashes, composed as follows:
|
205
205
|
# :port_name - The subcomponent's port name.
|
206
206
|
# :port_type - The subcomponent's port type.
|
@@ -277,7 +277,7 @@ module IPXACT::Parser::ComponentData
|
|
277
277
|
end
|
278
278
|
acc[instance.xpath("./spirit:instanceName").text] =
|
279
279
|
{
|
280
|
-
:reference => IPXACT::parse_reference(instance.xpath("./spirit:componentRef").first),
|
280
|
+
:reference => IPXACT::Parser::IdentifierData::parse_reference(instance.xpath("./spirit:componentRef").first),
|
281
281
|
:variables => variables
|
282
282
|
}
|
283
283
|
acc
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
# Module for parsing IPXACT identifiers into a ruby {IPXACT::Identifier}
|
18
|
+
#
|
19
|
+
# @author Guillaume Godet-Bar
|
20
|
+
#
|
21
|
+
module IPXACT::Parser::IdentifierData
|
22
|
+
|
23
|
+
# Parses the XML node (assuming it has the required children) into an
|
24
|
+
# {IPXACT::Identifier}
|
25
|
+
#
|
26
|
+
# @param [Nokogiri::Node] ipxact_root The XML node that should be
|
27
|
+
# parsed.
|
28
|
+
#
|
29
|
+
# @return [IPXACT::Identifier] the parsed data
|
30
|
+
#
|
31
|
+
def self.parse_identifier(ipxact_root)
|
32
|
+
args = {
|
33
|
+
:name => ipxact_root.xpath('./spirit:name').first.text,
|
34
|
+
:vendor => ipxact_root.xpath('./spirit:vendor').first.text,
|
35
|
+
:library => ipxact_root.xpath('./spirit:library').first.text,
|
36
|
+
:version => ipxact_root.xpath('./spirit:version').first.text
|
37
|
+
}
|
38
|
+
IPXACT::Identifier.new(args)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Parses the XML node (assuming it has the required attributes) into an
|
42
|
+
# {IPXACT::Identifier}
|
43
|
+
#
|
44
|
+
# @param [Nokogiri::Node] ipxact_root The XML node that should be
|
45
|
+
# parsed.
|
46
|
+
#
|
47
|
+
# @return [IPXACT::Identifier] the parsed data
|
48
|
+
#
|
49
|
+
def self.parse_reference(ipxact_root)
|
50
|
+
args = {
|
51
|
+
:name => ipxact_root['name'],
|
52
|
+
:vendor => ipxact_root['vendor'],
|
53
|
+
:library => ipxact_root['library'],
|
54
|
+
:version => ipxact_root['version']
|
55
|
+
}
|
56
|
+
IPXACT::Identifier.new(args)
|
57
|
+
end
|
58
|
+
end
|
data/lib/ipxact/platform.rb
CHANGED
@@ -35,9 +35,10 @@ class IPXACT::Platform < IPXACT::Component
|
|
35
35
|
# into a Platform.
|
36
36
|
#
|
37
37
|
def initialize(root_component)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
@ipxact_id = root_component.ipxact_id
|
39
|
+
@subcomponents = root_component.subcomponents
|
40
|
+
@ports = root_component.ports
|
41
|
+
@interconnections = root_component.interconnections
|
42
|
+
@cpus = root_component.cpus
|
42
43
|
end
|
43
44
|
end
|
@@ -52,21 +52,21 @@ describe "IPXACT: the tools for building transformation data" do
|
|
52
52
|
|
53
53
|
context "extracting a component's identifier" do
|
54
54
|
it "should be able to extract a design's identifier" do
|
55
|
-
IPXACT::identifier(File.join(PLATFORM_PATH,DESIGN_PATH)).should == {
|
55
|
+
IPXACT::identifier(File.join(PLATFORM_PATH,DESIGN_PATH)).should == IPXACT::Identifier.new({
|
56
56
|
:name => 'design_Leon2Platform',
|
57
57
|
:vendor => 'spiritconsortium.org',
|
58
58
|
:library => 'Leon2TLM',
|
59
59
|
:version => '1.1'
|
60
|
-
}
|
60
|
+
})
|
61
61
|
end
|
62
62
|
|
63
63
|
it "should be able to extract a component's identifier" do
|
64
|
-
IPXACT::identifier(File.join(PLATFORM_PATH,'SystemTLM1/Leon2Platform/Leon2Platform.xml')).should == {
|
64
|
+
IPXACT::identifier(File.join(PLATFORM_PATH,'SystemTLM1/Leon2Platform/Leon2Platform.xml')).should == IPXACT::Identifier.new({
|
65
65
|
:name => 'Leon2Platform',
|
66
66
|
:vendor => 'spiritconsortium.org',
|
67
67
|
:library => 'Leon2TLM',
|
68
68
|
:version => '1.1'
|
69
|
-
}
|
69
|
+
})
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
@@ -106,7 +106,7 @@ describe "IPXACT: the tools for building transformation data" do
|
|
106
106
|
platform.components['i_ahb'].should have(0).interconnections
|
107
107
|
platform.components['i_sub'].should have(4).subcomponents
|
108
108
|
platform.components['i_sub'].should have(5).interconnections
|
109
|
-
platform.components['i_sub']
|
109
|
+
platform.components['i_sub'].ipxact_id.version.should == "1.1"
|
110
110
|
platform.should have(0).ports
|
111
111
|
end
|
112
112
|
|
data/spec/unit/component_spec.rb
CHANGED
@@ -19,14 +19,17 @@ require File.join File.dirname(__FILE__), '../../lib/ipxact'
|
|
19
19
|
describe IPXACT::Component do
|
20
20
|
|
21
21
|
it "should create new components without subcomponents, interconnections or ports" do
|
22
|
-
component = IPXACT::Component.new("instance_name", "component_name", "component_vendor", "0.0")
|
22
|
+
component = IPXACT::Component.new("instance_name", {:name => "component_name", :vendor => "component_vendor", :version => "0.0", :library => "component_library"})
|
23
23
|
component.should have(0).subcomponents
|
24
24
|
component.should have(0).interconnections
|
25
25
|
component.should have(0).ports
|
26
|
-
|
27
|
-
component
|
28
|
-
|
29
|
-
|
26
|
+
|
27
|
+
ipxact_id = component.ipxact_id
|
28
|
+
ipxact_id.name.should == "component_name"
|
29
|
+
ipxact_id.vendor.should == "component_vendor"
|
30
|
+
ipxact_id.library.should == "component_library"
|
31
|
+
ipxact_id.version.should == "0.0"
|
32
|
+
component.instance_name.should == "instance_name"
|
30
33
|
end
|
31
34
|
|
32
35
|
it "should be able to get the register map of a given dma device" do
|
@@ -146,7 +149,7 @@ describe IPXACT::Component do
|
|
146
149
|
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], components, designs)
|
147
150
|
|
148
151
|
dma = platform.components['i_dma']
|
149
|
-
(dma
|
152
|
+
(dma.ipxact_id.name + '/' + dma.ipxact_id.vendor + '/x/y').should == 'dma/spiritconsortium.org/x/y'
|
150
153
|
|
151
154
|
end
|
152
155
|
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# Copyright (C) 2010 TIMA Laboratory
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
#
|
16
|
+
|
17
|
+
require File.join File.dirname(__FILE__), '../../lib/ipxact'
|
18
|
+
|
19
|
+
describe IPXACT::Identifier do
|
20
|
+
context "version comparator" do
|
21
|
+
|
22
|
+
it "should return true when comparing '1' and '0'" do
|
23
|
+
IPXACT::Identifier::is_most_recent_version?('1', '0').should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should return false when comparing '0' and '1'" do
|
27
|
+
IPXACT::Identifier::is_most_recent_version?('0', '1').should be_false
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should return false when comparing '1' and '1'" do
|
31
|
+
IPXACT::Identifier::is_most_recent_version?('1', '1').should be_false
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should return false when comparing '1.0' and '1.0'" do
|
35
|
+
IPXACT::Identifier::is_most_recent_version?('1.0', '1.0').should be_false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return true when comparing '1.1' and '1.0'" do
|
39
|
+
IPXACT::Identifier::is_most_recent_version?('1.1', '1.0').should be_true
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should return false when comparing '1.0' and '1.1'" do
|
43
|
+
IPXACT::Identifier::is_most_recent_version?('1.0', '1.1').should be_false
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should return false when comparing '1.0.0' and '1.0'" do
|
47
|
+
IPXACT::Identifier::is_most_recent_version?('1.0.0', '1.0').should be_false
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should return false when comparing '1.0' and '1.0.0'" do
|
51
|
+
IPXACT::Identifier::is_most_recent_version?('1.0', '1.0.0').should be_false
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should return false when comparing '1.0' and '1.0.1'" do
|
55
|
+
IPXACT::Identifier::is_most_recent_version?('1.0', '1.0.1').should be_false
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return true when comparing '1.0.1' and '1.0'" do
|
59
|
+
IPXACT::Identifier::is_most_recent_version?('1.0.1', '1.0').should be_true
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should return true when comparing '1.4.1' and '1.0'" do
|
63
|
+
IPXACT::Identifier::is_most_recent_version?('1.4.1', '1.0').should be_true
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/spec/unit/ipxact_spec.rb
CHANGED
@@ -18,52 +18,4 @@ require File.join File.dirname(__FILE__), '../../lib/ipxact'
|
|
18
18
|
|
19
19
|
describe IPXACT do
|
20
20
|
|
21
|
-
context "version comparator" do
|
22
|
-
|
23
|
-
it "should return true when comparing '1' and '0'" do
|
24
|
-
IPXACT::is_most_recent_version?('1', '0').should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should return false when comparing '0' and '1'" do
|
28
|
-
IPXACT::is_most_recent_version?('0', '1').should be_false
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should return false when comparing '1' and '1'" do
|
32
|
-
IPXACT::is_most_recent_version?('1', '1').should be_false
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should return false when comparing '1.0' and '1.0'" do
|
36
|
-
IPXACT::is_most_recent_version?('1.0', '1.0').should be_false
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should return true when comparing '1.1' and '1.0'" do
|
40
|
-
IPXACT::is_most_recent_version?('1.1', '1.0').should be_true
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should return false when comparing '1.0' and '1.1'" do
|
44
|
-
IPXACT::is_most_recent_version?('1.0', '1.1').should be_false
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should return false when comparing '1.0.0' and '1.0'" do
|
48
|
-
IPXACT::is_most_recent_version?('1.0.0', '1.0').should be_false
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should return false when comparing '1.0' and '1.0.0'" do
|
52
|
-
IPXACT::is_most_recent_version?('1.0', '1.0.0').should be_false
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should return false when comparing '1.0' and '1.0.1'" do
|
56
|
-
IPXACT::is_most_recent_version?('1.0', '1.0.1').should be_false
|
57
|
-
end
|
58
|
-
|
59
|
-
it "should return true when comparing '1.0.1' and '1.0'" do
|
60
|
-
IPXACT::is_most_recent_version?('1.0.1', '1.0').should be_true
|
61
|
-
end
|
62
|
-
|
63
|
-
it "should return true when comparing '1.4.1' and '1.0'" do
|
64
|
-
IPXACT::is_most_recent_version?('1.4.1', '1.0').should be_true
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
21
|
end
|
data/spec/unit/platform_spec.rb
CHANGED
@@ -22,13 +22,13 @@ describe IPXACT::Platform do
|
|
22
22
|
design_docs = IPXACT::load_designs(PLATFORM_PATH)
|
23
23
|
component_docs = IPXACT::load_components(PLATFORM_PATH)
|
24
24
|
platform = IPXACT::Parser::PlatformData.parse_platform("Leon2Platform", component_docs, design_docs)
|
25
|
-
platform
|
25
|
+
platform.ipxact_id.version.should == "1.3"
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should get the version of the platform that is specified in the arguments" do
|
29
29
|
design_docs = IPXACT::load_designs(PLATFORM_PATH)
|
30
30
|
component_docs = IPXACT::load_components(PLATFORM_PATH)
|
31
31
|
platform = IPXACT::Parser::PlatformData.parse_platform(["Leon2Platform", "1.1"], component_docs, design_docs)
|
32
|
-
platform
|
32
|
+
platform.ipxact_id.version.should == "1.1"
|
33
33
|
end
|
34
34
|
end
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 13
|
8
|
+
- 0
|
9
|
+
version: 0.13.0
|
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-
|
17
|
+
date: 2010-12-07 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -47,9 +47,11 @@ files:
|
|
47
47
|
- autotest/discover.rb
|
48
48
|
- lib/ipxact.rb
|
49
49
|
- lib/ipxact/component.rb
|
50
|
+
- lib/ipxact/identifier.rb
|
50
51
|
- lib/ipxact/parser.rb
|
51
52
|
- lib/ipxact/parser/bus_data_parser.rb
|
52
53
|
- lib/ipxact/parser/component_data_parser.rb
|
54
|
+
- lib/ipxact/parser/identifier_parser.rb
|
53
55
|
- lib/ipxact/parser/platform_data_parser.rb
|
54
56
|
- lib/ipxact/pathfinder/graph_pathfinder.rb
|
55
57
|
- lib/ipxact/platform.rb
|
@@ -177,6 +179,7 @@ files:
|
|
177
179
|
- spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/uart_tac.xml
|
178
180
|
- spec/unit/component_spec.rb
|
179
181
|
- spec/unit/graph_pathfinder_spec.rb
|
182
|
+
- spec/unit/identifier_spec.rb
|
180
183
|
- spec/unit/interconnect_spec.rb
|
181
184
|
- spec/unit/ipxact_spec.rb
|
182
185
|
- spec/unit/platform_spec.rb
|
@@ -221,6 +224,7 @@ test_files:
|
|
221
224
|
- spec/integration/general_spec.rb
|
222
225
|
- spec/unit/component_spec.rb
|
223
226
|
- spec/unit/graph_pathfinder_spec.rb
|
227
|
+
- spec/unit/identifier_spec.rb
|
224
228
|
- spec/unit/interconnect_spec.rb
|
225
229
|
- spec/unit/ipxact_spec.rb
|
226
230
|
- spec/unit/platform_spec.rb
|