ruby-ulid 0.6.0 → 0.6.1

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: 82f48c45c124521403b04938ec4498a85bf292645357d75f32173cc2b9613618
4
- data.tar.gz: 9c6269cbef649b57df980d120116687cdcc33e505cb45585b4566f4b16f3cdf2
3
+ metadata.gz: 5c7cf89034d0f74026278e2a4c113d57f8fc28b861b8bcf1d2210dbb76688e52
4
+ data.tar.gz: 340bfbea8fb1ff3ec0e49339e2a5a388a81552f8cd73a65ad9ff049448fc0c3f
5
5
  SHA512:
6
- metadata.gz: 817d5589c2967d8d1b787ce20c147483cd12769eba22a0489ade4002285e1edc31e06f9e5d8dd590d3cf2342d2875c388818e55b95cbd1d72921b1848287483f
7
- data.tar.gz: 6bcacebe7955bb247127ddc64df1fec2cc776954e7c86530750c200da5420fd4cbb73d5fd2f0888cb37ff5f097987dd12f372ee591adccb8b35f35e03e4f0538
6
+ metadata.gz: 74d26cb5dc49a8d79a5c933817c1c8913954d675d996a91057f29859fd1fdf0a32c99d8121ef954e1d7d400110fa1737be17a9084bfc03655082de96c9614392
7
+ data.tar.gz: 96f19838c4c90ee313722857f88693e88f247e5380293291b362eadc834f6adb1613c01034a0cfe430f24576b4fea55f252b79f689b00c3e05b739118db8906e
data/README.md CHANGED
@@ -49,7 +49,7 @@ Should be installed!
49
49
  Add this line in your Gemfile.
50
50
 
51
51
  ```ruby
52
- gem('ruby-ulid', '~> 0.6.0')
52
+ gem('ruby-ulid', '~> 0.6.1')
53
53
  ```
54
54
 
55
55
  ### How to use
@@ -58,10 +58,10 @@ gem('ruby-ulid', '~> 0.6.0')
58
58
  require 'ulid'
59
59
 
60
60
  ULID::VERSION
