ruby-ulid 0.7.0 → 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.
- checksums.yaml +4 -4
- data/README.md +63 -95
- data/lib/ulid/crockford_base32.rb +12 -12
- data/lib/ulid/errors.rb +1 -0
- data/lib/ulid/monotonic_generator.rb +14 -14
- data/lib/ulid/utils.rb +6 -24
- data/lib/ulid/uuid.rb +61 -31
- data/lib/ulid/version.rb +1 -1
- data/lib/ulid.rb +102 -116
- data/sig/ulid.rbs +137 -88
- metadata +7 -7
    
        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,7 +12,6 @@ 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
         | 
| @@ -34,9 +31,37 @@ class ULID < Object | |
| 34 31 | 
             
              class UnexpectedError < Error
         | 
| 35 32 | 
             
              end
         | 
| 36 33 |  | 
| 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
         | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 37 62 | 
             
              # Private module
         | 
| 38 63 | 
             
              module Utils
         | 
| 39 | 
            -
                def self. | 
| 64 | 
            +
                def self.encode_base32hex: (milliseconds: milliseconds, entropy: Integer) -> String
         | 
| 40 65 |  | 
| 41 66 | 
             
                def self.current_milliseconds: -> milliseconds
         | 
| 42 67 |  | 
| @@ -48,9 +73,7 @@ class ULID < Object | |
| 48 73 |  | 
| 49 74 | 
             
                def self.safe_get_class_name: (untyped object) -> String
         | 
| 50 75 |  | 
| 51 | 
            -
                def self. | 
| 52 | 
            -
             | 
| 53 | 
            -
                def self.make_sharable_constantans: (Module) -> void
         | 
| 76 | 
            +
                def self.make_sharable_constants: (Module) -> void
         | 
| 54 77 |  | 
| 55 78 | 
             
                def self.ractor_can_make_shareable_time?: -> bool
         | 
| 56 79 | 
             
              end
         | 
| @@ -59,7 +82,7 @@ class ULID < Object | |
| 59 82 | 
             
              module CrockfordBase32
         | 
| 60 83 | 
             
                ENCODING_STRING: String
         | 
| 61 84 | 
             
                CROCKFORD_TR_PATTERN: String
         | 
| 62 | 
            -
                 | 
| 85 | 
            +
                BASE32HEX_TR_PATTERN: String
         | 
| 63 86 | 
             
                VARIANT_TR_PATTERN: String
         | 
| 64 87 | 
             
                NORMALIZED_TR_PATTERN: String
         | 
| 65 88 |  | 
| @@ -69,67 +92,60 @@ class ULID < Object | |
| 69 92 |  | 
| 70 93 | 
             
                def self.normalize: (String string) -> String
         | 
| 71 94 |  | 
| 72 | 
            -
                def self. | 
| 95 | 
            +
                def self.from_base32hex: (String base32hex) -> String
         | 
| 73 96 | 
             
              end
         | 
| 74 97 |  | 
| 75 98 | 
             
              class MonotonicGenerator
         | 
| 76 99 | 
             
                include MonitorMixin
         | 
| 77 100 |  | 
| 78 | 
            -
                # Returned value is `basically not` Thread-safety
         | 
| 101 | 
            +
                # Returned value is `basically not` Thread-safety\
         | 
| 79 102 | 
             
                # If you want to keep Thread-safety, keep to call {#generate} only in same {#synchronize} block
         | 
| 80 103 | 
             
                #
         | 
| 81 104 | 
             
                # ```ruby
         | 
| 82 105 | 
             
                # generator.synchronize do
         | 
| 83 | 
            -
                #   generator. | 
| 106 | 
            +
                #   generator.last
         | 
| 84 107 | 
             
                #   generator.inspect
         | 
| 85 108 | 
             
                #   generator.generate
         | 
| 86 109 | 
             
                # end
         | 
| 87 110 | 
             
                # ```
         | 
| 88 | 
            -
                attr_reader  | 
