active_uxid 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ef45b0b1fd32eb33f6849dd019edd5ade93154d
4
- data.tar.gz: 84e9719c661f3f18b6e3abf624cd0d64d7355237
3
+ metadata.gz: c6581582e44cdb2170d2092d6d10132ac017d1f9
4
+ data.tar.gz: 42c9aa6394ef2dd4d6638ea2d1f246c229151361
5
5
  SHA512:
6
- metadata.gz: 71eaa94fffd906a47ef8002e0e76f807538792ea525105ed2a4010197bc70421fc66635a784155d19494d2bdc77c57228c2c8cf8d1e29c4a2cbc95573b92cc7e
7
- data.tar.gz: 860754811c07d43929748a8633b17e7b1a9a82ef4bd748f33d672d5d6ca2993356d0f8eaf660eb445095545db3deb847ea6df5832bb064cd30ac92e27ece5224
6
+ metadata.gz: 7a3f3a40376af3eb4769770b45f83b3c9bb2f2918526aba632f7f32e2fdce86a4f23e9e7dcb423d6a42100d1dc6ee74732a368af775827a66ef49102db2fa8bd
7
+ data.tar.gz: 1769ec243f802d44dceca2418e3bff8ea83cc063af8c93261fdcb02cea3984d8c77c80e36979a9bd4ffbd1263b6d469693cb5dffd26f9e3448bdbcd4c3ad7ffd
data/README.md CHANGED
@@ -1,10 +1,9 @@
1
- # ActiveRegulation
1
+ # ActiveUxid
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/active_uxid.svg)](http://badge.fury.io/rb/active_uxid)
4
4
  [![Build Status](https://travis-ci.org/drexed/active_uxid.svg?branch=master)](https://travis-ci.org/drexed/active_uxid)
5
- [![Coverage Status](https://coveralls.io/repos/github/drexed/active_uxid/badge.svg?branch=master)](https://coveralls.io/github/drexed/active_uxid?branch=master)
6
5
 
7
- ActiveRegulation is a library for commonly used record states.
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
- * [Methods](#methods)
28
- * [Usage](#usage)
26
+ * [Configuration](#configuration)
27
+ * [Hash](#hash)
28
+ * [Ulid](#ulid)
29
+ * [ActiveRecord](#active_record)
29
30
 
30
- ## Methods
31
+ ## Configuration
31
32
 
32
- **Modules:**
33
- * `activation`
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
- **Attributes:**
41
- * `:inactivated_at`
42
- * `:contained_at`
43
- * `:expires_at`
44
- * `:invisible_at`
45
- * `:quarantined_at`
46
- * `:suspended_at`
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
- class User < ActiveRecord::Base
47
+ # Hash ID's are reversible but less performant
48
+ # than ULID
50
49
 
51
- # Add one of the datetime attributes
52
- # above to the corresponding table.
50
+ ActiveUxid::Hash.encode(10) #=> 'q5D8inm0'
51
+ ActiveUxid::Hash.decode('q5D8inm0') #=> 10
52
+ ```
53
53
 
54
- include ActiveRegulation::Containment
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
- end
59
+ ActiveUxid::Ulid.encode #=> '1mqfg9qa96s8s5f02o1ucf8lcc'
57
60
  ```
58
61
 
59
- ## Usage
62
+ ## ActiveRecord
60
63
  ```ruby
61
- user.active? #=> true
62
- user.inactive? #=> false
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
- user.active!
68
- user.active? #=> true
68
+ include ActiveUxid::Record
69
+ end
69
70
 
70
- user.to_activation #=> 'Active'
71
+ # Hash UXid's type only
72
+ User.find_by_uxid('x123') #=> find record by uxid
71
73
 
72
- User.active #=> retrieves all active records
73
- User.inactive #=> retrieves all inactive records
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 lexicographical UXid's."
16
- spec.description = 'Generate lexicographical UXids.'
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'
@@ -7,6 +7,11 @@ module ActiveUxid
7
7
 
8
8
  included do
9
9
  after_create :callback_generate_uxid!, if: proc { respond_to?(:uxid) }
10
+
11
+ def self.find_by_uxid(uxid)
12
+ iden = ActiveUxid::Hash.decode(uxid)
13
+ find(iden)
14
+ end
10
15
  end
11
16
 
12
17
  def uxid_to_id
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRegulation
4
- VERSION ||= '1.0.0'
4
+ VERSION ||= '1.0.1'
5
5
  end
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.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 lexicographical UXids.
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 lexicographical UXid's.
238
+ summary: Gem for generating obfuscated UXid's.
254
239
  test_files: []
data/.coveralls.yml DELETED
@@ -1 +0,0 @@
1
- service_name: travis-ci