evt-identifier-uuid 0.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/identifier/uuid.rb +6 -0
- data/lib/identifier/uuid/controls.rb +3 -0
- data/lib/identifier/uuid/controls/incrementing.rb +24 -0
- data/lib/identifier/uuid/controls/invalid.rb +11 -0
- data/lib/identifier/uuid/controls/random.rb +11 -0
- data/lib/identifier/uuid/pattern.rb +17 -0
- data/lib/identifier/uuid/random.rb +49 -0
- data/lib/identifier/uuid/uuid.rb +30 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b1ca83ae60073221ffb5812fc7874aea2c64327
|
4
|
+
data.tar.gz: fc50d559e2ae57a66d0b95b14c405b20fd43ba06
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 987fd166ba8efffac107eab68e1af8eea1f7de346d31210e89d54b8bb408c219d5f2f1bef5ba645cda2a15c0f28b246fb4865a1fec67a40c445ed2fbaef1e137
|
7
|
+
data.tar.gz: 4bfa1c662a64fa4d2d8094417ca1abcdb00afdc259b4475600c3e1d915e54a7b3e9a9e30fb7add5daac35d0dcb169660d479caebed11111d02e6e29b990349d1
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Identifier
|
2
|
+
module UUID
|
3
|
+
module Controls
|
4
|
+
module Incrementing
|
5
|
+
def self.example(i=nil, increment: nil, sample: nil)
|
6
|
+
i ||= increment || 1
|
7
|
+
sample ||= false
|
8
|
+
|
9
|
+
first_octet = (i).to_s.rjust(8, '0')
|
10
|
+
|
11
|
+
fourth_prefixes = ['8', '9', 'a', 'b']
|
12
|
+
|
13
|
+
if sample
|
14
|
+
fourth_prefix = fourth_prefixes.sample
|
15
|
+
else
|
16
|
+
fourth_prefix = fourth_prefixes[0]
|
17
|
+
end
|
18
|
+
|
19
|
+
"#{first_octet}-0000-4000-#{fourth_prefix}000-000000000000"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Identifier
|
2
|
+
module UUID
|
3
|
+
module Pattern
|
4
|
+
TYPE_4 = %r{
|
5
|
+
[a-f0-9]{8} # abcdef01
|
6
|
+
- # -
|
7
|
+
[a-f0-9]{4} # abcd
|
8
|
+
- # -
|
9
|
+
4[a-f0-9]{3} # 4abc
|
10
|
+
- # -
|
11
|
+
[89ab][a-f0-9]{3} # 8abc
|
12
|
+
- # -
|
13
|
+
[a-f0-9]{12} # abcdef012345
|
14
|
+
}xi
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Identifier
|
2
|
+
module UUID
|
3
|
+
class Random
|
4
|
+
def get
|
5
|
+
self.class.get
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.get
|
9
|
+
UUID.format(raw)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.raw
|
13
|
+
SecureRandom.uuid
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.configure(receiver, attr_name=nil)
|
17
|
+
instance = new
|
18
|
+
|
19
|
+
if attr_name.nil?
|
20
|
+
if receiver.respond_to?(:identifier)
|
21
|
+
attr_name = :identifier
|
22
|
+
else
|
23
|
+
attr_name = :uuid
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
receiver.send "#{attr_name}=", instance
|
28
|
+
|
29
|
+
instance
|
30
|
+
end
|
31
|
+
|
32
|
+
module Substitute
|
33
|
+
NullUUID = Naught.build do |config|
|
34
|
+
config.mimic UUID::Random
|
35
|
+
|
36
|
+
def set(val)
|
37
|
+
define_singleton_method(:get) do
|
38
|
+
val
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.build
|
44
|
+
NullUUID.new
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Identifier
|
2
|
+
module UUID
|
3
|
+
def self.format(uuid)
|
4
|
+
uuid.to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.random
|
8
|
+
Random.get
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.uuid?(text)
|
12
|
+
uuid = parse(text)
|
13
|
+
uuid == text
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.parse(text)
|
17
|
+
uuid = text.match(pattern).to_s
|
18
|
+
uuid = nil if uuid == ''
|
19
|
+
uuid
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.pattern
|
23
|
+
Pattern::TYPE_4
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.zero
|
27
|
+
'00000000-0000-0000-0000-000000000000'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: evt-identifier-uuid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- The Eventide Project
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: naught
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ntl-test_bench
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " "
|
42
|
+
email: opensource@eventide-project.org
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/identifier/uuid.rb
|
48
|
+
- lib/identifier/uuid/controls.rb
|
49
|
+
- lib/identifier/uuid/controls/incrementing.rb
|
50
|
+
- lib/identifier/uuid/controls/invalid.rb
|
51
|
+
- lib/identifier/uuid/controls/random.rb
|
52
|
+
- lib/identifier/uuid/pattern.rb
|
53
|
+
- lib/identifier/uuid/random.rb
|
54
|
+
- lib/identifier/uuid/uuid.rb
|
55
|
+
homepage: https://github.com/eventide-project/identifier-uuid
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: 2.3.3
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.5.2
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: UUID identifier generator with support for dependency configuration for real
|
79
|
+
and null object implementations
|
80
|
+
test_files: []
|