uuid64 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/uuid64.rb +11 -8
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: abed77850782ed0058707cb23146578460692167
4
- data.tar.gz: 2789d338f33675d5fc06449e283d265a06cbfb42
3
+ metadata.gz: 7e51a87b3e3458b866e31da23ca03adde3007d1d
4
+ data.tar.gz: 7392e46d020b374d2f3817b8fca2a5015041eb57
5
5
  SHA512:
6
- metadata.gz: 646651260e6a2270498894fc339164e5555f2af4676b5a3e85cd8fcc4a821105cd8ded35e707f24e28e3d124bedfd6131cfdc69dba8697b0fff97afd3d3cd511
7
- data.tar.gz: 0137a16954ed78e934654b5593b8c68d1f602924c04374e5dfeb4ec0faf8b75094b2a1624c1353a9fcfed453741442bf2804dbc1e4a1f1d2c88117f28873a69f
6
+ metadata.gz: 9afc0334f6a5873692c9de09fba3a703f12d117d21db3c77fa25949f691cd6c3a6f1bae6fef28d5f948cd5b52887d2647bad8be9e1ab5ca8b2ab0f65f56ad445
7
+ data.tar.gz: eb1be3e8bd804caf49d0a76f61be78f2cb702de3f8353e5508d4bef7e8f1cde8fd3d7fad115f6e152d4c6f58c0f6ab0de6d62099618d0e677caf7921bc10109e
@@ -1,26 +1,29 @@
1
1
  require 'securerandom'
2
2
  require 'socket'
3
3
  require 'digest'
4
+
4
5
  module SecureRandom
5
- def SecureRandom.uuid64
6
+ def self.uuid64
6
7
  [[SecureRandom.uuid.gsub(/-/, '')].pack('H*')].pack('m').gsub(/==/,'').gsub(/\n/,'')
7
8
  end
8
- def SecureRandom.mongo_id
9
+
10
+ def self.mongo_id
9
11
  if @mongo_init.nil?
10
- @mongo_init = true
12
+ @mongo_init = true.freeze
11
13
  @mongo_host = Digest::SHA2.hexdigest(Socket.gethostname)[0..5].freeze
12
- @mongo_pid = Process.pid.to_s(16)[0..3].rjust(4, '0')
14
+ @mongo_pid = Process.pid.to_s(16)[0..3].rjust(4, '0').freeze
13
15
  @mongo_inc = 0
14
16
  else
15
17
  @mongo_inc += 1
16
18
  end
17
19
 
18
20
  Time.now.to_i.to_s(16)[0..15].rjust(8, '0')[0..7] +
19
- @mongo_host +
20
- @mongo_pid +
21
- @mongo_inc.to_s(16).rjust(6, '0')[0..5]
21
+ @mongo_host +
22
+ @mongo_pid +
23
+ @mongo_inc.to_s(16).rjust(6, '0')[0..5]
22
24
  end
23
- def SecureRandom.mongo_id64
25
+
26
+ def self.mongo_id64
24
27
  [[SecureRandom.mongo_id].pack('H*')].pack('m').gsub(/\n/,'')
25
28
  end
26
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uuid64
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - HeckPsi Lab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a library generating unique id in short pattern.
14
14
  email: business@heckpsi.com
@@ -29,7 +29,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 2.3.0
33
33
  required_rubygems_version: !ruby/object:Gem::Requirement
34
34
  requirements:
35
35
  - - ">="