ulid 1.2.0 → 1.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6d32b5f061971e975a65735d0d99c70c5c881e025d3e53325414d010f54d8f8
4
- data.tar.gz: 1dae11d7a1c57c7851ab29269d9fb7319c5af028e43ee0438a4b9d578fac7589
3
+ metadata.gz: c072f00beeac3732fbbee2fe32af5f95e14a4eb516e659f70e9e08c0bc525e01
4
+ data.tar.gz: f8d7ad8d5e714c142c0309a6e814be406c61519cc6e36adcaccae4982d94b96f
5
5
  SHA512:
6
- metadata.gz: fb53e67529dedec160c2fa2d80cd905874835ab545b2bfa769bc3fbf235f06e0c53051d90801ef11f1239efced45548820b5babd74b912f98af5d228d14c1995
7
- data.tar.gz: c1dcd2873822f7524b4644aee637f1f32e88736a816aa6d9dbe036cadf1480d1c92901fee6e98318977d08c697f8c16ef122ce37e78b0d12c805ca4fb6dd6771
6
+ metadata.gz: 0e7aaedb437ae82765ec74cf36ddbeb5b529948c9c65c077a0e648156c21ebb23dc26f2e85b3430434dd1babfaaa1b4b1d8bfd00c8dbf9f09f332bad33b93f97
7
+ data.tar.gz: 01f353360ca4b82534de75f8e715d872b9c976a85655a9f419dfc1a93b6e867d0bea342ad970a3b4653048f3484bba1bc8842f75980142869d13005d3fabc1e7
@@ -0,0 +1,3 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: [rafaelsales]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ulid (1.1.1)
4
+ ulid (1.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -24,7 +24,7 @@ GEM
24
24
  pry (~> 0.10)
25
25
  rainbow (2.2.2)
26
26
  rake
27
- rake (10.5.0)
27
+ rake (13.0.1)
28
28
  rubocop (0.50.0)
29
29
  parallel (~> 1.10)
30
30
  parser (>= 2.3.3.1, < 3.0)
data/README.md CHANGED
@@ -113,4 +113,4 @@ bundle exec rake test
113
113
 
114
114
  ### Credits and references:
115
115
 
116
- * https://github.com/alizain/ulid
116
+ * https://github.com/ulid/javascript
@@ -48,7 +48,18 @@ module ULID
48
48
  end
49
49
 
50
50
  def time_48bit(time = Time.now)
51
- time_ms = (time.to_f * 1000).to_i
51
+ # Avoid `time.to_f` since we want to accurately represent a whole number of milliseconds:
52
+ #
53
+ # > time = Time.new(2020, 1, 5, 7, 3, Rational(2, 1000))
54
+ # => 2020-01-05 07:03:00 +0000
55
+ # > (time.to_f * 1000).to_i
56
+ # => 1578207780001
57
+ #
58
+ # vs
59
+ #
60
+ # > (time.to_r * 1000).to_i
61
+ # => 1578207780002
62
+ time_ms = (time.to_r * 1000).to_i
52
63
  [time_ms].pack('Q>')[2..-1]
53
64
  end
54
65
 
data/lib/ulid/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module ULID
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.3.0'.freeze
3
3
  end
@@ -25,10 +25,30 @@ describe ULID do
25
25
 
26
26
  it 'encodes the timestamp in the first 10 characters' do
27
27
  # test case taken from original ulid README:
28
- # https://github.com/alizain/ulid#seed-time
29
- ulid = ULID.generate(Time.at(1_469_918_176.385))
28
+ # https://github.com/ulid/javascript#seed-time
29
+ #
30
+ # N.b. we avoid specifying the time as a float, since we lose precision:
31
+ #
32
+ # > Time.at(1_469_918_176.385).strftime("%F %T.%N")
33
+ # => "2016-07-30 23:36:16.384999990"
34
+ #
35
+ # vs the correct:
36
+ #
37
+ # > Time.at(1_469_918_176, 385, :millisecond).strftime("%F %T.%N")
38
+ # => "2016-07-30 23:36:16.385000000"
39
+ ulid = ULID.generate(Time.at(1_469_918_176, 385, :millisecond))
30
40
  assert_equal '01ARYZ6S41', ulid[0...10]
31
41
  end
42
+
43
+ it 'respects millisecond-precision order' do
44
+ ulids = Array.new(1000) do |millis|
45
+ time = Time.new(2020, 1, 2, 3, 4, Rational(millis, 10**3))
46
+
47
+ ULID.generate(time)
48
+ end
49
+
50
+ assert_equal(ulids, ulids.sort)
51
+ end
32
52
  end
33
53
 
34
54
  describe 'underlying binary' do
metadata CHANGED
@@ -1,22 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ulid
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Sales
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-03 00:00:00.000000000 Z
11
+ date: 2021-03-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description:
13
+ description:
14
14
  email:
15
15
  - rafaelcds@gmail.com
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - ".github/FUNDING.yml"
20
21
  - ".github/workflows/ruby.yml"
21
22
  - ".gitignore"
22
23
  - ".rubocop.yml"
@@ -55,9 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
56
  - !ruby/object:Gem::Version
56
57
  version: '0'
57
58
  requirements: []
58
- rubyforge_project:
59
- rubygems_version: 2.7.6.2
60
- signing_key:
59
+ rubygems_version: 3.1.2
60
+ signing_key:
61
61
  specification_version: 4
62
62
  summary: Universally Unique Lexicographically Sortable Identifier implementation for
63
63
  Ruby