ruby-ulid 0.6.1 → 0.8.0

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.
data/sig/ulid.rbs CHANGED
@@ -3,8 +3,6 @@ class ULID < Object
3
3
  TIMESTAMP_ENCODED_LENGTH: 10
4
4
  RANDOMNESS_ENCODED_LENGTH: 16
5
5
  ENCODED_LENGTH: 26
6
- TIMESTAMP_OCTETS_LENGTH: 6
7
- RANDOMNESS_OCTETS_LENGTH: 10
8
6
  OCTETS_LENGTH: 16
9
7
  MAX_MILLISECONDS: 281474976710655
10
8
  MAX_ENTROPY: 1208925819614629174706175
@@ -14,13 +12,12 @@ class ULID < Object
14
12
  PATTERN_WITH_CROCKFORD_BASE32_SUBSET: Regexp
15
13
  STRICT_PATTERN_WITH_CROCKFORD_BASE32_SUBSET: Regexp
16
14
  SCANNING_PATTERN: Regexp
17
- UUIDV4_PATTERN: Regexp
18
15
  MIN: ULID
19
16
  MAX: ULID
20
17
  include Comparable
21
18
 
22
- # The `moment` is a `Time` or `Intger of the milliseconds`
23
- type moment = Time | Integer
19
+ type milliseconds = Integer
20
+ type moment = Time | milliseconds
24
21
 
25
22
  class Error < StandardError
26
23
  end
@@ -34,84 +31,121 @@ class ULID < Object
34
31
  class UnexpectedError < Error
35
32
  end
36
33
 
37
- module CrockfordBase32
38
- class SetupError < UnexpectedError
34
+ class IrreversibleUUIDError < Error
35
+ end
36
+
37
+ module UUID
38
+ BASE_PATTERN: Regexp
39
+ V4_PATTERN: Regexp
40
+
41
+ def self.parse_any_to_int: (String) -> Integer
42
+ def self.parse_v4_to_int: (String) -> Integer
43
+
44
+ class Fields < Struct[Integer]
45
+ attr_accessor time_low: Integer
46
+ attr_accessor time_mid: Integer
47
+ attr_accessor time_hi_and_version: Integer
48
+ attr_accessor clock_seq_hi_and_res: Integer
49
+ attr_accessor clk_seq_low: Integer
50
+ attr_accessor node: Integer
51
+ def self.raw_from_octets: (octets) -> Fields
52
+ def self.forced_v4_from_octets: (octets) -> Fields
53
+
54
+ def values: -> Array[Integer]
55
+
56
+ private
57
+
58
+ def initialize: (?time_low: Integer, ?time_mid: Integer, ?time_hi_and_version: Integer, ?clock_seq_hi_and_res: Integer, ?clk_seq_low: Integer, ?node: Integer) -> void
39
59
  end
60
+ end
61
+
62
+ # Private module
63
+ module Utils
64
+ def self.encode_base32hex: (milliseconds: milliseconds, entropy: Integer) -> String
40
65
 
66
+ def self.current_milliseconds: -> milliseconds
67
+
68
+ def self.milliseconds_from_moment: (moment moment) -> milliseconds
69
+
70
+ def self.reasonable_entropy: -> Integer
71
+
72
+ def self.milliseconds_from_time: (Time time) -> milliseconds
73
+
74
+ def self.safe_get_class_name: (untyped object) -> String
75
+
76
+ def self.make_sharable_constants: (Module) -> void
77
+
78
+ def self.ractor_can_make_shareable_time?: -> bool
79
+ end
80
+
81
+ # Private module
82
+ module CrockfordBase32
41
83
  ENCODING_STRING: String
42
84
  CROCKFORD_TR_PATTERN: String
43
- BASE32_TR_PATTERN: String
85
+ BASE32HEX_TR_PATTERN: String
44
86
  VARIANT_TR_PATTERN: String
45
87
  NORMALIZED_TR_PATTERN: String
