uuid4 1.2.1 → 1.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +6 -3
- data/CHANGELOG.md +43 -2
- data/Gemfile +3 -0
- data/README.md +1 -1
- data/Rakefile +6 -2
- data/lib/uuid4.rb +35 -14
- data/lib/uuid4/formatter/base62.rb +1 -1
- data/lib/uuid4/version.rb +2 -2
- data/uuid4.gemspec +1 -3
- metadata +7 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cd72b459e5ec7d4886de25f62bfe4804d10cc9b89a3353aabaa9fc866b88b5b1
|
4
|
+
data.tar.gz: 2e0b69300a1c2b1ce8aab2591565e71a9fa691ee294cdfbfb03733125ab5dce2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4732a30f2fbca3e9732122cff2fc71484459c1f877534e69dc558251e3e4d667e555e7f5b52b2a40cd69497cd88df8343cdc7016083bb96cbfa4dbb305570693
|
7
|
+
data.tar.gz: 26610d164e801f0c15abcbf18a5dc4a18ce331e493ad8a09462306c4ed605fe4f75db578174b2731ff76f7277d99765f2718c1263bcb5a524d8d8044102952af
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,45 @@
|
|
1
|
-
#
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Changelog](http://keepachangelog.com/).
|
5
|
+
|
6
|
+
|
7
|
+
## Unreleased
|
8
|
+
---
|
9
|
+
|
10
|
+
### New
|
11
|
+
|
12
|
+
### Changes
|
13
|
+
|
14
|
+
### Fixes
|
15
|
+
|
16
|
+
### Breaks
|
17
|
+
|
18
|
+
|
19
|
+
## 1.3.4 - (2020-07-28)
|
20
|
+
---
|
21
|
+
|
22
|
+
### Fixes
|
23
|
+
* Consider newlines when checking base62 format (#5)
|
24
|
+
|
25
|
+
|
26
|
+
## 1.3.3
|
27
|
+
|
28
|
+
* Fix error message on type errors (#4)
|
29
|
+
|
30
|
+
## 1.3.2
|
31
|
+
|
32
|
+
* Fix issue when parsing UUIDs (5e47b00)
|
33
|
+
|
34
|
+
## 1.3.1
|
35
|
+
|
36
|
+
* Fix incompatibility with Rubies <2.2 introduced in #1
|
37
|
+
|
38
|
+
## 1.3.0
|
39
|
+
|
40
|
+
* Add `UUID#hash` and `UUID#eql?` for using UUIDs e.g. as hash keys
|
41
|
+
* Add `UUID.try_convert` returning a UUID or `nil`
|
42
|
+
* Add `UUID.valid?` to validate objects as UUIDs (#1)
|
2
43
|
|
3
44
|
## 1.2.1
|
4
45
|
|
@@ -18,4 +59,4 @@
|
|
18
59
|
|
19
60
|
## 1.0.0
|
20
61
|
|
21
|
-
* Initial release.
|
62
|
+
* Initial release.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# UUID4
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/jgraichen/uuid4.svg?branch=master)](https://travis-ci.org/jgraichen/uuid4)
|
3
|
+
[![Build Status](https://travis-ci.org/jgraichen/uuid4.svg?branch=master)](https://travis-ci.org/jgraichen/uuid4) [![Dependency Status](https://gemnasium.com/badges/github.com/jgraichen/uuid4.svg)](https://gemnasium.com/github.com/jgraichen/uuid4) [![Gem](https://img.shields.io/gem/v/uuid4.svg)](https://rubygems.org/gems/uuid4) [![license](https://img.shields.io/github/license/jgraichen/uuid4.svg)](https://github.com/jgraichen/uuid4/blob/master/LICENSE.txt)
|
4
4
|
|
5
5
|
A UUID support library specialized on v4 UUIDs, parsing and formatting existing UUIDs. It can encode and decode dashed UUIDs, compact UUIDs, large integers, UUID URNs and Base62 coded UUIDs.
|
6
6
|
|
data/Rakefile
CHANGED
data/lib/uuid4.rb
CHANGED
@@ -60,6 +60,14 @@ class UUID4
|
|
60
60
|
|
61
61
|
alias_method :to_i, :to_int
|
62
62
|
|
63
|
+
def hash
|
64
|
+
@value.hash
|
65
|
+
end
|
66
|
+
|
67
|
+
def eql?(object)
|
68
|
+
object.is_a?(::UUID4) && object.hash === hash
|
69
|
+
end
|
70
|
+
|
63
71
|
def inspect
|
64
72
|
"<UUID4:#{to_s}>"
|
65
73
|
end
|
@@ -79,33 +87,46 @@ class UUID4
|
|
79
87
|
attr_reader :value
|
80
88
|
|
81
89
|
class << self
|
90
|
+
alias _new new
|
91
|
+
private :_new
|
92
|
+
|
82
93
|
def new(value = nil)
|
83
94
|
if value.nil?
|
84
95
|
super(SecureRandom.uuid.tr('-', '').hex)
|
85
|
-
elsif value
|
96
|
+
elsif (uuid = try_convert(value))
|
97
|
+
uuid
|
98
|
+
else
|
99
|
+
raise TypeError.new "Invalid UUID: #{value.inspect}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def try_convert(value)
|
104
|
+
if value.nil? || value.is_a?(::UUID4)
|
86
105
|
value
|
87
106
|
elsif value.respond_to?(:to_uuid4)
|
88
107
|
value.to_uuid4
|
89
|
-
elsif
|
90
|
-
|
91
|
-
|
92
|
-
|
108
|
+
elsif (value = _parse(value))
|
109
|
+
_new value
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def valid?(value)
|
114
|
+
if value.is_a?(::UUID4)
|
115
|
+
true
|
93
116
|
else
|
94
|
-
|
117
|
+
!try_convert(value).nil?
|
95
118
|
end
|
96
119
|
end
|
97
120
|
|
98
121
|
def _parse(value)
|
99
122
|
if value.respond_to?(:to_int) && valid_int?(value = value.to_int)
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
123
|
+
value
|
124
|
+
else
|
125
|
+
# Return the result of the first formatter that can decode this value
|
126
|
+
FORMATTERS.lazy.map { |formatter|
|
127
|
+
formatter.decode(value) if formatter.respond_to?(:decode)
|
128
|
+
}.find {|value| !value.nil? }
|
106
129
|
end
|
107
|
-
|
108
|
-
nil
|
109
130
|
end
|
110
131
|
|
111
132
|
def valid_int?(int)
|
data/lib/uuid4/version.rb
CHANGED
data/uuid4.gemspec
CHANGED
@@ -20,7 +20,5 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'base62-rb', '~> 0.3.0'
|
22
22
|
|
23
|
-
spec.add_development_dependency 'bundler'
|
24
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
25
|
-
spec.add_development_dependency 'rspec', '~> 3.0'
|
23
|
+
spec.add_development_dependency 'bundler'
|
26
24
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uuid4
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Graichen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: base62-rb
|
@@ -28,44 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.12'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.12'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
31
|
+
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
33
|
+
version: '0'
|
48
34
|
type: :development
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - "
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
38
|
+
- - ">="
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
40
|
+
version: '0'
|
69
41
|
description:
|
70
42
|
email:
|
71
43
|
- jg@altimos.de
|
@@ -109,10 +81,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
81
|
- !ruby/object:Gem::Version
|
110
82
|
version: '0'
|
111
83
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.5.1
|
84
|
+
rubygems_version: 3.1.2
|
114
85
|
signing_key:
|
115
86
|
specification_version: 4
|
116
87
|
summary: A UUIDv4 support library
|
117
88
|
test_files: []
|
118
|
-
has_rdoc:
|