| 111 | 
            +
                attr_reader last: ULID | nil
         | 
| 89 112 |  | 
| 90 | 
            -
                # 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)\
         | 
| 91 114 | 
             
                # The `Thread-safety` is implemented with [Monitor](https://bugs.ruby-lang.org/issues/16255)
         | 
| 92 115 | 
             
                def generate: (?moment: moment) -> ULID
         | 
| 93 116 |  | 
| 94 117 | 
             
                # Just providing similar api as `ULID.generate` and `ULID.encode` relation. No performance benefit exists in monotonic generator's one.
         | 
| 95 118 | 
             
                def encode: (?moment: moment) -> String
         | 
| 96 119 |  | 
| 97 | 
            -
                # Returned value is `basically not` Thread-safety
         | 
| 120 | 
            +
                # Returned value is `basically not` Thread-safety\
         | 
| 98 121 | 
             
                # If you want to keep Thread-safety, keep to call {#generate} only in same {#synchronize} block
         | 
| 99 122 | 
             
                #
         | 
| 100 123 | 
             
                # ```ruby
         | 
| 101 124 | 
             
                # generator.synchronize do
         | 
| 102 | 
            -
                #   generator. | 
| 125 | 
            +
                #   generator.last
         | 
| 103 126 | 
             
                #   generator.inspect
         | 
| 104 127 | 
             
                #   generator.generate
         | 
| 105 128 | 
             
                # end
         | 
| 106 129 | 
             
                # ```
         | 
| 107 130 | 
             
                def inspect: -> String
         | 
| 108 131 | 
             
                alias to_s inspect
         | 
| 109 | 
            -
                def freeze: -> void
         | 
| 110 132 |  | 
| 111 133 | 
             
                private
         | 
| 112 134 |  | 
| 113 135 | 
             
                def initialize: -> void
         | 
| 114 136 |  | 
| 115 | 
            -
                def  | 
| 137 | 
            +
                def last=: (ULID?) -> void
         | 
| 116 138 | 
             
              end
         | 
| 117 139 |  | 
| 118 140 | 
             
              interface _ToULID
         | 
| 119 141 | 
             
                def to_ulid: () -> ULID
         | 
| 120 142 | 
             
              end
         | 
| 121 143 |  | 
| 122 | 
            -
              type  | 
| 123 | 
            -
              type timestamp_octets = [Integer, Integer, Integer, Integer, Integer, Integer] | Array[Integer]
         | 
| 124 | 
            -
              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]
         | 
| 125 145 | 
             
              type period = Range[Time] | Range[nil] | Range[ULID]
         | 
| 126 146 |  | 
| 127 147 | 
             
              @integer: Integer
         | 
| 128 148 | 
             
              @encoded: String
         | 
| 129 | 
            -
              @timestamp: String?
         | 
| 130 | 
            -
              @randomness: String?
         | 
| 131 | 
            -
              @inspect: String?
         | 
| 132 | 
            -
              @time: Time?
         | 
| 133 149 |  | 
| 134 150 | 
             
              # Retuns a ULID
         | 
| 135 151 | 
             
              #
         | 
| @@ -167,14 +183,13 @@ class ULID < Object | |
| 167 183 | 
             
              #
         | 
| 168 184 | 
             
              def self.generate: (?moment: moment, ?entropy: Integer) -> ULID
         | 
| 169 185 |  | 
| 170 | 
            -
              # Retuns encoded and normalzied String | 
| 171 | 
            -
              # It has same arguments signatures as `.generate | 
| 172 | 
            -
              #
         | 
| 173 | 
            -
              # 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.
         | 
| 174 189 | 
             
              #
         | 
| 175 190 | 
             
              def self.encode: (?moment: moment, ?entropy: Integer) -> String
         | 
| 176 191 |  | 
| 177 | 
            -
              # Shorthand of `ULID.generate(moment: Time) | 
| 192 | 
            +
              # Shorthand of `ULID.generate(moment: Time)`\
         | 
