dcm_dict 0.1.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.
- checksums.yaml +7 -0
- data/COPYING +674 -0
- data/LICENSE +22 -0
- data/README.md +296 -0
- data/Rakefile +36 -0
- data/bin/dcm_dict_converter.rb +194 -0
- data/lib/dcm_dict.rb +46 -0
- data/lib/dcm_dict/dictionary/base_dictionary.rb +47 -0
- data/lib/dcm_dict/dictionary/base_record.rb +62 -0
- data/lib/dcm_dict/dictionary/data_element_dictionary.rb +117 -0
- data/lib/dcm_dict/dictionary/data_element_record.rb +93 -0
- data/lib/dcm_dict/dictionary/uid_dictionary.rb +82 -0
- data/lib/dcm_dict/dictionary/uid_record.rb +48 -0
- data/lib/dcm_dict/encoder/data_to_code.rb +79 -0
- data/lib/dcm_dict/error/dictionary_error.rb +30 -0
- data/lib/dcm_dict/ext/object_extension.rb +38 -0
- data/lib/dcm_dict/refine/array_refine.rb +34 -0
- data/lib/dcm_dict/refine/data_element_refine.rb +37 -0
- data/lib/dcm_dict/refine/internal/array_refine_internal.rb +97 -0
- data/lib/dcm_dict/refine/internal/hash_refine_internal.rb +71 -0
- data/lib/dcm_dict/refine/internal/string_refine_internal.rb +119 -0
- data/lib/dcm_dict/refine/string_refine.rb +35 -0
- data/lib/dcm_dict/refine/symbol_refine.rb +34 -0
- data/lib/dcm_dict/refine/uid_refine.rb +36 -0
- data/lib/dcm_dict/rubies/rb_ext.rb +32 -0
- data/lib/dcm_dict/source_data/data_elements_data.rb +3937 -0
- data/lib/dcm_dict/source_data/detached_data.rb +67 -0
- data/lib/dcm_dict/source_data/uid_values_data.rb +382 -0
- data/lib/dcm_dict/version.rb +27 -0
- data/lib/dcm_dict/xml/constant.rb +38 -0
- data/lib/dcm_dict/xml/field_data.rb +47 -0
- data/lib/dcm_dict/xml/nokogiri_tool.rb +108 -0
- data/lib/dcm_dict/xml/rexml_tool.rb +105 -0
- data/lib/dcm_dict/xml/tag_field_data.rb +96 -0
- data/lib/dcm_dict/xml/uid_field_data.rb +49 -0
- data/lib/dcm_dict/xml/xml_tool.rb +47 -0
- data/spec/data_element_sample_spec_helper.rb +110 -0
- data/spec/data_element_shared_example_spec_helper.rb +57 -0
- data/spec/dcm_dict/dictionary/data_element_dictionary_spec.rb +75 -0
- data/spec/dcm_dict/dictionary/data_element_record_spec.rb +117 -0
- data/spec/dcm_dict/dictionary/uid_dictionary_spec.rb +60 -0
- data/spec/dcm_dict/dictionary/uid_record_spec.rb +53 -0
- data/spec/dcm_dict/encoder/data_to_code_spec.rb +109 -0
- data/spec/dcm_dict/ext/object_extension_spec.rb +53 -0
- data/spec/dcm_dict/refine/array_refine_spec.rb +61 -0
- data/spec/dcm_dict/refine/internal/array_refine_internal_spec.rb +98 -0
- data/spec/dcm_dict/refine/internal/hash_refine_internal_spec.rb +64 -0
- data/spec/dcm_dict/refine/internal/string_refine_internal_spec.rb +214 -0
- data/spec/dcm_dict/refine/string_refine_spec.rb +87 -0
- data/spec/dcm_dict/refine/symbol_refine_spec.rb +41 -0
- data/spec/dcm_dict/rubies/rb_ext_spec.rb +46 -0
- data/spec/dcm_dict/source_data/data_elements_data_spec.rb +40 -0
- data/spec/dcm_dict/source_data/detached_data_spec.rb +55 -0
- data/spec/dcm_dict/source_data/uid_values_data_spec.rb +37 -0
- data/spec/dcm_dict/version_spec.rb +30 -0
- data/spec/dcm_dict/xml/tag_field_data_spec.rb +62 -0
- data/spec/dcm_dict/xml/uid_field_data_spec.rb +60 -0
- data/spec/dictionary_shared_example_spec_helper.rb +118 -0
- data/spec/refine_shared_example_spec_helper.rb +54 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/xml_sample_spec_helper.rb +533 -0
- metadata +212 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe "String refinement" do
|
27
|
+
using DcmDict::Refine::StringRefine
|
28
|
+
describe "should permit access to single data element dictionary information" do
|
29
|
+
|
30
|
+
include_examples "refinement for standard tag",
|
31
|
+
["(0010,1005)", "Patient's Birth Name", "PatientBirthName", "(0010,1005)", "00101005",
|
32
|
+
'(60XX,0040)', "Overlay Type", "OverlayType", "(6022,0040)", "60220040",
|
33
|
+
'(0028,1200)', "Gray Lookup Table Data", "GrayLookupTableData", "(0028,1200)", "00281200",
|
34
|
+
'(0014,3050)', "Dark Current Counts", "DarkCurrentCounts", "(0014,3050)", "00143050",
|
35
|
+
],
|
36
|
+
Proc.new{|tag| tag.inspect}
|
37
|
+
|
38
|
+
|
39
|
+
multi_str_data = { '(6046,0040)' => {
|
40
|
+
tag_multiple: true,
|
41
|
+
tag_name: "Overlay Type",
|
42
|
+
tag_keyword: "OverlayType",
|
43
|
+
tag_key: "OverlayType",
|
44
|
+
tag_vr: [:CS], tag_vm: ["1"],
|
45
|
+
tag: [0x6046, 0x0040], tag_ary: [0x6046, 0x0040],
|
46
|
+
tag_ps: "(60XX,0040)",
|
47
|
+
tag_sym: :overlay_type,
|
48
|
+
tag_ndm: "60460040",
|
49
|
+
tag_str: "(6046,0040)",
|
50
|
+
tag_group: 0x6046,
|
51
|
+
tag_element: 0x0040 } }
|
52
|
+
|
53
|
+
include_examples "refinement for multiple tag",
|
54
|
+
multi_str_data,
|
55
|
+
Proc.new {|tag| tag.inspect}
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
describe "should permit access to single data uid dictionary information" do
|
61
|
+
describe "for regular uids" do
|
62
|
+
[
|
63
|
+
'1.2.840.10008.1.1', "Verification SOP Class",
|
64
|
+
'1.2.840.10008.1.2.1', "Explicit VR Little Endian",
|
65
|
+
'1.2.840.10008.5.1.4.1.2.1.1', "Patient Root Query/Retrieve Information Model - FIND",
|
66
|
+
'1.2.3.4.5.6'
|
67
|
+
].each do |uid|
|
68
|
+
describe "as #{uid.inspect}" do
|
69
|
+
obj = DcmDict::Dictionary::TheUidDictionary.record_at(uid)
|
70
|
+
DcmDict::Dictionary::UidMethod.each do |method|
|
71
|
+
expr = "#{uid.inspect}.#{method.to_s}"
|
72
|
+
it "with #{expr} > #{obj.send(method).inspect}" do
|
73
|
+
value = eval(expr)
|
74
|
+
expect(value).to eq(obj.send(method))
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
include_examples "Raise exception for wrong input",
|
83
|
+
[ '123g123m' ],
|
84
|
+
[ 'this string is not an uid' ],
|
85
|
+
Proc.new {|tag| tag.inspect}
|
86
|
+
|
87
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe "Symbol refinement" do
|
27
|
+
using DcmDict::Refine::SymbolRefine
|
28
|
+
describe "should permit access to single data element dictionary information" do
|
29
|
+
|
30
|
+
include_examples "refinement for standard tag",
|
31
|
+
[:patient_birth_name, :gray_lookup_table_data, :dark_current_counts],
|
32
|
+
Proc.new{|tag| tag.inspect}
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
include_examples "Raise exception for wrong input",
|
37
|
+
[ :wrong_data_element ],
|
38
|
+
[],
|
39
|
+
Proc.new {|tag| tag.inspect}
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe "Rubies dedicate extension" do
|
27
|
+
it "should check for Fixnum::bit_length method" do
|
28
|
+
{(-2**12-1) => 13,
|
29
|
+
(-2**12) => 12,
|
30
|
+
(-2**12+1) => 12,
|
31
|
+
-0x101 => 9,
|
32
|
+
-0x100 => 8,
|
33
|
+
-0xff => 8,
|
34
|
+
-2 => 1,
|
35
|
+
-1 => 0,
|
36
|
+
0 => 0,
|
37
|
+
1 => 1,
|
38
|
+
0xff => 8,
|
39
|
+
0x100 => 9,
|
40
|
+
(2**12-1) => 12,
|
41
|
+
(2**12) => 13,
|
42
|
+
(2**12+1) => 13}.each do |num, expected_bit_length|
|
43
|
+
expect(num.bit_length).to eq(expected_bit_length)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
require 'set'
|
26
|
+
|
27
|
+
describe "DcmDict::SourceData::DataElementsData" do
|
28
|
+
it "All record must have valid field" do
|
29
|
+
supported_keys = [:tag_ps, :tag_name, :tag_key, :tag_vr, :tag_vm, :tag_str, :tag_sym, :tag_ndm, :tag_ary, :tag_multiple, :tag_note].to_set
|
30
|
+
not_empty_keys = supported_keys-[:tag_multiple, :tag_note]
|
31
|
+
DcmDict::SourceData::DataElementsData.each do |record|
|
32
|
+
supported_keys.each do |key|
|
33
|
+
expect(record).to have_key(key)
|
34
|
+
end
|
35
|
+
not_empty_keys.each do |key|
|
36
|
+
expect(record[key].empty?).to be_falsy, "Error on check #{key} not empty for #{record[:tag_ps]} - '#{record[key].inspect}'"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
require 'data_element_sample_spec_helper'
|
26
|
+
|
27
|
+
describe "DcmDict::SourceData::DetachedData" do
|
28
|
+
|
29
|
+
DataElementSampleSpecHelper.unknown_group_length_sample.each do |tag, expected_data|
|
30
|
+
it "create data for 'group length' record for tag=#{tag.inspect}" do
|
31
|
+
data = DcmDict::SourceData::DetachedData.make_group_length_data(tag)
|
32
|
+
expected_data.each do |key, val|
|
33
|
+
expect(data[key]).to eq(val)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
DataElementSampleSpecHelper.private_creator_sample.each do |tag, expected_data|
|
39
|
+
it "create data for 'private creator' record for tag=#{tag.inspect}" do
|
40
|
+
data = DcmDict::SourceData::DetachedData.make_private_creator_data(tag)
|
41
|
+
expected_data.each do |key, val|
|
42
|
+
expect(data[key]).to eq(val)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
DataElementSampleSpecHelper.unknown_sample.each do |tag, expected_data|
|
48
|
+
it "create data for 'unknown tag' record for tag=#{tag.inspect}" do
|
49
|
+
data = DcmDict::SourceData::DetachedData.make_unknown_data(tag)
|
50
|
+
expected_data.each do |key, val|
|
51
|
+
expect(data[key]).to eq(val)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe "DcmDict::SourceData::UidValuesData" do
|
27
|
+
it "All record must have valid field" do
|
28
|
+
supported_keys = [:uid_value, :uid_name, :uid_type]
|
29
|
+
DcmDict::SourceData::UidValuesData.each do |record|
|
30
|
+
supported_keys.each do |key|
|
31
|
+
expect(record).to have_key(key)
|
32
|
+
expect(record.nil_or_empty?).to be_falsy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
|
26
|
+
describe "DcmDict version" do
|
27
|
+
it "may be defined" do
|
28
|
+
expect(DcmDict::VERSION).not_to be_nil
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
require 'xml_sample_spec_helper'
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
describe "XML management for Data Element" do
|
30
|
+
|
31
|
+
RSpec.shared_examples "XML management for Data Element" do |xml_mod, desc|
|
32
|
+
describe "should extract data from single node set data (#{desc})" do
|
33
|
+
XmlSampleSpecHelper.xml_tag_single_set.each do |xml_string, expected_data|
|
34
|
+
xml_data = xml_mod.extract_data_element_field_from_xml_tr(xml_string)
|
35
|
+
describe "for '#{expected_data[:tag_name]}'" do
|
36
|
+
expected_data.each do |key, expected_value|
|
37
|
+
it "with key #{key.inspect}" do
|
38
|
+
expect(xml_data[key]).to eq(expected_value)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
it "from XML doc" do
|
42
|
+
doc = xml_mod.create_xml_doc(xml_string)
|
43
|
+
data = {}
|
44
|
+
xml_mod.each_tr_set(doc, '//xmlns:tr') do |trset|
|
45
|
+
data = xml_mod.extract_data_element_field_from_tr_set(trset)
|
46
|
+
end
|
47
|
+
expect(data).to eq(expected_data)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
if DcmDict::XML.nokogiri_enable?
|
55
|
+
include_examples "XML management for Data Element", DcmDict::XML::NokogiriTool, "with Nokogiri"
|
56
|
+
end
|
57
|
+
|
58
|
+
include_examples "XML management for Data Element", DcmDict::XML::RexmlTool, "with REXML"
|
59
|
+
|
60
|
+
include_examples "XML management for Data Element", DcmDict::XML::XmlTool, "with general XML module"
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2014 Enrico Rivarola
|
3
|
+
#
|
4
|
+
# This file is part of DcmDict gem (dcm_dict).
|
5
|
+
#
|
6
|
+
# DcmDict is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# DcmDict is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with DcmDict. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
#
|
19
|
+
# This software has neither been tested nor approved for clinical use
|
20
|
+
# or for incorporation in a medical device.
|
21
|
+
# It is the redistributor's or user's responsibility to comply with any
|
22
|
+
# applicable local, state, national or international regulations.
|
23
|
+
#
|
24
|
+
require 'spec_helper'
|
25
|
+
require 'xml_sample_spec_helper'
|
26
|
+
|
27
|
+
describe "XML management for UID" do
|
28
|
+
|
29
|
+
RSpec.shared_examples "XML management for UID" do |xml_mod, desc|
|
30
|
+
describe "should extract data from single node set data (#{desc})" do
|
31
|
+
XmlSampleSpecHelper.xml_uid_set.each do |xml_string, expected_data|
|
32
|
+
xml_data = xml_mod.extract_uid_field_from_xml_tr(xml_string)
|
33
|
+
describe "for '#{expected_data[:uid_name]}'" do
|
34
|
+
expected_data.each do |key, expected_value|
|
35
|
+
it "with key #{key.inspect}" do
|
36
|
+
expect(xml_data[key]).to eq(expected_value)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
it "from XML doc" do
|
40
|
+
doc = xml_mod.create_xml_doc(xml_string)
|
41
|
+
data = {}
|
42
|
+
xml_mod.each_tr_set(doc, '//xmlns:tr') do |trset|
|
43
|
+
data = xml_mod.extract_uid_field_from_tr_set(trset)
|
44
|
+
end
|
45
|
+
expect(data).to eq(expected_data)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if DcmDict::XML.nokogiri_enable?
|
53
|
+
include_examples "XML management for UID", DcmDict::XML::NokogiriTool, "with Nokogiri"
|
54
|
+
end
|
55
|
+
|
56
|
+
include_examples "XML management for UID", DcmDict::XML::RexmlTool, "with REXML"
|
57
|
+
|
58
|
+
include_examples "XML management for UID", DcmDict::XML::XmlTool, "with general XML module"
|
59
|
+
|
60
|
+
end
|