frostyid 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/frostyid/version.rb +5 -0
- data/lib/frostyid.rb +30 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 40afae96caec9f2b80bc08b992a3bf2fb150c6d9a7693bb1612adf0bbc372968
|
4
|
+
data.tar.gz: 5e3859b0edbaf85a4938d9ae91eb4ef007191b2908b0e2ed201264ecf6cf3f41
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 294af01e1a33fcc41604f8fbdf9c8e555f910416b77427cd374bcdc7d07f56253966cba4fdae042e9798a5784f4501339adc725cbd176cd090151667afb2751b
|
7
|
+
data.tar.gz: 32c9f1337a8959659c9c561c195b38ffdc921729796dc59befa4c9b39e1b7dc406443b1d471846fb4d05fc4f3f903014c5f30f782a4376a9f6787c5e916e1f53
|
data/lib/frostyid.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "frostyid/version"
|
4
|
+
|
5
|
+
##
|
6
|
+
# Module that contains all of Frosty's code
|
7
|
+
module Frostyid
|
8
|
+
##
|
9
|
+
# The generator module containing the default generator.
|
10
|
+
module Generator
|
11
|
+
def self.generate_id(options)
|
12
|
+
"#{format("%0#{options[:timestamp_length]}s", (Time.now - options[:epoch]).to_i.to_s(36))}#{format("%0#{options[:random_length]}s", rand(36**options[:random_length]).to_s(36))}".gsub(' ', '0')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
##
|
16
|
+
# The ID Factory module, making generating a lot IDs easier.
|
17
|
+
class IDFactory
|
18
|
+
attr_reader :generator, :options
|
19
|
+
def initialize(generator: Generator, epoch: Time.new(2020), timestamp_length: 7, random_length: 25)
|
20
|
+
@generator = generator
|
21
|
+
@options = {epoch: epoch,
|
22
|
+
timestamp_length: timestamp_length,
|
23
|
+
random_length: random_length}
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate!
|
27
|
+
Frostyid::Generator.generate_id(@options)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: frostyid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sönke "Cubuzz" Köster
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: As a convenient tool to generate snowflake strings according to your
|
14
|
+
needs, FrostyID allows you to quickly get things up and running.
|
15
|
+
email:
|
16
|
+
- skoester@cubuzz.de
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/frostyid.rb
|
22
|
+
- lib/frostyid/version.rb
|
23
|
+
homepage: https://frostyid.culabs.eu
|
24
|
+
licenses:
|
25
|
+
- MIT
|
26
|
+
metadata:
|
27
|
+
homepage_uri: https://frostyid.culabs.eu
|
28
|
+
source_code_uri: https://github.com/cubuzz/frostyid
|
29
|
+
changelog_uri: https://frostyid.culabs.eu/changelog
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 2.4.0
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubygems_version: 3.2.22
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: FrostyID is a snowflake-style string generator.
|
49
|
+
test_files: []
|