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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ulid.rb +17 -1
  3. data/lib/ulid/version.rb +1 -1
  4. data/sig/ulid.rbs +1 -0
  5. metadata +5 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e00e5eba399c7d96e26ada6a0f0463fdb7fc08d7ec69c96588a5f85320a997be
4
- data.tar.gz: e5f79b9a86ab038be2d0b39a787d8e70108998d3a024c699e401770ec6edade3
3
+ metadata.gz: 1f33ff714eef2b217cb557fe4ae46087a77b834aa42c406e940f2f8a6630464c
4
+ data.tar.gz: ce004faa759110d8494f34a058230a90d7231af4a309c5c7bf66b0f0963bcf81
5
5
  SHA512:
6
- metadata.gz: 0b4221414e2cdeeb67f6f6173c5ce25475f388e11df12c16864f576d76cac1fe3197dc5c2dd6ddef03d4fdfe6c079e0256a91c7b1728af73dd9d1b56c6ca7109
7
- data.tar.gz: 369838ea1deac94dc44c71a37a606eb57a88f0266910f555a3ede1b7d85653be564499f7bf009cdd426a4a84a4be7e4d0f046ca4106bf25e8613cede927a47c5
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.to_r * 1000).to_i : moment.to_int
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
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  class ULID
5
- VERSION = '0.0.6'
5
+ VERSION = '0.0.7'
6
6
  end
data/sig/ulid.rbs CHANGED
@@ -40,6 +40,7 @@ class ULID
40
40
  def inspect: -> String
41
41
  def eql?: (untyped other) -> bool
42
42
  def ==: (untyped other) -> bool
43
+ def ===: (untyped other) -> bool
43
44
  def to_time: -> Time
44
45
  def octets: -> Array[Integer]
45
46
  def time_octets: -> Array[Integer]
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.6
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: '4'
37
- type: :development
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: 3.4.1
29
+ version: 0.1.2
44
30
  - - "<"
45
31
  - !ruby/object:Gem::Version
46
- version: '4'
32
+ version: 0.2.0
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: benchmark-ips
49
35
  requirement: !ruby/object:Gem::Requirement