| 178 193 | 
             
              # See also [ULID.generate](https://kachick.github.io/ruby-ulid/ULID.html#generate-class_method)
         | 
| 179 194 | 
             
              #
         | 
| 180 195 | 
             
              # ```ruby
         | 
| @@ -188,7 +203,8 @@ class ULID < Object | |
| 188 203 | 
             
              # ```
         | 
| 189 204 | 
             
              def self.at: (Time time) -> ULID
         | 
| 190 205 |  | 
| 191 | 
            -
              # `ULID` can be element of the `Range | 
| 206 | 
            +
              # `ULID` can be element of the `Range`.\
         | 
| 207 | 
            +
              # If you generated the IDs in monotonic generator, ID based filtering is easy and reliable
         | 
| 192 208 | 
             
              #
         | 
| 193 209 | 
             
              # ```ruby
         | 
| 194 210 | 
             
              # include_end = ulid1..ulid2
         | 
| @@ -236,16 +252,18 @@ class ULID < Object | |
| 236 252 | 
             
              # ```
         | 
| 237 253 | 
             
              def self.parse: (_ToStr string) -> ULID
         | 
| 238 254 |  | 
| 239 | 
            -
               | 
| 255 | 
            +
              type time_in = String | Integer | nil
         | 
| 256 | 
            +
             | 
| 257 | 
            +
              # Return Time instance from encoded String.\
         | 
| 240 258 | 
             
              # See also `ULID.encode` for similar purpose.
         | 
| 241 259 | 
             
              #
         | 
| 242 | 
            -
              # NOTE: Difference of ULID#to_time, returned Time is NOT frozen.
         | 
| 243 | 
            -
              #
         | 
| 244 260 | 
             
              # ```ruby
         | 
| 245 261 | 
             
              # time = ULID.decode_time('01ARZ3NDEKTSV4RRFFQ69G5FAV')
         | 
| 246 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
         | 
| 247 265 | 
             
              # ```
         | 
| 248 | 
            -
              def self.decode_time: (_ToStr string, ?in:  | 
| 266 | 
            +
              def self.decode_time: (_ToStr string, ?in: time_in) -> Time
         | 
| 249 267 |  | 
| 250 268 | 
             
              # Get ULID instance from unnormalized String that encoded in Crockford's base32.
         | 
| 251 269 | 
             
              #
         | 
| @@ -262,18 +280,35 @@ class ULID < Object | |
| 262 280 | 
             
              # See also [ulid/spec#57](https://github.com/ulid/spec/pull/57) and [ulid/spec#3](https://github.com/ulid/spec/issues/3)
         | 
| 263 281 | 
             
              def self.parse_variant_format: (_ToStr string) -> ULID
         | 
| 264 282 |  | 
| 283 | 
            +
              # Load a UUID-like string without checking version and variants.
         | 
| 284 | 
            +
              #
         | 
| 265 285 | 
             
              # ```ruby
         | 
| 266 | 
            -
              #  | 
| 267 | 
            -
              #  | 
| 286 | 
            +
              # ULID.from_uuidish('123e4567-e89b-12d3-a456-426614174000')
         | 
| 287 | 
            +
              # #=> ULID(2605-08-20 10:28:29.979 UTC: 0J7S2PFT4V2B9T8NJ2CRA1EG00)
         | 
| 288 | 
            +
              # ```
         | 
| 289 | 
            +
              #
         | 
| 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.
         | 
| 268 294 | 
             
              #
         | 
| 269 | 
            -
              #  | 
| 270 | 
            -
              #  | 
| 295 | 
            +
              # ```ruby
         | 
| 296 | 
            +
              # ULID.from_uuidv4('0983d0a2-ff15-4d83-8f37-7dd945b5aa39')
         | 
| 271 297 | 
             
              # #=> ULID(2301-07-10 00:28:28.821 UTC: 09GF8A5ZRN9P1RYDVXV52VBAHS)
         | 
| 272 | 
            -
              #  | 
| 298 | 
            +
              # ULID.from_uuidv4('123e4567-e89b-12d3-a456-426614174000')
         | 
| 299 | 
            +
              # #=> ULID::ParserError
         | 
| 273 300 | 
             
              # ```
         | 
| 274 301 | 
             
              #
         | 
| 275 | 
            -
              # See also [ | 
| 302 | 
            +
              # See also [ULID.from_uuidish]
         | 
| 276 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 | 
            +
              # ```
         | 
| 277 312 | 
             
              def self.from_integer: (Integer integer) -> ULID
         | 
| 278 313 |  | 
| 279 314 | 
             
              # Returns termination values for ULID spec.
         | 
| @@ -334,7 +369,8 @@ class ULID < Object | |
| 334 369 | 
             
              # # ULID(2665-03-16 14:50:22.724 UTC: 0KYFW9DWM4CEGFNTAC6YFAVVJ6)]
         | 
| 335 370 | 
             
              # ```
         | 
| 336 371 | 
             
              #
         | 
| 337 | 
            -
              # You can specify a range object for the timestamp restriction | 
| 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)
         | 
