ruby_xid 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_xid.rb +3 -4
- data/lib/xid/base32.rb +6 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43e2108601f1c726d195b4646fad23295f90facd04601df09003fdde47baffbe
|
4
|
+
data.tar.gz: af678e9fba6abd5d322e87393232084a3b012b64a4c1f0dc0a8a254f4e3410c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9de910d88a77f965b806a39bb4270d12371680f03b57f16b9646ec0582d2394b5933686d718d5e7bfc3ad473af3b059819a3bc6a3ea0aa1d45baaa082637c114
|
7
|
+
data.tar.gz: c1a87195ce2ea293e23c0459d7e5bdc9e5d3a6d507a8d5a40d3857c227a9036d45fed24d274e0816b36750c2c7315f38fc4cce863a19595df53634e09f29bd9e
|
data/lib/ruby_xid.rb
CHANGED
@@ -8,7 +8,6 @@ class Xid
|
|
8
8
|
TRIM_LEN = 20
|
9
9
|
|
10
10
|
attr_accessor :value
|
11
|
-
attr_reader :machine_id
|
12
11
|
|
13
12
|
def initialize(id = nil)
|
14
13
|
@mutex = Mutex.new
|
@@ -119,9 +118,9 @@ class Xid
|
|
119
118
|
@value[2] = (now >> 8) & 0xff
|
120
119
|
@value[3] = now & 0xff
|
121
120
|
|
122
|
-
@value[4] = machine_id[0]
|
123
|
-
@value[5] = machine_id[1]
|
124
|
-
@value[6] = machine_id[2]
|
121
|
+
@value[4] = @machine_id[0]
|
122
|
+
@value[5] = @machine_id[1]
|
123
|
+
@value[6] = @machine_id[2]
|
125
124
|
|
126
125
|
@value[7] = (@pid >> 8) & 0xff
|
127
126
|
@value[8] = @pid & 0xff
|
data/lib/xid/base32.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
|
2
2
|
class Xid::Base32
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
# 0123456789abcdefghijklmnopqrstuv - Used for encoding
|
5
|
+
ENCODE_HEX = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v"].freeze
|
6
6
|
|
7
7
|
# Start class methods
|
8
8
|
class << self
|
9
9
|
|
10
10
|
def decode_hex_map
|
11
|
-
Hash[ENCODE_HEX.
|
11
|
+
Hash[ENCODE_HEX.each_with_index.map { |x, i| [x, i] }]
|
12
12
|
end
|
13
13
|
|
14
14
|
def b32encode(src)
|
@@ -94,9 +94,9 @@ class Xid::Base32
|
|
94
94
|
if src_len >= 2
|
95
95
|
dst[0] = (dbuf[0] << 3) | (dbuf[1] >> 2)
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
dst = dst.map { |x| x & 0xff }
|
99
|
-
|
99
|
+
|
100
100
|
if src_len == 2
|
101
101
|
dst = dst[0]
|
102
102
|
elsif src_len == 4
|
@@ -112,7 +112,7 @@ class Xid::Base32
|
|
112
112
|
result += dst
|
113
113
|
src = src[8..src.length]
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
result
|
117
117
|
end
|
118
118
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_xid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valarpiraichandran
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-12-
|
11
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email: a.valarpirai@gmail.com
|