46
88
 
47
- # A private API. Should not be used in your code.
48
89
  def self.encode: (Integer integer) -> String
49
90
 
50
- # A private API. Should not be used in your code.
51
91
  def self.decode: (String string) -> Integer
52
92
 
53
- # A private API. Should not be used in your code.
54
93
  def self.normalize: (String string) -> String
55
94
 
56
- # A private API. Should not be used in your code.
57
- def self.from_n32: (String n32encoded) -> String
95
+ def self.from_base32hex: (String base32hex) -> String
58
96
  end
59
97
 
60
98
  class MonotonicGenerator
61
99
  include MonitorMixin
62
100
 
63
- # Returned value is `basically not` Thread-safety
101
+ # Returned value is `basically not` Thread-safety\
64
102
  # If you want to keep Thread-safety, keep to call {#generate} only in same {#synchronize} block
65
103
  #
66
104
  # ```ruby
67
105
  # generator.synchronize do
68
- # generator.prev
106
+ # generator.last
69
107
  # generator.inspect
70
108
  # generator.generate
71
109
  # end
72
110
  # ```
73
- attr_reader prev: ULID | nil
111
+ attr_reader last: ULID | nil
74
112
 
75
- # A private API. Should not be used in your code.
76
- def initialize: -> void
77
-
78
- # See [How to keep `Sortable` even if in same timestamp](https://github.com/kachick/ruby-ulid#how-to-keep-sortable-even-if-in-same-timestamp)
113
+ # See [How to keep `Sortable` even if in same timestamp](https://github.com/kachick/ruby-ulid#how-to-keep-sortable-even-if-in-same-timestamp)\
79
114
  # The `Thread-safety` is implemented with [Monitor](https://bugs.ruby-lang.org/issues/16255)
80
115
  def generate: (?moment: moment) -> ULID
81
116
 
82
117
  # Just providing similar api as `ULID.generate` and `ULID.encode` relation. No performance benefit exists in monotonic generator's one.
83
118
  def encode: (?moment: moment) -> String
84
119
 
85
- # Returned value is `basically not` Thread-safety
120
+ # Returned value is `basically not` Thread-safety\
86
121
  # If you want to keep Thread-safety, keep to call {#generate} only in same {#synchronize} block
87
122
  #
88
123
  # ```ruby
89
124
  # generator.synchronize do
90
- # generator.prev
125
+ # generator.last
91
126
  # generator.inspect
92
127
  # generator.generate
93
128
  # end
94
129
  # ```
95
130
  def inspect: -> String
96
131
  alias to_s inspect
97
- def freeze: -> void
132
+
133
+ private
134
+
135
+ def initialize: -> void
136
+
137
+ def last=: (ULID?) -> void
98
138
  end
99
139
 
100
140
  interface _ToULID
101
141
  def to_ulid: () -> ULID
102
142
  end
103
143
 
104
- type full_octets = [Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer] | Array[Integer]
105
- type timestamp_octets = [Integer, Integer, Integer, Integer, Integer, Integer] | Array[Integer]
106
- type randomness_octets = [Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer] | Array[Integer]
144
+ type octets = [Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer] | Array[Integer]
107
145
  type period = Range[Time] | Range[nil] | Range[ULID]
108
146
 
109
147
  @integer: Integer
110
148
  @encoded: String
111
- @timestamp: String?
112
- @randomness: String?
113
- @inspect: String?
114
- @time: Time?
115
149
 
116
150
  # Retuns a ULID
117
151
  #
@@ -149,17 +183,13 @@ class ULID < Object
149
183
  #
150
184
  def self.generate: (?moment: moment, ?entropy: Integer) -> ULID
151
185
 
152
- # Retuns encoded and normalzied String.
153
- # It has same arguments signatures as `.generate`. So can be used for just ID creation usecases without needless object creation.
154
- #
155
- # NOTE: Difference of ULID#encode, returned String is NOT frozen.
186
+ # Retuns encoded and normalzied String.\
187
+ # It has same arguments signatures as `.generate`\
188
+ # So can be used for just ID creation usecases without needless object creation.
156
189
  #
