ruby-ulid 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ulid.rb +17 -1
- data/lib/ulid/version.rb +1 -1
- data/sig/ulid.rbs +1 -0
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f33ff714eef2b217cb557fe4ae46087a77b834aa42c406e940f2f8a6630464c
|
4
|
+
data.tar.gz: ce004faa759110d8494f34a058230a90d7231af4a309c5c7bf66b0f0963bcf81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d60377fcf5cd9523b09eb78be1feef0fb996b9f6ebf0e430db9bf3902899ee6e6e6d62518a9f33ecfb5d6786390e08bbf545d5a9b36f141fd4a95bc7ff8f6612
|
7
|
+
data.tar.gz: 981bafadfcbb63254a276a1ae9b201b2b636555416450ce421ffa0f4482e343072811623ae4856970904227ae0da0fe2f991ffc809556d4bc6a33a910446c7dd
|
data/lib/ulid.rb
CHANGED
@@ -79,7 +79,7 @@ class ULID
|
|
79
79
|
# @param [Integer] entropy
|
80
80
|
# @return [ULID]
|
81
81
|
def self.generate(moment: current_milliseconds, entropy: reasonable_entropy)
|
82
|
-
milliseconds = moment.kind_of?(Time) ? (moment
|
82
|
+
milliseconds = moment.kind_of?(Time) ? time_to_milliseconds(moment) : moment
|
83
83
|
new milliseconds: milliseconds, entropy: entropy
|
84
84
|
end
|
85
85
|
|
@@ -174,6 +174,22 @@ class ULID
|
|
174
174
|
end
|
175
175
|
alias_method :==, :eql?
|
176
176
|
|
177
|
+
# @return [Boolean]
|
178
|
+
def ===(other)
|
179
|
+
case other
|
180
|
+
when ULID
|
181
|
+
self == other
|
182
|
+
when String
|
183
|
+
begin
|
184
|
+
self == self.class.parse(other)
|
185
|
+
rescue Exception
|
186
|
+
false
|
187
|
+
end
|
188
|
+
else
|
189
|
+
false
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
177
193
|
# @return [Time]
|
178
194
|
def to_time
|
179
195
|
@time ||= Time.at(0, @milliseconds, :millisecond).utc
|
data/lib/ulid/version.rb
CHANGED
data/sig/ulid.rbs
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-ulid
|
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
|
- Kenichi Kamiya
|
@@ -17,33 +17,19 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.1.2
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.1.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: test-unit
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 3.4.1
|
34
20
|
- - "<"
|
35
21
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
37
|
-
type: :
|
22
|
+
version: 0.2.0
|
23
|
+
type: :runtime
|
38
24
|
prerelease: false
|
39
25
|
version_requirements: !ruby/object:Gem::Requirement
|
40
26
|
requirements:
|
41
27
|
- - ">="
|
42
28
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
29
|
+
version: 0.1.2
|
44
30
|
- - "<"
|
45
31
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
32
|
+
version: 0.2.0
|
47
33
|
- !ruby/object:Gem::Dependency
|
48
34
|
name: benchmark-ips
|
49
35
|
requirement: !ruby/object:Gem::Requirement
|