active_uxid 1.0.0 → 1.0.1
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/README.md +38 -36
- data/active_uxid.gemspec +2 -3
- data/lib/active_uxid/record/hash.rb +5 -0
- data/lib/active_uxid/version.rb +1 -1
- metadata +3 -18
- data/.coveralls.yml +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6581582e44cdb2170d2092d6d10132ac017d1f9
|
4
|
+
data.tar.gz: 42c9aa6394ef2dd4d6638ea2d1f246c229151361
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a3f3a40376af3eb4769770b45f83b3c9bb2f2918526aba632f7f32e2fdce86a4f23e9e7dcb423d6a42100d1dc6ee74732a368af775827a66ef49102db2fa8bd
|
7
|
+
data.tar.gz: 1769ec243f802d44dceca2418e3bff8ea83cc063af8c93261fdcb02cea3984d8c77c80e36979a9bd4ffbd1263b6d469693cb5dffd26f9e3448bdbcd4c3ad7ffd
|
data/README.md
CHANGED
@@ -1,10 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# ActiveUxid
|
2
2
|
|
3
3
|
[](http://badge.fury.io/rb/active_uxid)
|
4
4
|
[](https://travis-ci.org/drexed/active_uxid)
|
5
|
-
[](https://coveralls.io/github/drexed/active_uxid?branch=master)
|
6
5
|
|
7
|
-
|
6
|
+
ActiveUxid is a library for generating obfuscated UXid's.
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
@@ -24,53 +23,56 @@ Or install it yourself as:
|
|
24
23
|
|
25
24
|
## Table of Contents
|
26
25
|
|
27
|
-
* [
|
28
|
-
* [
|
26
|
+
* [Configuration](#configuration)
|
27
|
+
* [Hash](#hash)
|
28
|
+
* [Ulid](#ulid)
|
29
|
+
* [ActiveRecord](#active_record)
|
29
30
|
|
30
|
-
##
|
31
|
+
## Configuration
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
* `containment`
|
35
|
-
* `expiration`
|
36
|
-
* `quarantine`
|
37
|
-
* `suspension`
|
38
|
-
* `visibility`
|
33
|
+
`rails generate active_uxid:install` will generate the following file:
|
34
|
+
`../config/initalizers/active_uxid.rb`
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
```ruby
|
37
|
+
ActiveUxid::Settings.configure do |config|
|
38
|
+
config.encoder_type = 'ulid'
|
39
|
+
config.encoding_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
40
|
+
config.encoding_length = 26
|
41
|
+
config.encoding_length = 1369136
|
42
|
+
end
|
43
|
+
```
|
47
44
|
|
45
|
+
## Hash
|
48
46
|
```ruby
|
49
|
-
|
47
|
+
# Hash ID's are reversible but less performant
|
48
|
+
# than ULID
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
ActiveUxid::Hash.encode(10) #=> 'q5D8inm0'
|
51
|
+
ActiveUxid::Hash.decode('q5D8inm0') #=> 10
|
52
|
+
```
|
53
53
|
|
54
|
-
|
54
|
+
## Ulid
|
55
|
+
```ruby
|
56
|
+
# ULID are secure as they are not reversible
|
57
|
+
# They are also more performant than Hash ID's
|
55
58
|
|
56
|
-
|
59
|
+
ActiveUxid::Ulid.encode #=> '1mqfg9qa96s8s5f02o1ucf8lcc'
|
57
60
|
```
|
58
61
|
|
59
|
-
##
|
62
|
+
## ActiveRecord
|
60
63
|
```ruby
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
user.inactive!
|
65
|
-
user.active? #=> false
|
64
|
+
class User < ActiveRecord::Base
|
65
|
+
# Add a uxid binary attribute to the corresponding table.
|
66
|
+
# This will include the proper UXid format from your settings
|
66
67
|
|
67
|
-
|
68
|
-
|
68
|
+
include ActiveUxid::Record
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
+
# Hash UXid's type only
|
72
|
+
User.find_by_uxid('x123') #=> find record by uxid
|
71
73
|
|
72
|
-
User.
|
73
|
-
|
74
|
+
user = User.new
|
75
|
+
user.uxid_to_id #=> decodes the records uxid to id
|
74
76
|
```
|
75
77
|
|
76
78
|
## Contributing
|
data/active_uxid.gemspec
CHANGED
@@ -12,8 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.authors = ['Juan Gomez']
|
13
13
|
spec.email = ['j.gomez@drexed.com']
|
14
14
|
|
15
|
-
spec.summary = "Gem for generating
|
16
|
-
spec.description =
|
15
|
+
spec.summary = "Gem for generating obfuscated UXid's."
|
16
|
+
spec.description = "Generate obfuscated UXid's."
|
17
17
|
spec.homepage = 'http://drexed.github.io/active_uxid'
|
18
18
|
spec.license = 'MIT'
|
19
19
|
|
@@ -27,7 +27,6 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_runtime_dependency 'dry-configurable'
|
28
28
|
|
29
29
|
spec.add_development_dependency 'bundler'
|
30
|
-
spec.add_development_dependency 'coveralls'
|
31
30
|
spec.add_development_dependency 'rake'
|
32
31
|
spec.add_development_dependency 'rspec'
|
33
32
|
spec.add_development_dependency 'sqlite3'
|
data/lib/active_uxid/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_uxid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Gomez
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: coveralls
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: rake
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,14 +178,13 @@ dependencies:
|
|
192
178
|
- - ">="
|
193
179
|
- !ruby/object:Gem::Version
|
194
180
|
version: '0'
|
195
|
-
description: Generate
|
181
|
+
description: Generate obfuscated UXid's.
|
196
182
|
email:
|
197
183
|
- j.gomez@drexed.com
|
198
184
|
executables: []
|
199
185
|
extensions: []
|
200
186
|
extra_rdoc_files: []
|
201
187
|
files:
|
202
|
-
- ".coveralls.yml"
|
203
188
|
- ".fasterer.yml"
|
204
189
|
- ".gitignore"
|
205
190
|
- ".reek"
|
@@ -250,5 +235,5 @@ rubyforge_project:
|
|
250
235
|
rubygems_version: 2.6.13
|
251
236
|
signing_key:
|
252
237
|
specification_version: 4
|
253
|
-
summary: Gem for generating
|
238
|
+
summary: Gem for generating obfuscated UXid's.
|
254
239
|
test_files: []
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: travis-ci
|