157
190
  def self.encode: (?moment: moment, ?entropy: Integer) -> String
158
191
 
159
- # A private API. Should not be used in your code.
160
- def self.encode_n32: (milliseconds: Integer, entropy: Integer) -> String
161
-
162
- # Shorthand of `ULID.generate(moment: Time)`
192
+ # Shorthand of `ULID.generate(moment: Time)`\
163
193
  # See also [ULID.generate](https://kachick.github.io/ruby-ulid/ULID.html#generate-class_method)
164
194
  #
165
195
  # ```ruby
@@ -173,13 +203,8 @@ class ULID < Object
173
203
  # ```
174
204
  def self.at: (Time time) -> ULID
175
205
 
176
- # A private API. Should not be used in your code.
177
- def self.current_milliseconds: -> Integer
178
-
179
- # A private API. Should not be used in your code.
180
- def self.milliseconds_from_moment: (moment moment) -> Integer
181
-
182
- # `ULID` can be element of the `Range`. If you generated the IDs in monotonic generator, ID based filtering is easy and reliable
206
+ # `ULID` can be element of the `Range`.\
207
+ # If you generated the IDs in monotonic generator, ID based filtering is easy and reliable
183
208
  #
184
209
  # ```ruby
185
210
  # include_end = ulid1..ulid2
@@ -227,16 +252,18 @@ class ULID < Object
227
252
  # ```
228
253
  def self.parse: (_ToStr string) -> ULID
229
254
 
230
- # Return Time instance from encoded String.
255
+ type time_in = String | Integer | nil
256
+
257
+ # Return Time instance from encoded String.\
231
258
  # See also `ULID.encode` for similar purpose.
232
259
  #
233
- # NOTE: Difference of ULID#to_time, returned Time is NOT frozen.
234
- #
235
260
  # ```ruby
236
261
  # time = ULID.decode_time('01ARZ3NDEKTSV4RRFFQ69G5FAV')
237
262
  # #=> 2016-07-30 23:54:10.259 UTC
263
+ # ULID.decode_time('01ARZ3NDEKTSV4RRFFQ69G5FAV', in: '+09:00')
264
+ # #=> 2016-07-31 08:54:10.259 +0900
238
265
  # ```
239
- def self.decode_time: (_ToStr string, ?in: String | Integer | nil) -> Time
266
+ def self.decode_time: (_ToStr string, ?in: time_in) -> Time
240
267
 
241
268
  # Get ULID instance from unnormalized String that encoded in Crockford's base32.
242
269
  #
@@ -253,18 +280,35 @@ class ULID < Object
253
280
  # See also [ulid/spec#57](https://github.com/ulid/spec/pull/57) and [ulid/spec#3](https://github.com/ulid/spec/issues/3)
254
281
  def self.parse_variant_format: (_ToStr string) -> ULID
255
282
 
283
+ # Load a UUID-like string without checking version and variants.
284
+ #
256
285
  # ```ruby
257
- # # Currently experimental feature, so needed to load the extension.
258
- # require 'ulid/uuid'
286
+ # ULID.from_uuidish('123e4567-e89b-12d3-a456-426614174000')
287
+ # #=> ULID(2605-08-20 10:28:29.979 UTC: 0J7S2PFT4V2B9T8NJ2CRA1EG00)
288
+ # ```
259
289
  #
260
- # # Basically reversible
261
- # ulid = ULID.from_uuidv4('0983d0a2-ff15-4d83-8f37-7dd945b5aa39')
290
+ # See also [ULID.from_uuidv4]
291
+ def self.from_uuidish: (String uuidish) -> ULID
292
+
293
+ # Load a UUIDv4 string with checking version and variants.
294
+ #
295
+ # ```ruby
296
+ # ULID.from_uuidv4('0983d0a2-ff15-4d83-8f37-7dd945b5aa39')
262
297
  # #=> ULID(2301-07-10 00:28:28.821 UTC: 09GF8A5ZRN9P1RYDVXV52VBAHS)
