devision 0.0.2.9 → 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/.envrc +1 -0
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/POST_INSTALL_MESSAGE +1 -0
- data/bin/rspec +16 -0
- data/devision.gemspec +13 -9
- data/lib/devision/configuration_options.rb +3 -6
- data/lib/devision/models/validatable.rb +35 -21
- data/lib/devision/version.rb +11 -3
- data/spec/devision_spec.rb +18 -0
- data/spec/spec_helper.rb +8 -0
- metadata +18 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f06d18b5d5046d3909518b72ac9ba7b0dd330ee3
|
4
|
+
data.tar.gz: 904a96ccfba3ceacab4d1d54418ab98b8b7203b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9cd8ec92036b4d24a4d4d90c72d87e785c59dbd920420ea797fd91831008b069d92e7d90444abb8141663972e0657317f9086bcb44784a25cc8066e60a4499d
|
7
|
+
data.tar.gz: e9b63cc0a1b998b590240fe10c3bf5e17a2357b9571d05c606bd2c9f53160836b2a53978b8feae4f2215507fa5e732a405876b62faf794d2be08c158485b1ae6
|
data/.envrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export PATH=$PWD/bin:$PATH
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Thanks for installing Devision!
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/devision.gemspec
CHANGED
@@ -1,29 +1,33 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
-
|
3
|
-
$:.unshift(lib) unless $:.include?(lib)
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
4
3
|
require 'devision/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
6
|
+
|
7
|
+
# metadata
|
7
8
|
spec.name = 'devision'
|
8
9
|
spec.version = Devision::VERSION::STRING
|
9
10
|
spec.authors = ['John Faucett']
|
10
11
|
spec.email = ['jwaterfaucett@gmail.com']
|
11
12
|
spec.summary = 'Devise on a Diet'
|
12
13
|
spec.license = 'MIT'
|
14
|
+
spec.require_paths = ['lib']
|
15
|
+
spec.platform = Gem::Platform::RUBY
|
16
|
+
spec.post_install_message = File.read('./POST_INSTALL_MESSAGE')
|
13
17
|
|
18
|
+
# files
|
14
19
|
spec.files = `git ls-files -z`.split("\x0")
|
15
20
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
21
|
spec.test_files = spec.files.grep(%r{^(spec|features)/})
|
17
22
|
spec.require_paths = ["lib"]
|
18
23
|
|
19
|
-
|
24
|
+
# dependencies
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
20
26
|
spec.add_development_dependency 'rake'
|
21
|
-
|
22
27
|
spec.add_development_dependency 'rspec', '~> 3.0.0'
|
23
|
-
|
24
|
-
spec.
|
25
|
-
spec.
|
26
|
-
spec.
|
27
|
-
spec.add_dependency 'thread_safe', '~> 0.3'
|
28
|
+
spec.add_runtime_dependency 'railties', '>= 3.2.6', '< 5'
|
29
|
+
spec.add_runtime_dependency 'orm_adapter', '~> 0.5'
|
30
|
+
spec.add_runtime_dependency 'bcrypt', '~> 3.1'
|
31
|
+
spec.add_runtime_dependency 'thread_safe', '~> 0.3'
|
28
32
|
|
29
33
|
end
|
@@ -20,7 +20,7 @@ module Devision
|
|
20
20
|
mattr_accessor :reset_password_within
|
21
21
|
@@reset_password_within = 6.hours
|
22
22
|
|
23
|
-
|
23
|
+
|
24
24
|
# Email regex used to validate email formats. It simply asserts that
|
25
25
|
# an one (and only one) @ exists in the given string. This is mainly
|
26
26
|
# to give user feedback and not to assert the e-mail validity.
|
@@ -28,16 +28,13 @@ module Devision
|
|
28
28
|
@@email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\s]+\z/
|
29
29
|
|
30
30
|
# Range validation for password length
|
31
|
-
mattr_accessor :
|
32
|
-
@@
|
31
|
+
mattr_accessor :password_range
|
32
|
+
@@password_range = 6..128
|
33
33
|
|
34
34
|
# ======================
|
35
35
|
# REMEMBERABLE OPTIONS
|
36
36
|
# ======================
|
37
37
|
|
38
|
-
# Custom domain or key for cookies. Not set by default
|
39
|
-
# mattr_accessor :rememberable_options
|
40
|
-
# @@rememberable_options = {}
|
41
38
|
|
42
39
|
# The time the user will be remembered without asking for credentials again.
|
43
40
|
mattr_accessor :remember_for
|
@@ -3,44 +3,58 @@ module Devision
|
|
3
3
|
|
4
4
|
module Validatable
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
def self.included(base)
|
11
|
-
base.extend(ClassMethods)
|
12
|
-
base.class_eval do
|
6
|
+
module Email
|
7
|
+
def self.required_fields(klass)
|
8
|
+
[:email]
|
9
|
+
end
|
13
10
|
|
14
|
-
|
11
|
+
def self.included(base)
|
12
|
+
base.extend(ClassMethods)
|
13
|
+
base.class_eval do
|
15
14
|
validates_presence_of :email, if: :email_required?
|
16
15
|
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
|
17
16
|
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
|
18
17
|
end
|
19
18
|
|
20
|
-
|
21
|
-
|
22
|
-
validates_confirmation_of :password, if: :password_required?
|
23
|
-
validates_length_of :password, within: password_length, allow_blank: true
|
19
|
+
def email_required?
|
20
|
+
true
|
24
21
|
end
|
25
22
|
end
|
23
|
+
|
24
|
+
module ClassMethods
|
25
|
+
Devision::Models::Config.add_options(self, :email_regexp)
|
26
|
+
end
|
26
27
|
end
|
27
28
|
|
28
|
-
|
29
|
+
module Password
|
30
|
+
def self.required_fields(klass)
|
31
|
+
[:password]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.included(base)
|
35
|
+
|
36
|
+
base.extend(ClassMethods)
|
37
|
+
base.class_eval do
|
38
|
+
validates_presence_of :password, if: :password_required?
|
39
|
+
validates_confirmation_of :password, if: :password_required?
|
40
|
+
validates_length_of :password, within: password_range, allow_blank: true
|
41
|
+
end
|
42
|
+
end
|
29
43
|
|
30
44
|
# Password/Confirmation combo is required for:
|
31
45
|
# new records
|
32
46
|
# whenever either password or password_confirmation is set
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
def email_required?
|
38
|
-
true
|
39
|
-
end
|
47
|
+
private
|
48
|
+
def password_required?
|
49
|
+
!persisted? || !password.nil? || !password_confirmation.nil?
|
50
|
+
end
|
40
51
|
|
41
52
|
module ClassMethods
|
42
|
-
Devision::Models::Config.add_options(self, :
|
53
|
+
Devision::Models::Config.add_options(self, :password_range)
|
43
54
|
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
44
58
|
end
|
45
59
|
end
|
46
60
|
end
|
data/lib/devision/version.rb
CHANGED
@@ -7,9 +7,17 @@ module Devision
|
|
7
7
|
|
8
8
|
MAJOR = 0
|
9
9
|
MINOR = 0
|
10
|
-
PATCH =
|
11
|
-
PRE =
|
10
|
+
PATCH = 3
|
11
|
+
PRE = 0
|
12
12
|
|
13
|
-
STRING = [MAJOR,MINOR,PATCH,PRE].compact.join('.').freeze
|
13
|
+
STRING = [MAJOR, MINOR, PATCH, PRE].compact.join('.').freeze
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.gem_version
|
17
|
+
VERSION.gem_version
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.version
|
21
|
+
VERSION::STRING
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Devision do
|
4
|
+
|
5
|
+
describe '#nice_token' do
|
6
|
+
|
7
|
+
it 'should generate a token 20 chars long without O0lI' do
|
8
|
+
100.times do
|
9
|
+
tkn = Devision.nice_token
|
10
|
+
expect(tkn.length).to eq(20)
|
11
|
+
'O0lI'.each_char do |ch|
|
12
|
+
expect(tkn.index(ch)).to be(nil)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3.0
|
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-
|
11
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.7'
|
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
|
-
version: '1.
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,15 +117,21 @@ dependencies:
|
|
117
117
|
description:
|
118
118
|
email:
|
119
119
|
- jwaterfaucett@gmail.com
|
120
|
-
executables:
|
120
|
+
executables:
|
121
|
+
- rspec
|
121
122
|
extensions: []
|
122
123
|
extra_rdoc_files: []
|
123
124
|
files:
|
125
|
+
- .envrc
|
124
126
|
- .gitignore
|
127
|
+
- .rspec
|
128
|
+
- .travis.yml
|
125
129
|
- Gemfile
|
126
130
|
- LICENSE.txt
|
131
|
+
- POST_INSTALL_MESSAGE
|
127
132
|
- README.md
|
128
133
|
- Rakefile
|
134
|
+
- bin/rspec
|
129
135
|
- devision.gemspec
|
130
136
|
- lib/devision.rb
|
131
137
|
- lib/devision/configuration_options.rb
|
@@ -140,11 +146,14 @@ files:
|
|
140
146
|
- lib/devision/models/validatable.rb
|
141
147
|
- lib/devision/token_generator.rb
|
142
148
|
- lib/devision/version.rb
|
149
|
+
- spec/devision_spec.rb
|
150
|
+
- spec/spec_helper.rb
|
143
151
|
homepage:
|
144
152
|
licenses:
|
145
153
|
- MIT
|
146
154
|
metadata: {}
|
147
|
-
post_install_message:
|
155
|
+
post_install_message: |
|
156
|
+
Thanks for installing Devision!
|
148
157
|
rdoc_options: []
|
149
158
|
require_paths:
|
150
159
|
- lib
|
@@ -164,4 +173,6 @@ rubygems_version: 2.4.1
|
|
164
173
|
signing_key:
|
165
174
|
specification_version: 4
|
166
175
|
summary: Devise on a Diet
|
167
|
-
test_files:
|
176
|
+
test_files:
|
177
|
+
- spec/devision_spec.rb
|
178
|
+
- spec/spec_helper.rb
|