| 338 374 | 
             
              #
         | 
| 339 375 | 
             
              # ```ruby
         | 
| 340 376 | 
             
              # ulid1 = ULID.parse('01F4A5Y1YAQCYAYCTC7GRMJ9AA') #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
         | 
| @@ -395,19 +431,6 @@ class ULID < Object | |
| 395 431 | 
             
              def self.valid_as_variant_format?: (_ToStr string) -> bool
         | 
| 396 432 | 
             
                                         | (untyped) -> false
         | 
| 397 433 |  | 
| 398 | 
            -
              # DEPRECATED Use valid_as_variant_format? instead
         | 
| 399 | 
            -
              #
         | 
| 400 | 
            -
              # Returns `true` if it is normalized string.
         | 
| 401 | 
            -
              # Basically the difference of normalized? is to accept downcase or not. This returns true for downcased ULIDs.
         | 
| 402 | 
            -
              #
         | 
| 403 | 
            -
              # ```ruby
         | 
| 404 | 
            -
              # ULID.valid?(ULID.generate.to_s.downcase) #=> true
         | 
| 405 | 
            -
              # ```
         | 
| 406 | 
            -
              #
         | 
| 407 | 
            -
              # See also [ulid/spec#57](https://github.com/ulid/spec/pull/57) and [ulid/spec#3](https://github.com/ulid/spec/issues/3)
         | 
| 408 | 
            -
              def self.valid?: (_ToStr string) -> bool
         | 
| 409 | 
            -
                             | (untyped) -> false
         | 
| 410 | 
            -
             | 
| 411 434 | 
             
              # Returns parsed ULIDs from given String for rough operations.
         | 
| 412 435 | 
             
              #
         | 
| 413 436 | 
             
              # ```ruby
         | 
| @@ -450,6 +473,7 @@ class ULID < Object | |
| 450 473 | 
             
              def self.scan:  (_ToStr string) -> Enumerator[self, singleton(ULID)]
         | 
| 451 474 | 
             
                            | (_ToStr string) { (ULID ulid) -> void } -> singleton(ULID)
         | 
| 452 475 |  | 
| 476 | 
            +
              # Returns nil if given object is not a ULID
         | 
| 453 477 | 
             
              def self.try_convert: (_ToULID) -> ULID
         | 
| 454 478 | 
             
                                  | (untyped) -> nil
         | 
| 455 479 |  | 
| @@ -459,14 +483,16 @@ class ULID < Object | |
| 459 483 | 
             
              # ulid.milliseconds #=> 1619544442826
         | 
| 460 484 | 
             
              # ```
         | 
| 461 485 | 
             
              attr_reader milliseconds: Integer
         | 
| 486 | 
            +
             | 
| 462 487 | 
             
              attr_reader entropy: Integer
         | 