263
- # ulid.to_uuidv4 #=> "0983d0a2-ff15-4d83-8f37-7dd945b5aa39"
298
+ # ULID.from_uuidv4('123e4567-e89b-12d3-a456-426614174000')
299
+ # #=> ULID::ParserError
264
300
  # ```
265
301
  #
266
- # See also [Why this is experimental?](https://github.com/kachick/ruby-ulid/issues/76)
302
+ # See also [ULID.from_uuidish]
267
303
  def self.from_uuidv4: (String uuid) -> ULID
304
+
305
+ # Load integer as ULID
306
+ #
307
+ # ```ruby
308
+ # ulid = ULID.parse('01GTXYCWNDKRYH14DBZ77TRSD7')
309
+ # ULID.from_integer(ulid.to_i)
310
+ # #=> ULID(2023-03-07 11:48:07.469 UTC: 01GTXYCWNDKRYH14DBZ77TRSD7)
311
+ # ```
268
312
  def self.from_integer: (Integer integer) -> ULID
269
313
 
270
314
  # Returns termination values for ULID spec.
@@ -325,7 +369,8 @@ class ULID < Object
325
369
  # # ULID(2665-03-16 14:50:22.724 UTC: 0KYFW9DWM4CEGFNTAC6YFAVVJ6)]
326
370
  # ```
327
371
  #
328
- # You can specify a range object for the timestamp restriction, See also [ULID.range](https://kachick.github.io/ruby-ulid/ULID.html#range-class_method).
372
+ # You can specify a range object for the timestamp restriction.\
373
+ # See also [ULID.range](https://kachick.github.io/ruby-ulid/ULID.html#range-class_method)
329
374
  #
330
375
  # ```ruby
331
376
  # ulid1 = ULID.parse('01F4A5Y1YAQCYAYCTC7GRMJ9AA') #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
@@ -386,19 +431,6 @@ class ULID < Object
386
431
  def self.valid_as_variant_format?: (_ToStr string) -> bool
387
432
  | (untyped) -> false
388
433
 
389
- # DEPRECATED Use valid_as_variant_format? instead
390
- #
391
- # Returns `true` if it is normalized string.
392
- # Basically the difference of normalized? is to accept downcase or not. This returns true for downcased ULIDs.
393
- #
394
- # ```ruby
395
- # ULID.valid?(ULID.generate.to_s.downcase) #=> true
396
- # ```
397
- #
398
- # See also [ulid/spec#57](https://github.com/ulid/spec/pull/57) and [ulid/spec#3](https://github.com/ulid/spec/issues/3)
399
- def self.valid?: (_ToStr string) -> bool
400
- | (untyped) -> false
401
-
402
434
  # Returns parsed ULIDs from given String for rough operations.
403
435
  #
404
436
  # ```ruby
@@ -440,7 +472,8 @@ class ULID < Object
440
472
  # ```
441
473
  def self.scan: (_ToStr string) -> Enumerator[self, singleton(ULID)]
442
474
  | (_ToStr string) { (ULID ulid) -> void } -> singleton(ULID)
443
- def self.from_milliseconds_and_entropy: (milliseconds: Integer, entropy: Integer) -> ULID
475
+
476
+ # Returns nil if given object is not a ULID
444
477
  def self.try_convert: (_ToULID) -> ULID
445
478
  | (untyped) -> nil
446
479
 
@@ -450,14 +483,16 @@ class ULID < Object
450
483
  # ulid.milliseconds #=> 1619544442826
451
484
  # ```
452
485
  attr_reader milliseconds: Integer
486
+
453
487
  attr_reader entropy: Integer
