acts_as_hashed 0.0.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +14 -0
- data/lib/acts_as_hashed.rb +1 -1
- data/lib/acts_as_hashed/version.rb +1 -1
- data/spec/acts_as_hashed_spec.rb +21 -0
- metadata +25 -10
data/README.md
CHANGED
@@ -44,6 +44,20 @@ class Seller < ActiveRecord::Base
|
|
44
44
|
end
|
45
45
|
```
|
46
46
|
|
47
|
+
or you can overwrite the method that will generate the hash.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
class Seller < ActiveRecord::Base
|
51
|
+
acts_as_hashed
|
52
|
+
|
53
|
+
class << self
|
54
|
+
def friendly_token
|
55
|
+
SecureRandom.hex(5)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
47
61
|
## Contributing
|
48
62
|
|
49
63
|
1. Fork it
|
data/lib/acts_as_hashed.rb
CHANGED
data/spec/acts_as_hashed_spec.rb
CHANGED
@@ -9,11 +9,22 @@ FileUtils.rm_f DB_FILE
|
|
9
9
|
|
10
10
|
ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => DB_FILE
|
11
11
|
ActiveRecord::Base.connection.execute 'CREATE TABLE some_models (id INTEGER NOT NULL PRIMARY KEY, hashed_code string)'
|
12
|
+
ActiveRecord::Base.connection.execute 'CREATE TABLE overwrited_models (id INTEGER NOT NULL PRIMARY KEY, hashed_code string)'
|
12
13
|
|
13
14
|
class SomeModel < ActiveRecord::Base
|
14
15
|
acts_as_hashed
|
15
16
|
end
|
16
17
|
|
18
|
+
class OverwritedModel < ActiveRecord::Base
|
19
|
+
acts_as_hashed
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def friendly_token
|
23
|
+
SecureRandom.hex(5)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
17
28
|
describe ActsAsHashed do
|
18
29
|
before(:each) do
|
19
30
|
clean_database!
|
@@ -40,4 +51,14 @@ describe ActsAsHashed do
|
|
40
51
|
}.to_not change(model, :hashed_code)
|
41
52
|
end
|
42
53
|
end
|
54
|
+
context "overwrite friendly_token" do
|
55
|
+
let!(:model) do
|
56
|
+
model = OverwritedModel.new
|
57
|
+
model.save
|
58
|
+
model
|
59
|
+
end
|
60
|
+
it "should have hashed_code with lenght 10" do
|
61
|
+
model.hashed_code.length.should == 10
|
62
|
+
end
|
63
|
+
end
|
43
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_hashed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,27 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- - =
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: 2.11.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.11.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: sqlite3
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :development
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: activerecord
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: 3.0.0
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.0.0
|
47
62
|
description: ActsAsHashed is helpful to set a hash_code column based on SecureRandom.hex(16).
|
48
63
|
email:
|
49
64
|
- rodrigopqn@gmail.com
|
@@ -84,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
84
99
|
version: '0'
|
85
100
|
requirements: []
|
86
101
|
rubyforge_project:
|
87
|
-
rubygems_version: 1.8.
|
102
|
+
rubygems_version: 1.8.24
|
88
103
|
signing_key:
|
89
104
|
specification_version: 3
|
90
105
|
summary: SecureRandom hex generator for hashed_code column.
|