Dicom_UID 0.0.6 → 0.0.7
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 +4 -4
- data/README.md +8 -0
- data/lib/dicom_uid.rb +32 -24
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e97f4395a5d889ad19cadea15ef9a2f67da63e5964fffaef298e07bd7ca2a83
|
4
|
+
data.tar.gz: 4f21101d69cbbb846aa9a7ae1ab8e10cee598f7aecc7e34d03879f2d699d28fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5976568e36b27869d5d2caf36bd41b0356695021c264d29fc84c2f0071f48868f396737015900bfaf27bbf89d4a7e5ab4bdea36d415af380170c72fe41d1f777
|
7
|
+
data.tar.gz: d375cac73d04c5d1820b5c035ad9742d31954d06ff25577eed934d6a7b09b76a62cfff79f4a25a010ed2ce61f5671f2c4a88d0de81694300ac0facafd990d9f7
|
data/README.md
ADDED
data/lib/dicom_uid.rb
CHANGED
@@ -1,24 +1,14 @@
|
|
1
|
-
# lib/dicom_uid.rb
|
2
|
-
|
3
1
|
# DICOM UID Generator according to the DICOM documentation
|
4
2
|
# http://dicom.nema.org/dicom/2013/output/chtml/part05/chapter_9.html
|
5
|
-
#
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def initialize name
|
11
|
-
@uid = random_dicom_uid '', nil
|
12
|
-
@name = name
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_s
|
16
|
-
'UID : ' << @uid << ' NAME : ' << @name
|
17
|
-
end
|
3
|
+
#
|
4
|
+
# The UID looks like the following <org>.<suffix>
|
5
|
+
# UID is composed of two main components, org and suffix. Components are separated by a dot and are only composed of decimals.
|
6
|
+
# The UID must not be more than 64 characters, dots included.
|
7
|
+
module DicomUID
|
18
8
|
|
19
9
|
|
20
|
-
# Generates random component with random, defined, length
|
21
|
-
def random_component length
|
10
|
+
# Generates random component with random, defined, maximum length
|
11
|
+
def self.random_component length, odd_byte_boundary
|
22
12
|
|
23
13
|
# randing length of number
|
24
14
|
length_component = length - 1
|
@@ -40,25 +30,25 @@ class DicomUID
|
|
40
30
|
end
|
41
31
|
|
42
32
|
|
43
|
-
#
|
44
|
-
def rand_duid uid
|
45
|
-
comp = random_component remain
|
33
|
+
# Generates recursively a random dicom uid
|
34
|
+
def self.rand_duid uid, remain, obb
|
35
|
+
comp = self.random_component remain, obb
|
46
36
|
remain -= comp.length
|
47
37
|
uid << comp
|
48
38
|
|
49
39
|
return uid if remain <= 0
|
50
40
|
|
51
41
|
uid << '.'
|
52
|
-
rand_duid uid, remain - 1
|
42
|
+
self.rand_duid uid, remain - 1, obb
|
53
43
|
end
|
54
44
|
|
55
45
|
|
56
46
|
# set default values, with org_root if needed
|
57
47
|
# the size of the UID is randomized
|
58
|
-
def random_dicom_uid org_root, fixed_size, odd_byte_boundary = true
|
48
|
+
def self.random_dicom_uid org_root, fixed_size, odd_byte_boundary = true
|
59
49
|
|
60
50
|
# building the org root
|
61
|
-
org_root
|
51
|
+
org_root = self.random_component(64, odd_byte_boundary) if org_root.empty?# UID needs at least an org root
|
62
52
|
raise LeadingZeroError if org_root[0] == '0' and org_root.length != 1
|
63
53
|
raise OddByteError if org_root[-2].to_i % 2 == 1 and org_root[-1] != 0 and odd_byte_boundary
|
64
54
|
org_root << '.' if org_root[-1] != '.'
|
@@ -70,9 +60,27 @@ class DicomUID
|
|
70
60
|
raise RangeError("Size of UID can't be negative") if fixed_size < 0
|
71
61
|
|
72
62
|
# building the suffix
|
73
|
-
rand_duid org_root, (fixed_size - org_root.length), odd_byte_boundary
|
63
|
+
self.rand_duid org_root, (fixed_size - org_root.length), odd_byte_boundary
|
74
64
|
end
|
75
65
|
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
def self.random_uids org_root, fixed_size, array_size, odd_byte_boundary = true
|
72
|
+
uids = Array.new
|
73
|
+
|
74
|
+
array_size.times do
|
75
|
+
uids << random_dicom_uid org_root, fixed_size, odd_byte_boundary
|
76
|
+
end
|
77
|
+
|
78
|
+
uids
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
76
84
|
end
|
77
85
|
|
78
86
|
# EXCEPTIONS
|
metadata
CHANGED
@@ -1,28 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Dicom_UID
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Repain Paul
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Generates random
|
13
|
+
description: Generates random UID for DICOM files
|
14
14
|
email: paul.repain@yahoo.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
|
-
extra_rdoc_files:
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.md
|
18
19
|
files:
|
20
|
+
- README.md
|
19
21
|
- lib/dicom_uid.rb
|
20
|
-
homepage: https://rubygems.org/gems/
|
22
|
+
homepage: https://rubygems.org/gems/Dicom_UID
|
21
23
|
licenses:
|
22
24
|
- MIT
|
23
25
|
metadata:
|
24
|
-
source_code_uri: https://github.com/Poulpy/
|
25
|
-
post_install_message:
|
26
|
+
source_code_uri: https://github.com/Poulpy/DICOM-UID
|
27
|
+
post_install_message: Thanks for installing!
|
26
28
|
rdoc_options: []
|
27
29
|
require_paths:
|
28
30
|
- lib
|
@@ -41,5 +43,5 @@ rubyforge_project:
|
|
41
43
|
rubygems_version: 2.7.9
|
42
44
|
signing_key:
|
43
45
|
specification_version: 4
|
44
|
-
summary:
|
46
|
+
summary: Random DICOM UID generator
|
45
47
|
test_files: []
|