ruby-ulid 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a390455a27395fd77ef398b0613e72b321b96d44e8454c8ab9346ae15eddfdc
4
- data.tar.gz: 1150658ae26cc591f3946898ccb356ce1c6135292de0600ef0604aceb7a00554
3
+ metadata.gz: fd21fa1c7af3acea07d2f4e6e7842927f1b33367e26b84bc5eef9a65a64c5582
4
+ data.tar.gz: da03f786abbbffa4411a4eb8b4ea189aecb3a920fb37026f1ae7f66398c5661f
5
5
  SHA512:
6
- metadata.gz: 4ffb5c69ec1327bacbb54b4afdd6718f8cc9b5afd450f739588d8e414c645eca9c1090c77efb464293f0e8e1b960cf4df75289785d3cd7b489404e31c24ecc8a
7
- data.tar.gz: bf6a08216e0745d0727c356a5a239126bac8518f8fbb57f295b417e14ed0878c8f0c32774b83137b1feb58d8230140492cb469bb18dc9d5df5db5aa088410ffb
6
+ metadata.gz: 41143d43ef0f41f7441d0f2570bd73cad4ac6e382ea531c5f8aa30fccd5a4ff99790a356c6563c577153857b56eca8545d1b561f66b1ccdb5baa2aa281f2b692
7
+ data.tar.gz: 8c3bca9d754e6003af6af000bcb0d63fddb779586f3022cb33771182efa41ee0939c8d0a781ede46807c5cbf106b3389fbbefb684122c3d5ba704a8921b9f9a5
File without changes
data/README.md CHANGED
@@ -10,8 +10,9 @@ Also providing [ruby/rbs](https://github.com/ruby/rbs) signature files.
10
10
 
11
11
  ![ULIDlogo](https://raw.githubusercontent.com/kachick/ruby-ulid/main/logo.png)
12
12
 
13
- ![Build Status](https://github.com/kachick/ruby-ulid/actions/workflows/test_behaviors.yml/badge.svg?branch=main)
13
+ [![Build Status](https://github.com/kachick/ruby-ulid/actions/workflows/test_behaviors.yml/badge.svg?branch=main)](https://github.com/kachick/ruby-ulid/actions/workflows/test_behaviors.yml/?branch=main)
14
14
  [![Gem Version](https://badge.fury.io/rb/ruby-ulid.png)](http://badge.fury.io/rb/ruby-ulid)
15
+ [![Visual Studio Code](https://img.shields.io/badge/Visual%20Studio%20Code-0078d7.svg?style=for-the-badge&logo=visual-studio-code&logoColor=white)](https://github.dev/kachick/ruby-ulid)
15
16
 
16
17
  ## Universally Unique Lexicographically Sortable Identifier
17
18
 
@@ -37,7 +38,7 @@ Instead, herein is proposed ULID:
37
38
 
38
39
  ### Install
39
40
 
40
- Require Ruby 2.6 or later
41
+ Require Ruby 2.7 or later
41
42
 
42
43
  This command will install the latest version into your environment
43
44
 
@@ -49,7 +50,7 @@ Should be installed!
49
50
  Add this line to your application/library's `Gemfile` is needed in basic use-case
50
51
 
51
52
  ```ruby
52
- gem 'ruby-ulid', '>= 0.1.4', '< 0.2.0'
53
+ gem 'ruby-ulid', '~> 0.2.0'
53
54
  ```
54
55
 
55
56
  ### Generator and Parser
@@ -170,8 +171,7 @@ exclude_end = ULID.range(time1...time2) #=> The end of `Range[ULID]` will be the
170
171
 
171
172
  # Below patterns are acceptable
172
173
  pinpointing = ULID.range(time1..time1) #=> This will match only for all IDs in `time1`
173
- # until_the_end = ULID.range(..time1) #=> This will match only for all IDs upto `time1` (The `nil` starting `Range` can be used since Ruby 2.7)
174
- until_the_end = ULID.range(ULID.min.to_time..time1) #=> This is same as above for Ruby 2.6
174
+ until_the_end = ULID.range(..time1) #=> This will match only for all IDs upto `time1`
175
175
  until_the_ulid_limit = ULID.range(time1..) # This will match only for all IDs from `time1` to max value of the ULID limit
176
176
 
177
177
  # So you can use the generated range objects as below
@@ -192,7 +192,7 @@ ULID.floor(time) #=> 2000-01-01 00:00:00.123 UTC
192
192
  For rough operations, `ULID.scan` might be useful.
193
193
 
194
194
  ```ruby
195
- json =<<'EOD'
195
+ json = <<'JSON'
196
196
  {
197
197
  "id": "01F4GNAV5ZR6FJQ5SFQC7WDSY3",
198
198
  "author": {
@@ -217,7 +217,7 @@ json =<<'EOD'
217
217
  }
218
218
  ]
219
219
  }
220
- EOD
220
+ JSON
221
221
 
222
222
  ULID.scan(json).to_a
223
223
  #=>
@@ -401,7 +401,7 @@ So you can replace the code as below
401
401
  +ULID.generate.to_s
402
402
  ```
403
403
 
404
- NOTE: It had crucial issue for handling precision, in version before `1.3.0`, when you extract timestamps from old generated ULIDs, it might be not accurate value.
404
+ NOTE: In version before `1.3.0`, timestamps might not be correct value.
405
405
 
406
406
  1. [Sort order does not respect millisecond ordering](https://github.com/rafaelsales/ulid/issues/22)
407
407
  1. [Fixed in this PR](https://github.com/rafaelsales/ulid/pull/23)
@@ -425,11 +425,12 @@ Major methods can be replaced as below.
425
425
  +ULID.max(time).to_s
426
426
  ```
427
427
 
428
- NOTE: It is still having precision issue similar as `ulid gem` in the both generator and parser. I sent PRs.
428
+ NOTE: In version before `1.0.2`, timestamps might not be correct value.
429
429
 
430
430
  1. [Parsed time object has more than milliseconds](https://github.com/abachman/ulid-ruby/issues/3)
431
431
  1. [Fix to handle timestamp precision in parser](https://github.com/abachman/ulid-ruby/pull/5)
432
432
  1. [Fix to handle timestamp precision in generator](https://github.com/abachman/ulid-ruby/pull/4)
433
+ 1. [Released in 1.0.2](https://github.com/abachman/ulid-ruby/compare/v1.0.0...v1.0.2)
433
434
 
434
435
  ### Compare performance with them
435
436
 
data/lib/ruby-ulid.rb ADDED
@@ -0,0 +1,6 @@
1
+ # coding: us-ascii
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright (C) 2021 Kenichi Kamiya
5
+
6
+ require_relative 'ulid'
@@ -1,9 +1,12 @@
1
1
  # coding: us-ascii
2
2
  # frozen_string_literal: true
3
+
3
4
  # Copyright (C) 2021 Kenichi Kamiya
4
5
 
5
6
  class ULID
6
- # Currently supporting only for `subset` for actual use-case`
7
+ # @see https://www.crockford.com/base32.html
8
+ #
9
+ # This module supporting only `subset of original crockford for actual use-case` in ULID context.
7
10
  # Original decoding spec allows other characters.
8
11
  # But I think ULID should allow `subset` of Crockford's Base32.
9
12
  # See below
@@ -46,18 +49,22 @@ class ULID
46
49
  end
47
50
  end.freeze
48
51
  raise SetupError, 'obvious bug exists in the mapping algorithm' unless N32_CHAR_BY_CROCKFORD_BASE32_CHAR.keys == crockford_base32_mappings.keys
52
+
49
53
  CROCKFORD_BASE32_CHAR_PATTERN = /[#{N32_CHAR_BY_CROCKFORD_BASE32_CHAR.keys.join}]/.freeze
50
54
 
51
55
  CROCKFORD_BASE32_CHAR_BY_N32_CHAR = N32_CHAR_BY_CROCKFORD_BASE32_CHAR.invert.freeze
52
56
  N32_CHAR_PATTERN = /[#{CROCKFORD_BASE32_CHAR_BY_N32_CHAR.keys.join}]/.freeze
53
57
 
54
- VARIANT_BY_STANDARD = {
58
+ STANDARD_BY_VARIANT = {
55
59
  'L' => '1',
60
+ 'l' => '1',
56
61
  'I' => '1',
62
+ 'i' => '1',
57
63
  'O' => '0',
64
+ 'o' => '0',
58
65
  '-' => ''
59
66
  }.freeze
60
- VARIANT_PATTERN = /[#{VARIANT_BY_STANDARD.keys.join}]/.freeze
67
+ VARIANT_PATTERN = /[#{STANDARD_BY_VARIANT.keys.join}]/.freeze
61
68
 
62
69
  # @api private
63
70
  # @param [String] string
@@ -79,7 +86,7 @@ class ULID
79
86
  # @param [String] string
80
87
  # @return [String]
81
88
  def self.normalize(string)
82
- string.upcase.gsub(VARIANT_PATTERN, VARIANT_BY_STANDARD)
89
+ string.gsub(VARIANT_PATTERN, STANDARD_BY_VARIANT)
83
90
  end
84
91
  end
85
92
  end
@@ -1,5 +1,6 @@
1
1
  # coding: us-ascii
2
2
  # frozen_string_literal: true
3
+
3
4
  # Copyright (C) 2021 Kenichi Kamiya
4
5
 
5
6
  class ULID
@@ -36,19 +37,23 @@ class ULID
36
37
 
37
38
  milliseconds = ULID.milliseconds_from_moment(moment)
38
39
 
39
- ulid = if @prev.milliseconds < milliseconds
40
- ULID.generate(moment: milliseconds)
41
- else
42
- ULID.from_milliseconds_and_entropy(milliseconds: @prev.milliseconds, entropy: @prev.entropy.succ)
43
- end
40
+ ulid = (
41
+ if @prev.milliseconds < milliseconds
42
+ ULID.generate(moment: milliseconds)
43
+ else
44
+ ULID.from_milliseconds_and_entropy(milliseconds: @prev.milliseconds, entropy: @prev.entropy.succ)
45
+ end
46
+ )
44
47
 
45
48
  unless ulid > @prev
46
49
  base_message = "monotonicity broken from unexpected reasons # generated: #{ulid.inspect}, prev: #{@prev.inspect}"
47
- additional_information = if Thread.list == [Thread.main]
48
- '# NOTE: looks single thread only exist'
49
- else
50
- '# NOTE: ran on multi threads, so this might from concurrency issue'
51
- end
50
+ additional_information = (
51
+ if Thread.list == [Thread.main]
52
+ '# NOTE: looks single thread only exist'
53
+ else
54
+ '# NOTE: ran on multi threads, so this might from concurrency issue'
55
+ end
56
+ )
52
57
 
53
58
  raise UnexpectedError, base_message + additional_information
54
59
  end
data/lib/ulid/uuid.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # coding: us-ascii
2
2
  # frozen_string_literal: true
3
+
3
4
  # Copyright (C) 2021 Kenichi Kamiya
4
5
 
5
6
  # Extracted features around UUID from some reasons
@@ -8,7 +9,7 @@
8
9
  # * https://github.com/kachick/ruby-ulid/issues/76
9
10
  class ULID
10
11
  # Imported from https://stackoverflow.com/a/38191104/1212807, thank you!
11
- UUIDV4_PATTERN = /\A[0-9A-F]{8}-[0-9A-F]{4}-[4][0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\z/i.freeze
12
+ UUIDV4_PATTERN = /\A[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}\z/i.freeze
12
13
  private_constant :UUIDV4_PATTERN
13
14
 
14
15
  # @param [String, #to_str] uuid
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.1.4'
5
+ VERSION = '0.2.0'
6
6
  end
data/lib/ulid.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # coding: us-ascii
2
2
  # frozen_string_literal: true
3
+
3
4
  # Copyright (C) 2021 Kenichi Kamiya
4
5
 
5
6
  require 'securerandom'
@@ -60,6 +61,7 @@ class ULID
60
61
  # @return [ULID]
61
62
  def self.at(time)
62
63
  raise ArgumentError, 'ULID.at takes only `Time` instance' unless Time === time
64
+
63
65
  from_milliseconds_and_entropy(milliseconds: milliseconds_from_time(time), entropy: reasonable_entropy)
64
66
  end
65
67
 
@@ -91,19 +93,21 @@ class ULID
91
93
  # * Do not take random generator for the arguments
92
94
  # * Raising error instead of truncating elements for the given number
93
95
  def self.sample(*args, period: nil)
94
- int_generator = if period
95
- ulid_range = range(period)
96
- min, max, exclude_end = ulid_range.begin.to_i, ulid_range.end.to_i, ulid_range.exclude_end?
96
+ int_generator = (
97
+ if period
98
+ ulid_range = range(period)
99
+ min, max, exclude_end = ulid_range.begin.to_i, ulid_range.end.to_i, ulid_range.exclude_end?
97
100
 
98
- possibilities = (max - min) + (exclude_end ? 0 : 1)
99
- raise ArgumentError, "given range `#{ulid_range.inspect}` does not have possibilities" unless possibilities.positive?
101
+ possibilities = (max - min) + (exclude_end ? 0 : 1)
102
+ raise ArgumentError, "given range `#{ulid_range.inspect}` does not have possibilities" unless possibilities.positive?
100
103
 
101
- -> {
102
- SecureRandom.random_number(possibilities) + min
103
- }
104
- else
105
- RANDOM_INTEGER_GENERATOR
106
- end
104
+ -> {
105
+ SecureRandom.random_number(possibilities) + min
106
+ }
107
+ else
108
+ RANDOM_INTEGER_GENERATOR
109
+ end
110
+ )
107
111
 
108
112
  case args.size
109
113
  when 0
@@ -134,6 +138,7 @@ class ULID
134
138
  string = String.try_convert(string)
135
139
  raise ArgumentError, 'ULID.scan takes only strings' unless string
136
140
  return to_enum(__callee__, string) unless block_given?
141
+
137
142
  string.scan(SCANNING_PATTERN) do |matched|
138
143
  yield parse(matched)
139
144
  end
@@ -156,7 +161,7 @@ class ULID
156
161
  milliseconds = n32encoded_timestamp.to_i(32)
157
162
  entropy = n32encoded_randomness.to_i(32)
158
163
 
159
- new milliseconds: milliseconds, entropy: entropy, integer: integer
164
+ new(milliseconds: milliseconds, entropy: entropy, integer: integer)
160
165
  end
161
166
 
162
167
  # @param [Range<Time>, Range<nil>, Range[ULID]] period
@@ -164,6 +169,7 @@ class ULID
164
169
  # @raise [ArgumentError] if the given period is not a `Range[Time]`, `Range[nil]` or `Range[ULID]`
165
170
  def self.range(period)
166
171
  raise ArgumentError, 'ULID.range takes only `Range[Time]`, `Range[nil]` or `Range[ULID]`' unless Range === period
172
+
167
173
  begin_element, end_element, exclude_end = period.begin, period.end, period.exclude_end?
168
174
  return period if self === begin_element && self === end_element
169
175
 
@@ -180,11 +186,7 @@ class ULID
180
186
 
181
187
  case end_element
182
188
  when Time
183
- if exclude_end
184
- end_ulid = min(end_element)
185
- else
186
- end_ulid = max(end_element)
187
- end
189
+ end_ulid = exclude_end ? min(end_element) : max(end_element)
188
190
  when nil
189
191
  # The end should be max and include end, because nil end means to cover endless ULIDs until the limit
190
192
  end_ulid = MAX
@@ -206,11 +208,7 @@ class ULID
206
208
  def self.floor(time)
207
209
  raise ArgumentError, 'ULID.floor takes only `Time` instance' unless Time === time
208
210
 
209
- if RUBY_VERSION >= '2.7'
210
- time.floor(3)
211
- else
212
- Time.at(0, milliseconds_from_time(time), :millisecond)
213
- end
211
+ time.floor(3)
214
212
  end
215
213
 
216
214
  # @api private
@@ -310,8 +308,19 @@ class ULID
310
308
  private_class_method def self.safe_get_class_name(object)
311
309
  fallback = 'UnknownObject'
312
310
 
311
+ # This class getter implementation used https://github.com/rspec/rspec-support/blob/4ad8392d0787a66f9c351d9cf6c7618e18b3d0f2/lib/rspec/support.rb#L83-L89 as a reference, thank you!
312
+ # ref: https://twitter.com/_kachick/status/1400064896759304196
313
+ klass = (
314
+ begin
315
+ object.class
316
+ rescue NoMethodError
317
+ singleton_class = class << object; self; end
318
+ singleton_class.ancestors.detect { |ancestor| !ancestor.equal?(singleton_class) }
319
+ end
320
+ )
321
+
313
322
  begin
314
- name = String.try_convert(object.class.name)
323
+ name = String.try_convert(klass.name)
315
324
  rescue Exception
316
325
  fallback
317
326
  else
@@ -335,7 +344,7 @@ class ULID
335
344
  n32encoded_randomness = entropy.to_s(32).rjust(RANDOMNESS_ENCODED_LENGTH, '0')
336
345
  integer = (n32encoded_timestamp + n32encoded_randomness).to_i(32)
337
346
 
338
- new milliseconds: milliseconds, entropy: entropy, integer: integer
347
+ new(milliseconds: milliseconds, entropy: entropy, integer: integer)
339
348
  end
340
349
 
341
350
  attr_reader :milliseconds, :entropy
@@ -393,20 +402,14 @@ class ULID
393
402
 
394
403
  # @return [Time]
395
404
  def to_time
396
- @time ||= begin
397
- if RUBY_VERSION >= '2.7'
398
- Time.at(0, @milliseconds, :millisecond, in: 'UTC').freeze
399
- else
400
- Time.at(0, @milliseconds, :millisecond).utc.freeze
401
- end
402
- end
405
+ @time ||= Time.at(0, @milliseconds, :millisecond, in: 'UTC').freeze
403
406
  end
404
407
 
405
408
  # @return [Array(Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer, Integer)]
406
409
  def octets
407
410
  digits = @integer.digits(256)
408
411
  (OCTETS_LENGTH - digits.size).times do
409
- digits.push 0
412
+ digits.push(0)
410
413
  end
411
414
  digits.reverse!
412
415
  end
@@ -477,6 +480,20 @@ class ULID
477
480
  super
478
481
  end
479
482
 
483
+ # @api private
484
+ # @return [Integer]
485
+ def marshal_dump
486
+ @integer
487
+ end
488
+
489
+ # @api private
490
+ # @param [Integer] integer
491
+ # @return [void]
492
+ def marshal_load(integer)
493
+ unmarshaled = ULID.from_integer(integer)
494
+ initialize(integer: unmarshaled.to_i, milliseconds: unmarshaled.milliseconds, entropy: unmarshaled.entropy)
495
+ end
496
+
480
497
  # @return [self]
481
498
  def to_ulid
482
499
  self
data/sig/ulid.rbs CHANGED
@@ -43,16 +43,16 @@ class ULID < Object
43
43
  CROCKFORD_BASE32_CHAR_PATTERN: Regexp
44
44
  CROCKFORD_BASE32_CHAR_BY_N32_CHAR: Hash[String, String]
45
45
  N32_CHAR_PATTERN: Regexp
46
- VARIANT_BY_STANDARD: Hash[String, String]
46
+ STANDARD_BY_VARIANT: Hash[String, String]
47
47
  VARIANT_PATTERN: Regexp
48
48
 
49
- # A pribate API. Should not be used in your code.
49
+ # A private API. Should not be used in your code.
50
50
  def self.encode: (Integer integer) -> String
51
51
 
52
- # A pribate API. Should not be used in your code.
52
+ # A private API. Should not be used in your code.
53
53
  def self.decode: (String string) -> Integer
54
54
 
55
- # A pribate API. Should not be used in your code.
55
+ # A private API. Should not be used in your code.
56
56
  def self.normalize: (String string) -> String
57
57
  end
58
58
 
@@ -71,7 +71,7 @@ class ULID < Object
71
71
  # ```
72
72
  attr_reader prev: ULID | nil
73
73
 
74
- # A pribate API. Should not be used in your code.
74
+ # A private API. Should not be used in your code.
75
75
  def initialize: -> void
76
76
 
77
77
  # 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)
@@ -143,7 +143,7 @@ class ULID < Object
143
143
  #
144
144
  # If you want to keep sortable even if in same timestamp, See also [ULID::MonotonicGenerator](https://github.com/kachick/ruby-ulid#how-to-keep-sortable-even-if-in-same-timestamp)
145
145
  #
146
- def self.generate: (?moment: moment, ?entropy: Integer) -> self
146
+ def self.generate: (?moment: moment, ?entropy: Integer) -> ULID
147
147
 
148
148
  # Shorthand of `ULID.generate(moment: Time)`
149
149
  # See also [ULID.generate](https://kachick.github.io/ruby-ulid/ULID.html#generate-class_method)
@@ -157,12 +157,12 @@ class ULID < Object
157
157
  # end
158
158
  # ulids.sort == ulids #=> true
159
159
  # ```
160
- def self.at: (Time time) -> self
160
+ def self.at: (Time time) -> ULID
161
161
 
162
- # A pribate API. Should not be used in your code.
162
+ # A private API. Should not be used in your code.
163
163
  def self.current_milliseconds: -> Integer
164
164
 
165
- # A pribate API. Should not be used in your code.
165
+ # A private API. Should not be used in your code.
166
166
  def self.milliseconds_from_moment: (moment moment) -> Integer
167
167
 
168
168
  # `ULID` can be element of the `Range`. If you generated the IDs in monotonic generator, ID based filtering is easy and reliable
@@ -185,8 +185,7 @@ class ULID < Object
185
185
  #
186
186
  # # Below patterns are acceptable
187
187
  # pinpointing = ULID.range(time1..time1) #=> This will match only for all IDs in `time1`
188
- # until_the_end = ULID.range(..time1) #=> This will match only for all IDs upto `time1` (The `nil` starting `Range` can be used since Ruby 2.7)
189
- # until_the_end = ULID.range(ULID.min.to_time..time1) #=> This is same as above for Ruby 2.6
188
+ # until_the_end = ULID.range(..time1) #=> This will match only for all IDs upto `time1`
190
189
  # until_the_ulid_limit = ULID.range(time1..) # This will match only for all IDs from `time1` to max value of the ULID limit
191
190
  #
192
191
  # # So you can use the generated range objects as below
@@ -212,7 +211,7 @@ class ULID < Object
212
211
  # ulid = ULID.parse('01ARZ3NDEKTSV4RRFFQ69G5FAV')
213
212
  # #=> ULID(2016-07-30 23:54:10.259 UTC: 01ARZ3NDEKTSV4RRFFQ69G5FAV)
214
213
  # ```
215
- def self.parse: (_ToStr string) -> self
214
+ def self.parse: (_ToStr string) -> ULID
216
215
 
217
216
  # ```ruby
218
217
  # # Currently experimental feature, so needed to load the extension.
@@ -226,7 +225,7 @@ class ULID < Object
226
225
  #
227
226
  # See also [Why this is experimental?](https://github.com/kachick/ruby-ulid/issues/76)
228
227
  def self.from_uuidv4: (String uuid) -> ULID
229
- def self.from_integer: (Integer integer) -> self
228
+ def self.from_integer: (Integer integer) -> ULID
230
229
 
231
230
  # Returns termination values for ULID spec.
232
231
  #
@@ -318,8 +317,8 @@ class ULID < Object
318
317
  # # ULID(2021-04-28 16:49:06.484 UTC: 01F4CP4PDM214Q6H3KJP7DYJRR),
319
318
  # # ULID(2021-04-28 15:05:06.808 UTC: 01F4CG68ZRST94T056KRZ5K9S4)]
320
319
  # ```
321
- def self.sample: (?period: period) -> self
322
- | (Integer number, ?period: period) -> Array[self]
320
+ def self.sample: (?period: period) -> ULID
321
+ | (Integer number, ?period: period) -> Array[ULID]
323
322
  def self.valid?: (untyped) -> bool
324
323
 
325
324
  # Returns normalized string
@@ -384,8 +383,8 @@ class ULID < Object
384
383
  # # ULID(2021-04-30 05:53:12.478 UTC: 01F4GND4RYYSKNAADHQ9BNXAWJ)]
385
384
  # ```
386
385
  def self.scan: (_ToStr string) -> Enumerator[self, singleton(ULID)]
387
- | (_ToStr string) { (self ulid) -> void } -> singleton(ULID)
388
- def self.from_milliseconds_and_entropy: (milliseconds: Integer, entropy: Integer) -> self
386
+ | (_ToStr string) { (ULID ulid) -> void } -> singleton(ULID)
387
+ def self.from_milliseconds_and_entropy: (milliseconds: Integer, entropy: Integer) -> ULID
389
388
  def self.try_convert: (_ToULID) -> ULID
390
389
  | (untyped) -> nil
391
390
 
@@ -507,6 +506,12 @@ class ULID < Object
507
506
  def pred: -> ULID?
508
507
  def freeze: -> self
509
508
 
509
+ # A private API. Should not be used in your code.
510
+ def marshal_dump: -> Integer
511
+
512
+ # A private API. Should not be used in your code.
513
+ def marshal_load: (Integer integer) -> void
514
+
510
515
  # Returns `self`
511
516
  def to_ulid: -> self
512
517
 
@@ -519,21 +524,21 @@ class ULID < Object
519
524
 
520
525
  private
521
526
 
522
- # A pribate API. Should not be used in your code.
527
+ # A private API. Should not be used in your code.
523
528
  def self.new: (milliseconds: Integer, entropy: Integer, integer: Integer) -> self
524
529
 
525
- # A pribate API. Should not be used in your code.
530
+ # A private API. Should not be used in your code.
526
531
  def self.reasonable_entropy: -> Integer
527
532
 
528
- # A pribate API. Should not be used in your code.
533
+ # A private API. Should not be used in your code.
529
534
  def self.milliseconds_from_time: (Time time) -> Integer
530
535
 
531
- # A pribate API. Should not be used in your code.
536
+ # A private API. Should not be used in your code.
532
537
  def self.safe_get_class_name: (untyped object) -> String
533
538
 
534
- # A pribate API. Should not be used in your code.
539
+ # A private API. Should not be used in your code.
535
540
  def initialize: (milliseconds: Integer, entropy: Integer, integer: Integer) -> void
536
541
 
537
- # A pribate API. Should not be used in your code.
542
+ # A private API. Should not be used in your code.
538
543
  def cache_all_instance_variables: -> void
539
544
  end
metadata CHANGED
@@ -1,265 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ulid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.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: 2021-05-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: test-unit
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 3.4.1
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '4.0'
23
- type: :development
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 3.4.1
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '4.0'
33
- - !ruby/object:Gem::Dependency
34
- name: irb
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 1.3.5
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '2.0'
43
- type: :development
44
- prerelease: false
45
- version_requirements: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 1.3.5
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '2.0'
53
- - !ruby/object:Gem::Dependency
54
- name: irb-power_assert
55
- requirement: !ruby/object:Gem::Requirement
56
- requirements:
57
- - - '='
58
- - !ruby/object:Gem::Version
59
- version: 0.0.2
60
- type: :development
61
- prerelease: false
62
- version_requirements: !ruby/object:Gem::Requirement
63
- requirements:
64
- - - '='
65
- - !ruby/object:Gem::Version
66
- version: 0.0.2
67
- - !ruby/object:Gem::Dependency
68
- name: warning
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: 1.2.0
74
- - - "<"
75
- - !ruby/object:Gem::Version
76
- version: '2.0'
77
- type: :development
78
- prerelease: false
79
- version_requirements: !ruby/object:Gem::Requirement
80
- requirements:
81
- - - ">="
82
- - !ruby/object:Gem::Version
83
- version: 1.2.0
84
- - - "<"
85
- - !ruby/object:Gem::Version
86
- version: '2.0'
87
- - !ruby/object:Gem::Dependency
88
- name: rbs
89
- requirement: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: 1.2.0
94
- - - "<"
95
- - !ruby/object:Gem::Version
96
- version: '2.0'
97
- type: :development
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: 1.2.0
104
- - - "<"
105
- - !ruby/object:Gem::Version
106
- version: '2.0'
107
- - !ruby/object:Gem::Dependency
108
- name: rake
109
- requirement: !ruby/object:Gem::Requirement
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- version: 13.0.3
114
- - - "<"
115
- - !ruby/object:Gem::Version
116
- version: '20.0'
117
- type: :development
118
- prerelease: false
119
- version_requirements: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: 13.0.3
124
- - - "<"
125
- - !ruby/object:Gem::Version
126
- version: '20.0'
127
- - !ruby/object:Gem::Dependency
128
- name: benchmark-ips
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: 2.8.4
134
- - - "<"
135
- - !ruby/object:Gem::Version
136
- version: '3'
137
- type: :development
138
- prerelease: false
139
- version_requirements: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: 2.8.4
144
- - - "<"
145
- - !ruby/object:Gem::Version
146
- version: '3'
147
- - !ruby/object:Gem::Dependency
148
- name: yard
149
- requirement: !ruby/object:Gem::Requirement
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- version: 0.9.26
154
- - - "<"
155
- - !ruby/object:Gem::Version
156
- version: '2'
157
- type: :development
158
- prerelease: false
159
- version_requirements: !ruby/object:Gem::Requirement
160
- requirements:
161
- - - ">="
162
- - !ruby/object:Gem::Version
163
- version: 0.9.26
164
- - - "<"
165
- - !ruby/object:Gem::Version
166
- version: '2'
167
- - !ruby/object:Gem::Dependency
168
- name: steep
169
- requirement: !ruby/object:Gem::Requirement
170
- requirements:
171
- - - ">="
172
- - !ruby/object:Gem::Version
173
- version: 0.44.1
174
- - - "<"
175
- - !ruby/object:Gem::Version
176
- version: 0.50.0
177
- type: :development
178
- prerelease: false
179
- version_requirements: !ruby/object:Gem::Requirement
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- version: 0.44.1
184
- - - "<"
185
- - !ruby/object:Gem::Version
186
- version: 0.50.0
187
- - !ruby/object:Gem::Dependency
188
- name: rubocop
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - ">="
192
- - !ruby/object:Gem::Version
193
- version: 1.14.0
194
- - - "<"
195
- - !ruby/object:Gem::Version
196
- version: 1.15.0
197
- type: :development
198
- prerelease: false
199
- version_requirements: !ruby/object:Gem::Requirement
200
- requirements:
201
- - - ">="
202
- - !ruby/object:Gem::Version
203
- version: 1.14.0
204
- - - "<"
205
- - !ruby/object:Gem::Version
206
- version: 1.15.0
207
- - !ruby/object:Gem::Dependency
208
- name: rubocop-rake
209
- requirement: !ruby/object:Gem::Requirement
210
- requirements:
211
- - - ">="
212
- - !ruby/object:Gem::Version
213
- version: '0'
214
- type: :development
215
- prerelease: false
216
- version_requirements: !ruby/object:Gem::Requirement
217
- requirements:
218
- - - ">="
219
- - !ruby/object:Gem::Version
220
- version: '0'
221
- - !ruby/object:Gem::Dependency
222
- name: rubocop-performance
223
- requirement: !ruby/object:Gem::Requirement
224
- requirements:
225
- - - ">="
226
- - !ruby/object:Gem::Version
227
- version: '0'
228
- type: :development
229
- prerelease: false
230
- version_requirements: !ruby/object:Gem::Requirement
231
- requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- version: '0'
235
- - !ruby/object:Gem::Dependency
236
- name: rubocop-rubycw
237
- requirement: !ruby/object:Gem::Requirement
238
- requirements:
239
- - - ">="
240
- - !ruby/object:Gem::Version
241
- version: '0'
242
- type: :development
243
- prerelease: false
244
- version_requirements: !ruby/object:Gem::Requirement
245
- requirements:
246
- - - ">="
247
- - !ruby/object:Gem::Version
248
- version: '0'
249
- - !ruby/object:Gem::Dependency
250
- name: rubocop-md
251
- requirement: !ruby/object:Gem::Requirement
252
- requirements:
253
- - - ">="
254
- - !ruby/object:Gem::Version
255
- version: '0'
256
- type: :development
257
- prerelease: false
258
- version_requirements: !ruby/object:Gem::Requirement
259
- requirements:
260
- - - ">="
261
- - !ruby/object:Gem::Version
262
- version: '0'
11
+ date: 2022-05-13 00:00:00.000000000 Z
12
+ dependencies: []
263
13
  description: |2
264
14
  The ULID(Universally Unique Lexicographically Sortable Identifier) has useful specs for applications (e.g. `Database key`), especially possess all `uniqueness`, `randomness`, `extractable timestamps` and `sortable` features.
265
15
  This gem aims to provide the generator, monotonic generator, parser and handy manipulation features around the ULID.
@@ -270,8 +20,9 @@ executables: []
270
20
  extensions: []
271
21
  extra_rdoc_files: []
272
22
  files:
273
- - LICENSE
23
+ - LICENSE.txt
274
24
  - README.md
25
+ - lib/ruby-ulid.rb
275
26
  - lib/ulid.rb
276
27
  - lib/ulid/crockford_base32.rb
277
28
  - lib/ulid/monotonic_generator.rb
@@ -285,7 +36,9 @@ metadata:
285
36
  documentation_uri: https://kachick.github.io/ruby-ulid/
286
37
  homepage_uri: https://github.com/kachick/ruby-ulid
287
38
  source_code_uri: https://github.com/kachick/ruby-ulid
288
- post_install_message:
39
+ bug_tracker_uri: https://github.com/kachick/ruby-ulid/issues
40
+ rubygems_mfa_required: 'true'
41
+ post_install_message:
289
42
  rdoc_options: []
290
43
  require_paths:
291
44
  - lib
@@ -293,15 +46,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
293
46
  requirements:
294
47
  - - ">="
295
48
  - !ruby/object:Gem::Version
296
- version: 2.6.0
49
+ version: 2.7.0
297
50
  required_rubygems_version: !ruby/object:Gem::Requirement
298
51
  requirements:
299
52
  - - ">="
300
53
  - !ruby/object:Gem::Version
301
54
  version: '0'
302
55
  requirements: []
303
- rubygems_version: 3.2.15
304
- signing_key:
56
+ rubygems_version: 3.3.7
57
+ signing_key:
305
58
  specification_version: 4
306
- summary: A handy ULID library
59
+ summary: ULID manipulation library
307
60
  test_files: []