devise_suspendable 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,100 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionmailer (3.0.7)
6
+ actionpack (= 3.0.7)
7
+ mail (~> 2.2.15)
8
+ actionpack (3.0.7)
9
+ activemodel (= 3.0.7)
10
+ activesupport (= 3.0.7)
11
+ builder (~> 2.1.2)
12
+ erubis (~> 2.6.6)
13
+ i18n (~> 0.5.0)
14
+ rack (~> 1.2.1)
15
+ rack-mount (~> 0.6.14)
16
+ rack-test (~> 0.5.7)
17
+ tzinfo (~> 0.3.23)
18
+ activemodel (3.0.7)
19
+ activesupport (= 3.0.7)
20
+ builder (~> 2.1.2)
21
+ i18n (~> 0.5.0)
22
+ activerecord (3.0.7)
23
+ activemodel (= 3.0.7)
24
+ activesupport (= 3.0.7)
25
+ arel (~> 2.0.2)
26
+ tzinfo (~> 0.3.23)
27
+ activeresource (3.0.7)
28
+ activemodel (= 3.0.7)
29
+ activesupport (= 3.0.7)
30
+ activesupport (3.0.7)
31
+ arel (2.0.9)
32
+ bcrypt-ruby (2.1.4)
33
+ builder (2.1.2)
34
+ devise (1.3.3)
35
+ bcrypt-ruby (~> 2.1.2)
36
+ orm_adapter (~> 0.0.3)
37
+ warden (~> 1.0.3)
38
+ diff-lcs (1.1.2)
39
+ erubis (2.6.6)
40
+ abstract (>= 1.0.0)
41
+ git (1.2.5)
42
+ i18n (0.5.0)
43
+ jeweler (1.5.2)
44
+ bundler (~> 1.0.0)
45
+ git (>= 1.2.5)
46
+ rake
47
+ mail (2.2.19)
48
+ activesupport (>= 2.3.6)
49
+ i18n (>= 0.4.0)
50
+ mime-types (~> 1.16)
51
+ treetop (~> 1.4.8)
52
+ mime-types (1.16)
53
+ orm_adapter (0.0.4)
54
+ polyglot (0.3.1)
55
+ rack (1.2.2)
56
+ rack-mount (0.6.14)
57
+ rack (>= 1.0.0)
58
+ rack-test (0.5.7)
59
+ rack (>= 1.0)
60
+ rails (3.0.7)
61
+ actionmailer (= 3.0.7)
62
+ actionpack (= 3.0.7)
63
+ activerecord (= 3.0.7)
64
+ activeresource (= 3.0.7)
65
+ activesupport (= 3.0.7)
66
+ bundler (~> 1.0)
67
+ railties (= 3.0.7)
68
+ railties (3.0.7)
69
+ actionpack (= 3.0.7)
70
+ activesupport (= 3.0.7)
71
+ rake (>= 0.8.7)
72
+ thor (~> 0.14.4)
73
+ rake (0.8.7)
74
+ rcov (0.9.9)
75
+ rspec (2.5.0)
76
+ rspec-core (~> 2.5.0)
77
+ rspec-expectations (~> 2.5.0)
78
+ rspec-mocks (~> 2.5.0)
79
+ rspec-core (2.5.1)
80
+ rspec-expectations (2.5.0)
81
+ diff-lcs (~> 1.1.2)
82
+ rspec-mocks (2.5.0)
83
+ thor (0.14.6)
84
+ treetop (1.4.9)
85
+ polyglot (>= 0.3.1)
86
+ tzinfo (0.3.27)
87
+ warden (1.0.3)
88
+ rack (>= 1.0.0)
89
+
90
+ PLATFORMS
91
+ ruby
92
+
93
+ DEPENDENCIES
94
+ bundler (~> 1.0.0)
95
+ devise
96
+ jeweler (~> 1.5.2)
97
+ rails (>= 3.0.4)
98
+ rcov
99
+ rspec
100
+ warden
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -6,21 +6,15 @@ When an account is suspended the date and time of suspension is recorded, as wel
6
6
  == Setup