454
488
 
489
+ # Private api. (Actually defined protected visibility)
490
+ attr_reader encoded: String
491
+
455
492
  # ```ruby
456
493
  # ulid = ULID.generate
457
494
  # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
458
495
  # ulid.encode #=> "01F4A5Y1YAQCYAYCTC7GRMJ9AA"
459
- # ulid.encode.frozen? #=> true
460
- # ulid.encode.equal?(ulid.to_s) #=> true
461
496
  # ```
462
497
  def encode: -> String
463
498
  alias to_s encode
@@ -480,7 +515,7 @@ class ULID < Object
480
515
  # #=> true
481
516
  # ```
482
517
  #
483
- # To be precise, this sorting unaffected with `case sensitive or not` and might handle [ulid/spec#57](https://github.com/ulid/spec/pull/57) in future.
518
+ # To be precise, this sorting unaffected with `case sensitive or not` and might handle [ulid/spec#57](https://github.com/ulid/spec/pull/57) in future.\
484
519
  # So preferable than `lexicographically sortable` in actual case.
485
520
  #
486
521
  # This returns -1 | 0 | 1 for ULIDs. However defined as returning Integer. It is caused on ruby/rbs current definition.
@@ -490,6 +525,8 @@ class ULID < Object
490
525
  def <=>: (ULID other) -> Integer
491
526
  | (untyped other) -> nil
492
527
 
528
+ # Returns human readable strings that used by Kernel.#p
529
+ #
493
530
  # ```ruby
494
531
  # ulid = ULID.generate
495
532
  # ulid.inspect #=> "ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)"
@@ -504,7 +541,7 @@ class ULID < Object
504
541
  | (untyped other) -> false
505
542
  alias == eql?
506
543
 
507
- # Return `true` for same value of ULID, variant formats of strings, same Time in ULID precision(msec).
544
+ # Return `true` for same value of ULID, variant formats of strings, same Time in ULID precision(msec).\
508
545
  # Do not consider integer, octets and partial strings, then returns `false`.
509
546
  #
510
547
  # ```ruby
@@ -524,12 +561,15 @@ class ULID < Object
524
561
  | (untyped other) -> false
525
562
 
526
563
  # ```ruby
527
- # ulid = ULID.generate
528
- # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
529
- # ulid.to_time #=> 2021-04-27 17:27:22.826 UTC
564
+ # ULID.parse('01F4A5Y1YAQCYAYCTC7GRMJ9AA').to_time
565
+ # #=> 2021-04-27 17:27:22.826 UTC
566
+ # ULID.parse('01F4A5Y1YAQCYAYCTC7GRMJ9AA').to_time(in: '+09:00')
567
+ # #=> 2021-04-28 02:27:22.826 +0900
530
568
  # ```
531
- def to_time: -> Time
569
+ def to_time: (?in: time_in) -> Time
532
570
 
571
+ # Returns timestamp(prefix) part of encoded ULID
572
+ #
533
573
  # ```ruby
534
574
  # ulid = ULID.generate
535
575
  # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
@@ -537,6 +577,8 @@ class ULID < Object
537
577
  # ```
538
578
  def timestamp: -> String
539
579
 
580
+ # Returns randomness(suffix) part of encoded ULID
581
+ #
540
582
  # ```ruby
541
583
  # ulid = ULID.generate
542
584
  # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
@@ -544,27 +586,15 @@ class ULID < Object
544
586
  # ```
545
587
  def randomness: -> String
546
588
 
547
- # Intentionally avoiding to use `Record type` ref: https://github.com/ruby/rbs/blob/4fb4c33b2325d1a73d79ff7aaeb49f21cec1e0e5/docs/syntax.md#record-type
548
- # Because the returning values are not fixed.
549
- def patterns: -> Hash[Symbol, Regexp | String]
550
- def octets: -> full_octets
551
- def timestamp_octets: -> timestamp_octets
552
- def randomness_octets: -> randomness_octets
553
-
554
- # ```ruby
555
- # # Currently experimental feature, so needed to load the extension.
556
- # require 'ulid/uuid'
589
+ # Returns 6 + 10 octets(bytes) represented with Array[Integer]
557
590
  #