| 463 488 |  | 
| 489 | 
            +
              # Private api. (Actually defined protected visibility)
         | 
| 490 | 
            +
              attr_reader encoded: String
         | 
| 491 | 
            +
             | 
| 464 492 | 
             
              # ```ruby
         | 
| 465 493 | 
             
              # ulid = ULID.generate
         | 
| 466 494 | 
             
              # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
         | 
| 467 495 | 
             
              # ulid.encode #=> "01F4A5Y1YAQCYAYCTC7GRMJ9AA"
         | 
| 468 | 
            -
              # ulid.encode.frozen? #=> true
         | 
| 469 | 
            -
              # ulid.encode.equal?(ulid.to_s) #=> true
         | 
| 470 496 | 
             
              # ```
         | 
| 471 497 | 
             
              def encode: -> String
         | 
| 472 498 | 
             
              alias to_s encode
         | 
| @@ -489,7 +515,7 @@ class ULID < Object | |
| 489 515 | 
             
              # #=> true
         | 
| 490 516 | 
             
              # ```
         | 
| 491 517 | 
             
              #
         | 
| 492 | 
            -
              # 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.\
         | 
| 493 519 | 
             
              # So preferable than `lexicographically sortable` in actual case.
         | 
| 494 520 | 
             
              #
         | 
| 495 521 | 
             
              # This returns -1 | 0 | 1 for ULIDs. However defined as returning Integer. It is caused on ruby/rbs current definition.
         | 
| @@ -499,6 +525,8 @@ class ULID < Object | |
| 499 525 | 
             
              def <=>: (ULID other) -> Integer
         | 
| 500 526 | 
             
                     | (untyped other) -> nil
         | 
| 501 527 |  | 
| 528 | 
            +
              # Returns human readable strings that used by Kernel.#p
         | 
| 529 | 
            +
              #
         | 
| 502 530 | 
             
              # ```ruby
         | 
| 503 531 | 
             
              # ulid = ULID.generate
         | 
| 504 532 | 
             
              # ulid.inspect #=> "ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)"
         | 
| @@ -513,7 +541,7 @@ class ULID < Object | |
| 513 541 | 
             
                      | (untyped other) -> false
         | 
| 514 542 | 
             
              alias == eql?
         | 
| 515 543 |  | 
| 516 | 
            -
              # 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).\
         | 
| 517 545 | 
             
              # Do not consider integer, octets and partial strings, then returns `false`.
         | 
| 518 546 | 
             
              #
         | 
| 519 547 | 
             
              # ```ruby
         | 
| @@ -533,12 +561,15 @@ class ULID < Object | |
| 533 561 | 
             
                     | (untyped other) -> false
         | 
| 534 562 |  | 
| 535 563 | 
             
              # ```ruby
         | 
| 536 | 
            -
              #  | 
| 537 | 
            -
              # #=>  | 
| 538 | 
            -
              #  | 
| 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
         | 
| 539 568 | 
             
              # ```
         | 
| 540 | 
            -
              def to_time: -> Time
         | 
| 569 | 
            +
              def to_time: (?in: time_in) -> Time
         | 
| 541 570 |  | 
| 571 | 
            +
              # Returns timestamp(prefix) part of encoded ULID
         | 
| 572 | 
            +
              #
         | 
| 542 573 | 
             
              # ```ruby
         | 
| 543 574 | 
             
              # ulid = ULID.generate
         | 
| 544 575 | 
             
              # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
         | 
| @@ -546,6 +577,8 @@ class ULID < Object | |
| 546 577 | 
             
              # ```
         | 
| 547 578 | 
             
              def timestamp: -> String
         | 
| 548 579 |  | 
| 580 | 
            +
              # Returns randomness(suffix) part of encoded ULID
         | 
| 581 | 
            +
              #
         | 
| 549 582 | 
             
              # ```ruby
         | 
| 550 583 | 
             
              # ulid = ULID.generate
         | 