7
7
  (Assumes that you have devise already setup and your device models, e.g. User, are already created)
8
8
  1. Add `gem devise_suspendable` in your Gemfile
9
-
10
9
  2. Create a migration to update each of your device model(s), e.g. User, that you want to be suspendable
11
10
  rails g devise_suspendable User
12
-
13
11
  3. Run the migration
14
12
  rake db:migrate
15
-
16
13
  4. Mark the model as suspendable
17
-
18
- class User < ActiveRecord::Base
19
-
20
- devise ..., :activatable, :suspendable
21
-
22
- ...
23
- end
14
+ class User < ActiveRecord::Base
15
+ devise ..., :activatable, :suspendable
16
+ ...
17
+ end
24
18
 
25
19
  == Notes
26
20
  - :suspendable depends on :activatable
@@ -35,11 +29,6 @@ When an account is suspended the date and time of suspension is recorded, as wel
35
29
  * [Devise](http://github.com/plataformatec/devise)
36
30
  * [Warden](http://github.com/hassox/warden)
37
31
 
38
-
39
- == TODO
40
-
41
- - tests, tests, tests
42
-
43
32
  == Thanks to
44
33
  * Josh Kalderimis for most of core logic for this gem
45
34
  * devise_lastseenable[https://github.com/ctide/devise_lastseenable] for essentially operating as the base for this gem
data/Rakefile CHANGED
@@ -15,11 +15,10 @@ Jeweler::Tasks.new do |gem|
15
15
  gem.name = "devise_suspendable"
16
16
  gem.homepage = "http://github.com/amolk/devise_suspendable"
17
17
  gem.license = "MIT"
18
- gem.summary = %Q{Device module that provides a simple clean way to suspend an account}
19
- gem.description = %Q{Devise-Suspendable is a simple module which uses the [Devise](http://github.com/plataformatec/devise) authentication framework Activatable module hooks to provide a simple clean way to suspend an account.
20
- When an account is suspended the date and time of suspension is recorded, as well as an optional reason, for easy reference.}
18
+ gem.summary = %Q{Devise user account suspension module}
19
+ gem.description = %Q{Has a user left the organisation? Or maybe the account created was bogus? Remove access for a user with a click of a button}
21
20
  gem.email = "kelkar.amol@gmail.com"
22
- gem.authors = ["Amol Kelkar"]
21
+ gem.authors = ["Amol Kelkar", "Josh Kalderimis"]
23
22
  # Include your dependencies below. Runtime dependencies are required when using your gem,
24
23
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
24
  # gem.add_runtime_dependency 'jabber4r', '> 0.1'
@@ -48,4 +47,4 @@ Rake::RDocTask.new do |rdoc|
48
47
  rdoc.title = "devise_suspendable #{version}"
49
48
  rdoc.rdoc_files.include('README*')
50
49
  rdoc.rdoc_files.include('lib/**/*.rb')
51
- end
50
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.0
1
+ 0.6.1
@@ -0,0 +1,81 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{devise_suspendable}
8
+ s.version = "0.6.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Amol Kelkar", "Josh Kalderimis"]
12
+ s.date = %q{2011-04-27}
13
+ s.description = %q{Has a user left the organisation? Or maybe the account created was bogus? Remove access for a user with a click of a button}
14
+ s.email = %q{kelkar.amol@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "Gemfile.lock",
24
+ "LICENSE.txt",
25
+ "MIT-LICENSE",
26
+ "README.rdoc",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "devise_suspendable.gemspec",
30
+ "lib/devise_suspendable.rb",
31
+ "lib/devise_suspendable/model.rb",
32
+ "lib/devise_suspendable/rails.rb",
33
+ "lib/generators/devise_suspendable/.DS_Store",
34
+ "lib/generators/devise_suspendable/devise_suspendable_generator.rb",
35
+ "lib/generators/devise_suspendable/templates/.DS_Store",
36
+ "lib/generators/devise_suspendable/templates/migration.rb",
37
+ "rails/init.rb",
38
+ "spec/devise_suspendable_spec.rb",
39
+ "spec/spec_helper.rb"
40
+ ]
41
+ s.homepage = %q{http://github.com/amolk/devise_suspendable}
42
+ s.licenses = ["MIT"]
43
+ s.require_paths = ["lib"]
44
+ s.rubygems_version = %q{1.6.2}
45
+ s.summary = %q{Devise user account suspension module}
46
+ s.test_files = [
47
+ "spec/devise_suspendable_spec.rb",
48
+ "spec/spec_helper.rb"
49
+ ]
50
+
51
+ if s.respond_to? :specification_version then
52
+ s.specification_version = 3
53
+
54
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
55
+ s.add_runtime_dependency(%q<rails>, [">= 3.0.4"])
56
+ s.add_runtime_dependency(%q<warden>, [">= 0"])
57
+ s.add_runtime_dependency(%q<devise>, [">= 0"])
58
+ s.add_development_dependency(%q<rspec>, [">= 0"])
59
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
60
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
61
+ s.add_development_dependency(%q<rcov>, [">= 0"])
62
+ else
63
+ s.add_dependency(%q<rails>, [">= 3.0.4"])
64
+ s.add_dependency(%q<warden>, [">= 0"])
65
+ s.add_dependency(%q<devise>, [">= 0"])
66
+ s.add_dependency(%q<rspec>, [">= 0"])
67
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
68
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
69
+ s.add_dependency(%q<rcov>, [">= 0"])
70
+ end
71
+ else
72
+ s.add_dependency(%q<rails>, [">= 3.0.4"])
73
+ s.add_dependency(%q<warden>, [">= 0"])
74
+ s.add_dependency(%q<devise>, [">= 0"])
75
+ s.add_dependency(%q<rspec>, [">= 0"])
76
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
78
+ s.add_dependency(%q<rcov>, [">= 0"])
79
+ end
80
+ end
81
+
@@ -8,4 +8,4 @@ Devise.add_module :suspendable, :model => 'devise_suspendable/model'
8
8
  module DeviseSuspendable
9
9
  end
10
10
 
11
- require 'devise_suspendable/rails'
11
+ require 'devise_suspendable/rails'
@@ -0,0 +1,53 @@
1
+ module Devise
2
+ module Models
3
+ # Suspendable Module, responsible for manual deactivation of a user account.
4
+ #
5
+ # Examples:
6
+ #
7
+ # User.find(1).suspend!('Left the company')
8
+ #
9
+ module Suspendable
10
+ def self.included(base)
11
+ base.class_eval do
12
+ validates_length_of :suspension_reason, :maximum => 250
13
+
14
+ # basic sanitization
15
+ before_validation do |acc|
16
+ acc.suspension_reason.strip! if acc.suspension_reason
17
+ acc.suspension_reason = nil if acc.suspension_reason.blank?
18
+ acc.suspension_reason = nil if acc.suspended_at.blank?
19
+ end
20
+ end
21
+ end
22
+
23
+ def suspended?
24
+ self.suspended_at?
25
+ end
26
+
27
+ def suspend!(reason = nil)
28
+ return if suspended?
29
+ self.suspended_at = Time.zone.now
30
+ self.suspension_reason = reason
31
+ self.save(:validate => false)
32
+ end
33
+
34
+ def unsuspend!
35
+ return if !suspended?
36
+ self.suspended_at = nil
37
+ self.suspension_reason = nil
38
+ self.save(:validate => false) if self.changed?
39
+ end
40
+
41
+ # override Activatable
42
+ def active?
43
+ super && !suspended?
44
+ end
45
+
46
+ # Overwrites invalid_message from Devise::Models::Authenticatable to define
47
+ # the correct reason for blocking the sign in.
48
+ def inactive_message
49
+ suspended? ? :suspended : super
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,6 @@
1
+ require 'devise_suspendable'
2
+
3
+ module DeviseSuspendable
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,31 @@
1
+ require 'rails/generators/migration'
2
+
3
+ class DeviseSuspendableGenerator < Rails::Generators::NamedBase
4
+ include Rails::Generators::Migration
5
+
6
+ def self.source_root
7
+ @_devise_source_root ||= File.expand_path("../templates", __FILE__)
8
+ end
9
+
10
+ def self.orm_has_migration?
11
+ Rails::Generators.options[:rails][:orm] == :active_record
12
+ end
13
+
14
+ def self.next_migration_number(dirname)
15
+ if ActiveRecord::Base.timestamped_migrations
16
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
17
+ else
18
+ "%.3d" % (current_migration_number(dirname) + 1)
19
+ end
20
+ end
21
+
22
+ class_option :orm
23
+ class_option :migration, :type => :boolean, :default => orm_has_migration?
24
+
25
+
26
+ def create_migration_file
27
+ migration_template 'migration.rb', "db/migrate/devise_add_suspendable_#{name.downcase}.rb"
28
+ end
29
+
30
+ protected
31
+ end
@@ -0,0 +1,11 @@
1
+ class DeviseAddSuspendable<%= table_name.camelize.singularize %> < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :<%= table_name %>, :suspended_at, :datetime, :null => true, :default => nil
4
+ add_column :<%= table_name %>, :suspension_reason, :string, :null => true, :default => nil
5
+ end
6
+
7
+ def self.down
8
+ remove_column :<%= table_name %>, :suspended_at
9
+ remove_column :<%= table_name %>, :suspension_reason
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ require 'devise_suspendable'
metadata CHANGED
@@ -2,10 +2,11 @@
2
2
  name: devise_suspendable
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 0.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Amol Kelkar
9
+ - Josh Kalderimis
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
@@ -90,9 +91,7 @@ dependencies:
90
91
  type: :development
91
92
  prerelease: false
92
93
  version_requirements: *id007
93
- description: |-
94
- Devise-Suspendable is a simple module which uses the [Devise](http://github.com/plataformatec/devise) authentication framework Activatable module hooks to provide a simple clean way to suspend an account.
95
- When an account is suspended the date and time of suspension is recorded, as well as an optional reason, for easy reference.
94
+ description: Has a user left the organisation? Or maybe the account created was bogus? Remove access for a user with a click of a button
96
95
  email: kelkar.amol@gmail.com
97
96
  executables: []
98
97
 
@@ -105,11 +104,21 @@ files:
105
104
  - .document
106
105
  - .rspec
107
106
  - Gemfile
107
+ - Gemfile.lock
108
108
  - LICENSE.txt
109
+ - MIT-LICENSE
109
110
  - README.rdoc
110
111
  - Rakefile
111
112
  - VERSION
113
+ - devise_suspendable.gemspec
112
114
  - lib/devise_suspendable.rb
115
+ - lib/devise_suspendable/model.rb
116
+ - lib/devise_suspendable/rails.rb
117
+ - lib/generators/devise_suspendable/.DS_Store
118
+ - lib/generators/devise_suspendable/devise_suspendable_generator.rb
119
+ - lib/generators/devise_suspendable/templates/.DS_Store
120
+ - lib/generators/devise_suspendable/templates/migration.rb
121
+ - rails/init.rb
113
122
  - spec/devise_suspendable_spec.rb
114
123
  - spec/spec_helper.rb
115
124
  has_rdoc: true
@@ -126,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
126
135
  requirements:
127
136
  - - ">="
128
137
  - !ruby/object:Gem::Version
129
- hash: -736303433424034158
138
+ hash: 2894843038137255541
130
139
  segments:
131
140
  - 0
132
141
  version: "0"
@@ -142,7 +151,7 @@ rubyforge_project:
142
151
  rubygems_version: 1.6.2
143
152
  signing_key:
144
153
  specification_version: 3
145
- summary: Device module that provides a simple clean way to suspend an account
154
+ summary: Devise user account suspension module
146
155
  test_files:
147
156
  - spec/devise_suspendable_spec.rb
148
157
  - spec/spec_helper.rb