558
- # # Basically reversible
559
- # ulid = ULID.from_uuidv4('0983d0a2-ff15-4d83-8f37-7dd945b5aa39')
560
- # #=> ULID(2301-07-10 00:28:28.821 UTC: 09GF8A5ZRN9P1RYDVXV52VBAHS)
561
- # ulid.to_uuidv4 #=> "0983d0a2-ff15-4d83-8f37-7dd945b5aa39"
591
+ # ```ruby
592
+ # ulid = ULID.parse('01F4A5Y1YAQCYAYCTC7GRMJ9AA')
593
+ # ulid.octets #=> [1, 121, 20, 95, 7, 202, 187, 60, 175, 51, 76, 60, 49, 73, 37, 74]
562
594
  # ```
563
- #
564
- # See also [Why this is experimental?](https://github.com/kachick/ruby-ulid/issues/76)
565
- def to_uuidv4: -> String
595
+ def octets: -> octets
566
596
 
567
- # Returns next(successor) ULID.
597
+ # Returns next(successor) ULID.\
568
598
  # Especially `ULID#succ` makes it possible `Range[ULID]#each`.
569
599
  #
570
600
  # NOTE: But basically `Range[ULID]#each` should not be used, incrementing 128 bits IDs are not reasonable operation in most case
@@ -589,38 +619,53 @@ class ULID < Object
589
619
  #
590
620
  # See also [ULID#succ](https://kachick.github.io/ruby-ulid/ULID.html#succ-instance_method)
591
621
  def pred: -> ULID?
592
- def freeze: -> self
593
622
 
594
- # A private API. Should not be used in your code.
595
623
  def marshal_dump: -> Integer
596
624
 
597
- # A private API. Should not be used in your code.
598
625
  def marshal_load: (Integer integer) -> void
599
626
 
600
627
  # Returns `self`
601
628
  def to_ulid: -> self
602
629
 
603
- # Returns `self`. Not a new instance.
604
- def dup: -> self
605
-
606
- # Same API as [Object#clone](https://github.com/ruby/rbs/blob/4fb4c33b2325d1a73d79ff7aaeb49f21cec1e0e5/core/object.rbs#L79)
607
- # But actually returns `self`. Not a new instance.
608
- def clone: (?freeze: bool) -> self
609
-
610
- private
630
+ # Generate a UUID-like string that does not set the version and variants field.\
631
+ # It means wrong in UUIDv4 spec, but reversible
632
+ #
633
+ # ```ruby
634
+ # ulid = ULID.parse('01GTXYCWNDKRYH14DBZ77TRSD7')
635
+ # ulid.to_uuidish #-> '0186bbe6-72ad-9e3d-1091-abf9cfac65a7'
636
+ # ULID.from_uuidish(ulid.to_uuidish) #=> ULID(2023-03-07 11:48:07.469 UTC: 01GTXYCWNDKRYH14DBZ77TRSD7)
637
+ # ```
638
+ #
639
+ # See also [ULID.from_uuidish], [ULID#to_uuidv4], [ulid/spec#64](https://github.com/ulid/spec/issues/64)
640
+ def to_uuidish: -> String
611
641
 
