hashid-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +9 -2
- data/lib/hashid/rails.rb +8 -2
- data/lib/hashid/rails/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55e2d11c97ee9f402b01c2acd5979cceb445e129
|
4
|
+
data.tar.gz: 547037c91e5c315fef7d3b8e555ed4b4c2e78dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0966a9aa4f6a805f6a2cad08a1afbf70c9939718f9c289c7319649fdbc7c58396f04b7c49a064044915dc93c699747bfe87ad2cfe76badc1f45cbaccad57a77f
|
7
|
+
data.tar.gz: 02eecb588c3333c2b97f872da37d1f15d94b3024fd914640edf6e7c00985a0125d5a8e22e279e23b113bde9d2db2d4522f11b74203fa0edd0719b9ada4b456b6
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -19,11 +19,15 @@ gem 'hashid-rails'
|
|
19
19
|
|
20
20
|
And then execute:
|
21
21
|
|
22
|
-
|
22
|
+
```shell
|
23
|
+
$ bundle
|
24
|
+
```
|
23
25
|
|
24
26
|
Or install it yourself as:
|
25
27
|
|
26
|
-
|
28
|
+
```shell
|
29
|
+
$ gem install hashid-rails
|
30
|
+
```
|
27
31
|
|
28
32
|
## Usage
|
29
33
|
|
@@ -42,6 +46,9 @@ easily reverse engineer your ids, create an initializer and:
|
|
42
46
|
Hashid::Rails.configure do |config|
|
43
47
|
config.secret = 'my secret'
|
44
48
|
config.length = 6
|
49
|
+
# config.alphabet is optional, hashids provides a default
|
50
|
+
# alphabet that consists of all characters [a-zA-Z0-9]
|
51
|
+
config.alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
45
52
|
end
|
46
53
|
```
|
47
54
|
|
data/lib/hashid/rails.rb
CHANGED
@@ -38,7 +38,12 @@ module Hashid
|
|
38
38
|
def hashids
|
39
39
|
secret = Hashid::Rails.configuration.secret
|
40
40
|
length = Hashid::Rails.configuration.length
|
41
|
-
|
41
|
+
alphabet = Hashid::Rails.configuration.alphabet
|
42
|
+
|
43
|
+
arguments = ["#{table_name}#{secret}", length]
|
44
|
+
arguments << alphabet if alphabet.present?
|
45
|
+
|
46
|
+
Hashids.new(*arguments)
|
42
47
|
end
|
43
48
|
|
44
49
|
def encode_id(id)
|
@@ -61,11 +66,12 @@ module Hashid
|
|
61
66
|
end
|
62
67
|
|
63
68
|
class Configuration
|
64
|
-
attr_accessor :secret, :length
|
69
|
+
attr_accessor :secret, :length, :alphabet
|
65
70
|
|
66
71
|
def initialize
|
67
72
|
@secret = ''
|
68
73
|
@length = 6
|
74
|
+
@alphabet = nil
|
69
75
|
end
|
70
76
|
end
|
71
77
|
|
data/lib/hashid/rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hashid-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Cypret
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -124,8 +124,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.
|
127
|
+
rubygems_version: 2.5.1
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: Use Hashids in your Rails app models.
|
131
131
|
test_files: []
|
132
|
+
has_rdoc:
|