uxid 0.2.3 → 1.0.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 +4 -4
- data/CHANGELOG.md +30 -0
- data/README.md +139 -41
- data/lib/uxid/decoded.rb +53 -0
- data/lib/uxid/decoder.rb +107 -0
- data/lib/uxid/encoder.rb +86 -155
- data/lib/uxid/error.rb +35 -0
- data/lib/uxid/monotonic.rb +213 -0
- data/lib/uxid/options.rb +144 -0
- data/lib/uxid/version.rb +4 -1
- data/lib/uxid.rb +155 -61
- metadata +17 -29
- data/.github/workflows/build.yml +0 -72
- data/.gitignore +0 -43
- data/.rubocop.yml +0 -103
- data/.simplecov +0 -8
- data/Dangerfile +0 -5
- data/Gemfile +0 -15
- data/Gemfile.lock +0 -171
- data/Rakefile +0 -3
- data/bin/console +0 -7
- data/bin/setup +0 -8
- data/lib/tasks/bundler.rake +0 -4
- data/lib/tasks/check.rake +0 -2
- data/lib/tasks/linting.rake +0 -19
- data/lib/tasks/quality.rake +0 -12
- data/lib/tasks/test.rake +0 -8
- data/lib/uxid/model.rb +0 -44
- data/uxid.gemspec +0 -27
data/Gemfile.lock
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: .
|
|
3
|
-
specs:
|
|
4
|
-
uxid (0.2.2)
|
|
5
|
-
|
|
6
|
-
GEM
|
|
7
|
-
remote: https://rubygems.org/
|
|
8
|
-
specs:
|
|
9
|
-
addressable (2.7.0)
|
|
10
|
-
public_suffix (>= 2.0.2, < 5.0)
|
|
11
|
-
ansi (1.5.0)
|
|
12
|
-
ast (2.4.1)
|
|
13
|
-
axiom-types (0.1.1)
|
|
14
|
-
descendants_tracker (~> 0.0.4)
|
|
15
|
-
ice_nine (~> 0.11.0)
|
|
16
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
|
17
|
-
builder (3.2.4)
|
|
18
|
-
claide (1.0.3)
|
|
19
|
-
claide-plugins (0.9.2)
|
|
20
|
-
cork
|
|
21
|
-
nap
|
|
22
|
-
open4 (~> 1.3)
|
|
23
|
-
coderay (1.1.3)
|
|
24
|
-
coercible (1.0.0)
|
|
25
|
-
descendants_tracker (~> 0.0.1)
|
|
26
|
-
colored2 (3.1.2)
|
|
27
|
-
cork (0.3.0)
|
|
28
|
-
colored2 (~> 3.1)
|
|
29
|
-
danger (8.2.1)
|
|
30
|
-
claide (~> 1.0)
|
|
31
|
-
claide-plugins (>= 0.9.2)
|
|
32
|
-
colored2 (~> 3.1)
|
|
33
|
-
cork (~> 0.1)
|
|
34
|
-
faraday (>= 0.9.0, < 2.0)
|
|
35
|
-
faraday-http-cache (~> 2.0)
|
|
36
|
-
git (~> 1.7)
|
|
37
|
-
kramdown (~> 2.3)
|
|
38
|
-
kramdown-parser-gfm (~> 1.0)
|
|
39
|
-
no_proxy_fix
|
|
40
|
-
octokit (~> 4.7)
|
|
41
|
-
terminal-table (~> 1)
|
|
42
|
-
danger-commit_lint (0.0.7)
|
|
43
|
-
danger-plugin-api (~> 1.0)
|
|
44
|
-
danger-plugin-api (1.0.0)
|
|
45
|
-
danger (> 2.0)
|
|
46
|
-
descendants_tracker (0.0.4)
|
|
47
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
|
48
|
-
docile (1.3.2)
|
|
49
|
-
equalizer (0.0.11)
|
|
50
|
-
erubis (2.7.0)
|
|
51
|
-
faraday (1.1.0)
|
|
52
|
-
multipart-post (>= 1.2, < 3)
|
|
53
|
-
ruby2_keywords
|
|
54
|
-
faraday-http-cache (2.2.0)
|
|
55
|
-
faraday (>= 0.8)
|
|
56
|
-
flay (2.12.1)
|
|
57
|
-
erubis (~> 2.7.0)
|
|
58
|
-
path_expander (~> 1.0)
|
|
59
|
-
ruby_parser (~> 3.0)
|
|
60
|
-
sexp_processor (~> 4.0)
|
|
61
|
-
flog (4.6.4)
|
|
62
|
-
path_expander (~> 1.0)
|
|
63
|
-
ruby_parser (~> 3.1, > 3.1.0)
|
|
64
|
-
sexp_processor (~> 4.8)
|
|
65
|
-
git (1.7.0)
|
|
66
|
-
rchardet (~> 1.8)
|
|
67
|
-
ice_nine (0.11.2)
|
|
68
|
-
kramdown (2.3.0)
|
|
69
|
-
rexml
|
|
70
|
-
kramdown-parser-gfm (1.1.0)
|
|
71
|
-
kramdown (~> 2.0)
|
|
72
|
-
kwalify (0.7.2)
|
|
73
|
-
launchy (2.5.0)
|
|
74
|
-
addressable (~> 2.7)
|
|
75
|
-
method_source (0.9.2)
|
|
76
|
-
minitest (5.14.1)
|
|
77
|
-
minitest-focus (1.2.1)
|
|
78
|
-
minitest (>= 4, < 6)
|
|
79
|
-
minitest-reporters (1.4.2)
|
|
80
|
-
ansi
|
|
81
|
-
builder
|
|
82
|
-
minitest (>= 5.0)
|
|
83
|
-
ruby-progressbar
|
|
84
|
-
multipart-post (2.1.1)
|
|
85
|
-
nap (1.1.0)
|
|
86
|
-
no_proxy_fix (0.1.2)
|
|
87
|
-
octokit (4.19.0)
|
|
88
|
-
faraday (>= 0.9)
|
|
89
|
-
sawyer (~> 0.8.0, >= 0.5.3)
|
|
90
|
-
open4 (1.3.4)
|
|
91
|
-
parallel (1.19.2)
|
|
92
|
-
parser (2.7.1.3)
|
|
93
|
-
ast (~> 2.4.0)
|
|
94
|
-
path_expander (1.1.0)
|
|
95
|
-
pry (0.12.2)
|
|
96
|
-
coderay (~> 1.1.0)
|
|
97
|
-
method_source (~> 0.9.0)
|
|
98
|
-
pry-nav (0.3.0)
|
|
99
|
-
pry (>= 0.9.10, < 0.13.0)
|
|
100
|
-
psych (3.1.0)
|
|
101
|
-
public_suffix (4.0.5)
|
|
102
|
-
rainbow (3.0.0)
|
|
103
|
-
rake (12.3.3)
|
|
104
|
-
rchardet (1.8.0)
|
|
105
|
-
reek (6.0.1)
|
|
106
|
-
kwalify (~> 0.7.0)
|
|
107
|
-
parser (>= 2.5.0.0, < 2.8, != 2.5.1.1)
|
|
108
|
-
psych (~> 3.1.0)
|
|
109
|
-
rainbow (>= 2.0, < 4.0)
|
|
110
|
-
regexp_parser (1.7.1)
|
|
111
|
-
rexml (3.2.4)
|
|
112
|
-
rubocop (0.85.1)
|
|
113
|
-
parallel (~> 1.10)
|
|
114
|
-
parser (>= 2.7.0.1)
|
|
115
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
116
|
-
regexp_parser (>= 1.7)
|
|
117
|
-
rexml
|
|
118
|
-
rubocop-ast (>= 0.0.3)
|
|
119
|
-
ruby-progressbar (~> 1.7)
|
|
120
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
|
121
|
-
rubocop-ast (0.0.3)
|
|
122
|
-
parser (>= 2.7.0.1)
|
|
123
|
-
ruby-progressbar (1.10.1)
|
|
124
|
-
ruby2_keywords (0.0.2)
|
|
125
|
-
ruby_parser (3.14.2)
|
|
126
|
-
sexp_processor (~> 4.9)
|
|
127
|
-
rubycritic (4.5.0)
|
|
128
|
-
flay (~> 2.8)
|
|
129
|
-
flog (~> 4.4)
|
|
130
|
-
launchy (>= 2.0.0)
|
|
131
|
-
parser (>= 2.6.0)
|
|
132
|
-
rainbow (~> 3.0)
|
|
133
|
-
reek (~> 6.0, < 7.0)
|
|
134
|
-
ruby_parser (~> 3.8)
|
|
135
|
-
simplecov (>= 0.17.0)
|
|
136
|
-
tty-which (~> 0.4.0)
|
|
137
|
-
virtus (~> 1.0)
|
|
138
|
-
sawyer (0.8.2)
|
|
139
|
-
addressable (>= 2.3.5)
|
|
140
|
-
faraday (> 0.8, < 2.0)
|
|
141
|
-
sexp_processor (4.15.0)
|
|
142
|
-
simplecov (0.18.5)
|
|
143
|
-
docile (~> 1.1)
|
|
144
|
-
simplecov-html (~> 0.11)
|
|
145
|
-
simplecov-html (0.12.2)
|
|
146
|
-
terminal-table (1.8.0)
|
|
147
|
-
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
148
|
-
thread_safe (0.3.6)
|
|
149
|
-
tty-which (0.4.2)
|
|
150
|
-
unicode-display_width (1.7.0)
|
|
151
|
-
virtus (1.0.5)
|
|
152
|
-
axiom-types (~> 0.1)
|
|
153
|
-
coercible (~> 1.0)
|
|
154
|
-
descendants_tracker (~> 0.0, >= 0.0.3)
|
|
155
|
-
equalizer (~> 0.0, >= 0.0.9)
|
|
156
|
-
|
|
157
|
-
PLATFORMS
|
|
158
|
-
ruby
|
|
159
|
-
|
|
160
|
-
DEPENDENCIES
|
|
161
|
-
danger
|
|
162
|
-
danger-commit_lint
|
|
163
|
-
minitest (~> 5.0)
|
|
164
|
-
minitest-focus
|
|
165
|
-
minitest-reporters
|
|
166
|
-
pry-nav
|
|
167
|
-
rake (~> 12.0)
|
|
168
|
-
rubocop
|
|
169
|
-
rubycritic
|
|
170
|
-
simplecov
|
|
171
|
-
uxid!
|
data/Rakefile
DELETED
data/bin/console
DELETED
data/bin/setup
DELETED
data/lib/tasks/bundler.rake
DELETED
data/lib/tasks/check.rake
DELETED
data/lib/tasks/linting.rake
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require "rubocop/rake_task"
|
|
3
|
-
|
|
4
|
-
desc "Run Linting (RuboCop)"
|
|
5
|
-
task linting: "linting:dev"
|
|
6
|
-
|
|
7
|
-
namespace :linting do
|
|
8
|
-
common_options = %w[ --display-cop-names --extra-details --config=.rubocop.yml --parallel ]
|
|
9
|
-
|
|
10
|
-
RuboCop::RakeTask.new :dev do |t|
|
|
11
|
-
t.options = common_options
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
RuboCop::RakeTask.new :report do |t|
|
|
15
|
-
t.options = common_options + %w[ --format=html --out=reports/linting/index.html ]
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
rescue LoadError
|
|
19
|
-
end
|
data/lib/tasks/quality.rake
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require "rubycritic/rake_task"
|
|
3
|
-
|
|
4
|
-
namespace :metrics do
|
|
5
|
-
RubyCritic::RakeTask.new do |task|
|
|
6
|
-
task.name = "quality"
|
|
7
|
-
task.paths = FileList["lib/**/*.rb"]
|
|
8
|
-
task.options = "--format html --no-browser --path reports/quality"
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
rescue LoadError
|
|
12
|
-
end
|
data/lib/tasks/test.rake
DELETED
data/lib/uxid/model.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
require "uxid/encoder"
|
|
2
|
-
|
|
3
|
-
module UXID
|
|
4
|
-
class Model
|
|
5
|
-
attr_accessor :time, :time_encoded, :entropy, :entropy_encoded, :prefix, :size, :rand_size
|
|
6
|
-
|
|
7
|
-
def encode
|
|
8
|
-
encoder = ::UXID::Encoder.new self
|
|
9
|
-
encoder.encode
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
# Returns time as 48 bits
|
|
13
|
-
def time_bytes
|
|
14
|
-
return @time_bytes if @time_bytes
|
|
15
|
-
|
|
16
|
-
time_ms = (@time.to_f * 1000).to_i
|
|
17
|
-
bytes = [time_ms].pack "Q>"
|
|
18
|
-
bytes_string = bytes[2..-1]
|
|
19
|
-
@time_bytes = bytes_string.bytes
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def entropy_bytes
|
|
23
|
-
return @entropy_bytes if @entropy_bytes
|
|
24
|
-
|
|
25
|
-
bytes_string = SecureRandom.random_bytes @rand_size
|
|
26
|
-
@entropy_bytes = bytes_string.bytes
|
|
27
|
-
return @entropy_bytes
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def encoded
|
|
31
|
-
id = time_encoded + entropy_encoded
|
|
32
|
-
|
|
33
|
-
if has_prefix?
|
|
34
|
-
[prefix, id].join UXID::DELIMITER
|
|
35
|
-
else
|
|
36
|
-
id
|
|
37
|
-
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def has_prefix?
|
|
41
|
-
!(prefix.nil? || prefix == "")
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
data/uxid.gemspec
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require_relative "lib/uxid/version"
|
|
2
|
-
here = File.expand_path "..", __FILE__
|
|
3
|
-
|
|
4
|
-
Gem::Specification.new do |spec|
|
|
5
|
-
spec.name = "uxid"
|
|
6
|
-
spec.version = UXID::VERSION
|
|
7
|
-
spec.authors = ["JohnnyT"]
|
|
8
|
-
spec.email = ["ubergeek3141@gmail.com"]
|
|
9
|
-
|
|
10
|
-
spec.summary = "Generates IDs like: cus_01EPEY1JMK and txn_01EPEY2P06TR1RTV07 (similar to Stripe identifiers)."
|
|
11
|
-
spec.description = spec.summary
|
|
12
|
-
spec.homepage = "https://github.com/riddler/uxid-rb"
|
|
13
|
-
spec.license = "MIT"
|
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new ">= 2.3.0"
|
|
15
|
-
|
|
16
|
-
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
-
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
|
-
|
|
19
|
-
# Specify which files should be added to the gem when it is released.
|
|
20
|
-
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
21
|
-
spec.files = Dir.chdir here do
|
|
22
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match %r{^(test|spec|features)/} }
|
|
23
|
-
end
|
|
24
|
-
spec.bindir = "exe"
|
|
25
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename f }
|
|
26
|
-
spec.require_paths = ["lib"]
|
|
27
|
-
end
|