612
- # A private API. Should not be used in your code.
613
- def self.reasonable_entropy: -> Integer
642
+ # Generate a UUIDv4-like string that sets the version and variants field.\
643
+ # It may conform to the UUID specification, but it is irreversible with the source ULID and may conflict with some other ULIDs.\
644
+ # You can specify `force` keyword argument to turn off the irreversible check
645
+ #
646
+ # ```ruby
647
+ # uuid = '0983d0a2-ff15-4d83-8f37-7dd945b5aa39'
648
+ # ulid = ULID.from_uuidv4(uuid)
649
+ # ulid.to_uuidv4 #=> 0983d0a2-ff15-4d83-8f37-7dd945b5aa39
650
+ # ```
651
+ #
652
+ # ```ruby
653
+ # ulid = ULID.from_uuidish('0186bbe6-72ad-9e3d-1091-abf9cfac65a7')
654
+ # ulid.to_uuidv4 #=> ULID::IrreversibleUUIDError
655
+ # ulid.to_uuidv4(force: true) #=> '0186bbe6-72ad-4e3d-9091-abf9cfac65a7'
656
+ # ```
657
+ #
658
+ # See also [ULID.from_uuidv4], [ULID#to_uuidish], [ulid/spec#64](https://github.com/ulid/spec/issues/64)
659
+ def to_uuidv4: (?force: boolish) -> String
614
660
 
615
- # A private API. Should not be used in your code.
616
- def self.milliseconds_from_time: (Time time) -> Integer
661
+ # Returns same ID with different Ruby object.
662
+ def dup: -> ULID
617
663
 
618
- # A private API. Should not be used in your code.
619
- def self.safe_get_class_name: (untyped object) -> String
664
+ # Returns same ID with different Ruby object.::Array::_Pattern\
665
+ # `freeze` keyarg is just provided for standardized API with `Object#clone`, however it accepts only `true`.
666
+ def clone: (?freeze: true) -> ULID
620
667
 
621
- # A private API. Should not be used in your code.
622
- def initialize: (milliseconds: Integer, entropy: Integer, integer: Integer, encoded: String) -> void
668
+ private
623
669
 
624
- # A private API. Should not be used in your code.
625
- def cache_all_instance_variables: -> void
670
+ def initialize: (milliseconds: milliseconds, entropy: Integer, integer: Integer, encoded: String) -> void
626
671
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ulid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Kamiya
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-18 00:00:00.000000000 Z
11
+ date: 2023-03-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " generator, optional monotonicity, parser and tools for ULID (RBS
14
14
  included)\n"
@@ -25,7 +25,7 @@ files:
25
25
  - lib/ulid/crockford_base32.rb
26
26
  - lib/ulid/errors.rb
27
27
  - lib/ulid/monotonic_generator.rb
28
- - lib/ulid/ractor_unshareable_constants.rb
28
+ - lib/ulid/utils.rb
29
29
  - lib/ulid/uuid.rb
30
30
  - lib/ulid/version.rb
31
31
  - sig/ulid.rbs
@@ -38,7 +38,7 @@ metadata:
38
38
  source_code_uri: https://github.com/kachick/ruby-ulid
39
39
  bug_tracker_uri: https://github.com/kachick/ruby-ulid/issues
40
40
  rubygems_mfa_required: 'true'
41
- post_install_message:
41
+ post_install_message:
42
42
  rdoc_options: []
43
43
  require_paths:
44
44
  - lib
@@ -46,15 +46,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 2.7.2
49
+ version: '3.1'
50
50
  required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  requirements: []
56
- rubygems_version: 3.3.7
57
- signing_key:
56
+ rubygems_version: 3.4.6
57
+ signing_key:
58
58
  specification_version: 4
59
59
  summary: ULID manipulation library
60
60
  test_files: []
@@ -1,12 +0,0 @@
1
- # coding: us-ascii
2
- # frozen_string_literal: true
3
-
4
- class ULID
5
- min = parse('00000000000000000000000000').freeze
6
- max = parse('7ZZZZZZZZZZZZZZZZZZZZZZZZZ').freeze
7
-
8
- ractor_can_make_shareable_time = RUBY_VERSION >= '3.1'
9
-
10
- MIN = ractor_can_make_shareable_time ? Ractor.make_shareable(min) : min
11
- MAX = ractor_can_make_shareable_time ? Ractor.make_shareable(max) : max
12
- end