| 551 584 | 
             
              # #=> ULID(2021-04-27 17:27:22.826 UTC: 01F4A5Y1YAQCYAYCTC7GRMJ9AA)
         | 
| @@ -553,27 +586,15 @@ class ULID < Object | |
| 553 586 | 
             
              # ```
         | 
| 554 587 | 
             
              def randomness: -> String
         | 
| 555 588 |  | 
| 556 | 
            -
              #  | 
| 557 | 
            -
              # Because the returning values are not fixed.
         | 
| 558 | 
            -
              def patterns: -> Hash[Symbol, Regexp | String]
         | 
| 559 | 
            -
              def octets: -> full_octets
         | 
| 560 | 
            -
              def timestamp_octets: -> timestamp_octets
         | 
| 561 | 
            -
              def randomness_octets: -> randomness_octets
         | 
| 562 | 
            -
             | 
| 563 | 
            -
              # ```ruby
         | 
| 564 | 
            -
              # # Currently experimental feature, so needed to load the extension.
         | 
| 565 | 
            -
              # require 'ulid/uuid'
         | 
| 589 | 
            +
              # Returns 6 + 10 octets(bytes) represented with Array[Integer]
         | 
| 566 590 | 
             
              #
         | 
| 567 | 
            -
              #  | 
| 568 | 
            -
              # ulid = ULID. | 
| 569 | 
            -
              # #=>  | 
| 570 | 
            -
              # 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]
         | 
| 571 594 | 
             
              # ```
         | 
| 572 | 
            -
               | 
| 573 | 
            -
              # See also [Why this is experimental?](https://github.com/kachick/ruby-ulid/issues/76)
         | 
| 574 | 
            -
              def to_uuidv4: -> String
         | 
| 595 | 
            +
              def octets: -> octets
         | 
| 575 596 |  | 
| 576 | 
            -
              # Returns next(successor) ULID | 
| 597 | 
            +
              # Returns next(successor) ULID.\
         | 
| 577 598 | 
             
              # Especially `ULID#succ` makes it possible `Range[ULID]#each`.
         | 
| 578 599 | 
             
              #
         | 
| 579 600 | 
             
              # NOTE: But basically `Range[ULID]#each` should not be used, incrementing 128 bits IDs are not reasonable operation in most case
         | 
| @@ -598,7 +619,6 @@ class ULID < Object | |
| 598 619 | 
             
              #
         | 
| 599 620 | 
             
              # See also [ULID#succ](https://kachick.github.io/ruby-ulid/ULID.html#succ-instance_method)
         | 
| 600 621 | 
             
              def pred: -> ULID?
         | 
| 601 | 
            -
              def freeze: -> self
         | 
| 602 622 |  | 
| 603 623 | 
             
              def marshal_dump: -> Integer
         | 
| 604 624 |  | 
| @@ -607,16 +627,45 @@ class ULID < Object | |
| 607 627 | 
             
              # Returns `self`
         | 
| 608 628 | 
             
              def to_ulid: -> self
         | 
| 609 629 |  | 
| 610 | 
            -
              #  | 
| 611 | 
            -
               | 
| 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
         | 
| 612 641 |  | 
| 613 | 
            -
              #  | 
| 614 | 
            -
              #  | 
| 615 | 
            -
               | 
| 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
         | 
| 660 | 
            +
             | 
| 661 | 
            +
              # Returns same ID with different Ruby object.
         | 
| 662 | 
            +
              def dup: -> ULID
         | 
| 663 | 
            +
             | 
| 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
         | 
| 616 667 |  | 
| 617 668 | 
             
              private
         | 
| 618 669 |  | 
| 619 670 | 
             
              def initialize: (milliseconds: milliseconds, entropy: Integer, integer: Integer, encoded: String) -> void
         | 
| 620 | 
            -
             | 
| 621 | 
            -
              def cache_all_instance_variables: -> void
         | 
| 622 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. | 
| 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:  | 
| 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"
         | 
| @@ -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:  | 
| 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. | 
| 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: []
         |