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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71c60b5b414a413c97192b5c81cc6c0495a71a06
4
- data.tar.gz: d4e88b4c3ee0ff8a1412eb19cf7bbae4ee29ed37
3
+ metadata.gz: 55e2d11c97ee9f402b01c2acd5979cceb445e129
4
+ data.tar.gz: 547037c91e5c315fef7d3b8e555ed4b4c2e78dae
5
5
  SHA512:
6
- metadata.gz: c27cbfdf204ae0227beccdc6efeeec7544bb4f283fbe939c67b9266e6fa818f5878f8a49f99edec0b4e409c7b1559e725923c4ea5166abd11395a2e6acaa4ed2
7
- data.tar.gz: 39ef44045dd17fd962d869a8cad31ccd0593b9be32bc07cd1fd1f3a5c03ce83ee12a62740070c696a8605c616c1fcdb5cc5035ad80ef90e2067363c55fca0822
6
+ metadata.gz: 0966a9aa4f6a805f6a2cad08a1afbf70c9939718f9c289c7319649fdbc7c58396f04b7c49a064044915dc93c699747bfe87ad2cfe76badc1f45cbaccad57a77f
7
+ data.tar.gz: 02eecb588c3333c2b97f872da37d1f15d94b3024fd914640edf6e7c00985a0125d5a8e22e279e23b113bde9d2db2d4522f11b74203fa0edd0719b9ada4b456b6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2016-03-10)
4
+ - Customize the alphabet used for Hashids
5
+
3
6
  ## 0.2.0 (2016-01-02)
4
7
 
5
8
  - Customize the Hashid seed and length using a configuration initializer.
data/README.md CHANGED
@@ -19,11 +19,15 @@ gem 'hashid-rails'
19
19
 
20
20
  And then execute:
21
21
 
22
- $ bundle
22
+ ```shell
23
+ $ bundle
24
+ ```
23
25
 
24
26
  Or install it yourself as:
25
27
 
26
- $ gem install hashid-rails
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
- Hashids.new("#{table_name}#{secret}", length)
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
 
@@ -1,5 +1,5 @@
1
1
  module Hashid
2
2
  module Rails
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
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.2.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-01-03 00:00:00.000000000 Z
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.4.5
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: