devision 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/devision.rb +1 -0
- data/lib/devision/models/config.rb +1 -1
- data/lib/devision/models/rememberable.rb +2 -2
- data/lib/devision/models/validatable.rb +41 -0
- data/lib/devision/version.rb +1 -1
- metadata +22 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0cb8c4125e19cd07b1d858d4cfec877a75ae8dde
|
4
|
+
data.tar.gz: 9b7d8a1a50ed31544983243d132136f3fb70d6c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 450a9ce4da6cc4862373a3802d8587b92d9dedaebadb8cb48c82a7e30fa7d6f38be94ae0ed2b0ce90195ac59e426613ee30b59f2871eba62f575454ad7a17764
|
7
|
+
data.tar.gz: c05e735692e10420a9fa4fa3d78af6ccc6e455702e303fe9f8f7500d6cf6dde0abdd4976b1823f84329ec0cbaaa8cdb1821a074d61d65571c59939475da99680
|
data/lib/devision.rb
CHANGED
@@ -13,6 +13,7 @@ module Devision
|
|
13
13
|
autoload :DatabaseAuthenticatable, 'devision/models/database_authenticatable'
|
14
14
|
autoload :Recoverable, 'devision/models/recoverable'
|
15
15
|
autoload :Rememberable, 'devision/models/rememberable'
|
16
|
+
autoload :Validatable, 'devision/models/validatable'
|
16
17
|
end
|
17
18
|
|
18
19
|
# Devision configuration settings (for initializers)
|
@@ -9,7 +9,7 @@ module Devision
|
|
9
9
|
#
|
10
10
|
# == Options
|
11
11
|
#
|
12
|
-
# Rememberable adds the following options in
|
12
|
+
# Rememberable adds the following options in to a model:
|
13
13
|
#
|
14
14
|
# * +remember_for+: the time you want the user will be remembered without
|
15
15
|
# asking for credentials. After this time the user will be blocked and
|
@@ -107,7 +107,7 @@ module Devision
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
|
110
|
+
Devision::Models::Config.add_options(self, :remember_for, :extend_remember_period, :rememberable_options)
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Devision
|
2
|
+
module Models
|
3
|
+
|
4
|
+
module Validatable
|
5
|
+
|
6
|
+
def self.required_fields(klass)
|
7
|
+
[]
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.included(base)
|
11
|
+
base.extend(ClassMethods)
|
12
|
+
base.class_eval do
|
13
|
+
validates_presence_of :email, if: :email_required?
|
14
|
+
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
15
|
+
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
|
16
|
+
|
17
|
+
validates_presence_of :password, if: :password_required?
|
18
|
+
validates_confirmation_of :password, if: :password_required?
|
19
|
+
validates_length_of :password, within: password_length, allow_blank: true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
|
25
|
+
# Password/Confirmation combo is required for:
|
26
|
+
# new records
|
27
|
+
# whenever either password or password_confirmation is set
|
28
|
+
def password_required?
|
29
|
+
!persisted || !password.nil? || !password_confirmation.nil?
|
30
|
+
end
|
31
|
+
|
32
|
+
def email_required?
|
33
|
+
true
|
34
|
+
end
|
35
|
+
|
36
|
+
module ClassMethods
|
37
|
+
Devision::Models::Config.add_options(self, :email_regexp, :password_length)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/devision/version.rb
CHANGED
metadata
CHANGED
@@ -1,117 +1,117 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Faucett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.6'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: 3.0.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 3.0.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: railties
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 3.2.6
|
62
|
-
- -
|
62
|
+
- - <
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '5'
|
65
65
|
type: :runtime
|
66
66
|
prerelease: false
|
67
67
|
version_requirements: !ruby/object:Gem::Requirement
|
68
68
|
requirements:
|
69
|
-
- -
|
69
|
+
- - '>='
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 3.2.6
|
72
|
-
- -
|
72
|
+
- - <
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '5'
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: orm_adapter
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
78
78
|
requirements:
|
79
|
-
- -
|
79
|
+
- - ~>
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0.5'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
|
-
- -
|
86
|
+
- - ~>
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: '0.5'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: bcrypt
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
|
-
- -
|
93
|
+
- - ~>
|
94
94
|
- !ruby/object:Gem::Version
|
95
95
|
version: '3.1'
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
|
-
- -
|
100
|
+
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '3.1'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: thread_safe
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ~>
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0.3'
|
110
110
|
type: :runtime
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
|
-
- -
|
114
|
+
- - ~>
|
115
115
|
- !ruby/object:Gem::Version
|
116
116
|
version: '0.3'
|
117
117
|
description:
|
@@ -121,7 +121,7 @@ executables: []
|
|
121
121
|
extensions: []
|
122
122
|
extra_rdoc_files: []
|
123
123
|
files:
|
124
|
-
-
|
124
|
+
- .gitignore
|
125
125
|
- Gemfile
|
126
126
|
- LICENSE.txt
|
127
127
|
- README.md
|
@@ -137,6 +137,7 @@ files:
|
|
137
137
|
- lib/devision/models/lockable.rb
|
138
138
|
- lib/devision/models/recoverable.rb
|
139
139
|
- lib/devision/models/rememberable.rb
|
140
|
+
- lib/devision/models/validatable.rb
|
140
141
|
- lib/devision/token_generator.rb
|
141
142
|
- lib/devision/version.rb
|
142
143
|
homepage:
|
@@ -149,12 +150,12 @@ require_paths:
|
|
149
150
|
- lib
|
150
151
|
required_ruby_version: !ruby/object:Gem::Requirement
|
151
152
|
requirements:
|
152
|
-
- -
|
153
|
+
- - '>='
|
153
154
|
- !ruby/object:Gem::Version
|
154
155
|
version: '0'
|
155
156
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
157
|
requirements:
|
157
|
-
- -
|
158
|
+
- - '>='
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
160
161
|
requirements: []
|