61
- # => "0.6.0"
61
+ # => "0.6.1"
62
62
  ```
63
63
 
64
- NOTE: This README includes info about development version. If you would see released version's one. [Look at the ref](https://github.com/kachick/ruby-ulid/tree/v0.6.0).
64
+ NOTE: This README includes info about development version. If you would see released version's one. [Look at the ref](https://github.com/kachick/ruby-ulid/tree/v0.6.1).
65
65
 
66
66
  ### Generator and Parser
67
67
 
@@ -118,11 +118,11 @@ ULID.decode_time('00VHNCZB00SYG7RCEXZC9DA4E1', in: '+09:00') #=> 2000-01-01 09:0
118
118
 
119
119
  This project does not prioritize the speed. However it actually works faster than others! :zap:
120
120
 
121
- Snapshot on 0.6.0 is below
121
+ Snapshot on 0.6.1 is below
122
122
 
123
- * Generator is 1.4x faster than - [ulid gem](https://github.com/rafaelsales/ulid)
124
- * Generator is 1.7x faster than - [ulid-ruby gem](https://github.com/abachman/ulid-ruby)
125
- * Parser is 2.6x faster than - [ulid-ruby gem](https://github.com/abachman/ulid-ruby)
123
+ * Generator is 1.5x faster than - [ulid gem](https://github.com/rafaelsales/ulid)
124
+ * Generator is 1.9x faster than - [ulid-ruby gem](https://github.com/abachman/ulid-ruby)
125
+ * Parser is 2.7x faster than - [ulid-ruby gem](https://github.com/abachman/ulid-ruby)
126
126
 
127
127
  You can see further detail at [Benchmark](https://github.com/kachick/ruby-ulid/wiki/Benchmark).
128
128
 
@@ -15,8 +15,7 @@ class ULID
15
15
  # * https://github.com/kachick/ruby-ulid/issues/57
16
16
  # * https://github.com/kachick/ruby-ulid/issues/78
17
17
  module CrockfordBase32
18
- # Excluded I, L, O, U, - from Base32
19
- base32_to_crockford = {
18
+ same_definitions = {
20
19
  '0' => '0',
21
20
  '1' => '1',
22
21
  '2' => '2',
@@ -34,7 +33,11 @@ class ULID
34
33
  'E' => 'E',
35
34
  'F' => 'F',
36
35
  'G' => 'G',
37
- 'H' => 'H',
36
+ 'H' => 'H'
37
+ }.freeze
38
+
39
+ # Excluded I, L, O, U, - from Base32
40
+ base32_to_crockford = {
38
41
  'I' => 'J',
39
42
  'J' => 'K',
40
43
  'K' => 'M',
@@ -51,9 +54,10 @@ class ULID
51
54
  'V' => 'Z'
52
55
  }.freeze
53
56
  BASE32_TR_PATTERN = base32_to_crockford.keys.join.freeze
54
- ENCODING_STRING = CROCKFORD_BASE32_TR_PATTERN = base32_to_crockford.values.freeze.join.freeze
57
+ CROCKFORD_TR_PATTERN = base32_to_crockford.values.join.freeze
58
+ ENCODING_STRING = "#{same_definitions.values.join}#{CROCKFORD_TR_PATTERN}".freeze
55
59
 
56
- normarized_by_variant = {
60
+ variant_to_normarized = {
57
61
  'L' => '1',
58
62
  'l' => '1',
59
63
  'I' => '1',
@@ -61,8 +65,8 @@ class ULID
61
65
  'O' => '0',
62
66
  'o' => '0'
63
67
  }.freeze
64
- VARIANT_TR_PATTERN = normarized_by_variant.keys.join.freeze
65
- NORMALIZED_TR_PATTERN = normarized_by_variant.values.join.freeze
68
+ VARIANT_TR_PATTERN = variant_to_normarized.keys.join.freeze
69
+ NORMALIZED_TR_PATTERN = variant_to_normarized.values.join.freeze
66
70
 
67
71
  # @note Avoid to depend regex as possible. `tr(string, string)` is almost 2x Faster than `gsub(regex, hash)` in Ruby 3.1
68
72
 
@@ -70,7 +74,7 @@ class ULID
70
74
  # @param [String] string
71
75
  # @return [Integer]
72
76
  def self.decode(string)
73
- n32encoded = string.upcase.tr(CROCKFORD_BASE32_TR_PATTERN, BASE32_TR_PATTERN)
77
+ n32encoded = string.upcase.tr(CROCKFORD_TR_PATTERN, BASE32_TR_PATTERN)
74
78
  n32encoded.to_i(32)
75
79
  end
76
80
 
@@ -93,7 +97,7 @@ class ULID
93
97
  # @param [String] n32encoded
94
98
  # @return [String]
95
99
  def self.from_n32(n32encoded)
96
- n32encoded.upcase.tr(BASE32_TR_PATTERN, CROCKFORD_BASE32_TR_PATTERN)
100
+ n32encoded.upcase.tr(BASE32_TR_PATTERN, CROCKFORD_TR_PATTERN)
97
101
  end
98
102
  end
99
103
  end
data/lib/ulid/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # shareable_constant_value: literal
4
4
 
5
5
  class ULID
6
- VERSION = '0.6.0'
6
+ VERSION = '0.6.1'
7
7
  end
data/sig/ulid.rbs CHANGED
@@ -39,7 +39,7 @@ class ULID < Object
39
39
  end
40
40
 
41
41
  ENCODING_STRING: String
42
- CROCKFORD_BASE32_TR_PATTERN: String
42
+ CROCKFORD_TR_PATTERN: String
43
43
  BASE32_TR_PATTERN: String
44
44
  VARIANT_TR_PATTERN: String
45
45
  NORMALIZED_TR_PATTERN: String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-ulid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi Kamiya