devise_suspendable 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rails', ">= 3.0.4"
4
+ gem 'warden'
5
+ gem 'devise'
6
+
7
+ group :development do
8
+ gem "rspec"
9
+ gem "bundler", "~> 1.0.0"
10
+ gem "jeweler", "~> 1.5.2"
11
+ gem "rcov", ">= 0"
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010, 2011 Josh Kalderimis, Amol Kelkar
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.
data/README.rdoc ADDED
@@ -0,0 +1,51 @@
1
+ = devise_suspendable
2
+
3
+ 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.
4
+ When an account is suspended the date and time of suspension is recorded, as well as an optional reason, for easy reference.
5
+
6
+ == Setup
7
+ (Assumes that you have devise already setup and your device models, e.g. User, are already created)
8
+ 1. Add `gem devise_suspendable` in your Gemfile
9
+
10
+ 2. Create a migration to update each of your device model(s), e.g. User, that you want to be suspendable
11
+ rails g devise_suspendable User
12
+
13
+ 3. Run the migration
14
+ rake db:migrate
15
+
16
+ 4. Mark the model as suspendable
17
+
18
+ class User < ActiveRecord::Base
19
+
20
+ devise ..., :activatable, :suspendable
21
+
22
+ ...
23
+ end
24
+
25
+ == Notes
26
+ - :suspendable depends on :activatable
27
+
28
+ - This plugin is similar to Lockable and can be used along side it, as long as Lockable is using token or timeouts as the unlock strategy. Lockable is great for failed login tracking, and subsequent locking, suspendable is best for manual account suspension
29
+
30
+ - Maintaining your active users is part and parcel of running a web app
31
+
32
+
33
+ == References
34
+
35
+ * [Devise](http://github.com/plataformatec/devise)
36
+ * [Warden](http://github.com/hassox/warden)
37
+
38
+
39
+ == TODO
40
+
41
+ - tests, tests, tests
42
+
43
+ == Thanks to
44
+ * Josh Kalderimis for most of core logic for this gem
45
+ * devise_lastseenable[https://github.com/ctide/devise_lastseenable] for essentially operating as the base for this gem
46
+ * Jeweler[https://github.com/technicalpickles/jeweler] for making it dead simple to write this gem
47
+
48
+
49
+ Released under the MIT license
50
+
51
+ Copyright (c) 2010, 2011 Josh Kalderimis, Amol Kelkar
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "devise_suspendable"
16
+ gem.homepage = "http://github.com/amolk/devise_suspendable"
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.}
21
+ gem.email = "kelkar.amol@gmail.com"
22
+ gem.authors = ["Amol Kelkar"]
23
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
24
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
25
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
26
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
27
+ end
28
+ Jeweler::RubygemsDotOrgTasks.new
29
+
30
+ require 'rspec/core'
31
+ require 'rspec/core/rake_task'
32
+ RSpec::Core::RakeTask.new(:spec) do |spec|
33
+ spec.pattern = FileList['spec/**/*_spec.rb']
34
+ end
35
+
36
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
37
+ spec.pattern = 'spec/**/*_spec.rb'
38
+ spec.rcov = true
39
+ end
40
+
41
+ task :default => :spec
42
+
43
+ require 'rake/rdoctask'
44
+ Rake::RDocTask.new do |rdoc|
45
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
46
+
47
+ rdoc.rdoc_dir = 'rdoc'
48
+ rdoc.title = "devise_suspendable #{version}"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.6.0
@@ -0,0 +1,11 @@
1
+ unless defined?(Devise)
2
+ require 'devise'
3
+ end
4
+ require 'devise_suspendable'
5
+
6
+ Devise.add_module :suspendable, :model => 'devise_suspendable/model'
7
+
8
+ module DeviseSuspendable
9
+ end
10
+
11
+ require 'devise_suspendable/rails'
@@ -0,0 +1,32 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "DeviseSuspendable" do
4
+ it 'cannot run tests here' do
5
+ pending "copy this file to your project as /spec/models/suspendable_user_spec.rb and run as part of your project's specs. The spec code depends on FactoryGirl gem and a valid :user factory defined."
6
+ end
7
+
8
+ it 'is not in suspended state when created fresh' do
9
+ user = Factory(:user)
10
+ user.should_not be_suspended
11
+ user.should be_active
12
+ end
13
+
14
+ it 'can be suspended' do
15
+ user = Factory(:user)
16
+ user.suspend!("has too many 'family members'")
17
+ user.should be_suspended
18
+ user.should_not be_active
19
+ end
20
+
21
+ it 'can be unsuspended' do
22
+ user = Factory(:user, :suspended_at => 1.day.ago)
23
+ user.should be_suspended
24
+ user.should_not be_active
25
+
26
+ user.unsuspend!
27
+
28
+ user.should_not be_suspended
29
+ user.should be_active
30
+ end
31
+
32
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'devise_suspendable'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_suspendable
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.6.0
6
+ platform: ruby
7
+ authors:
8
+ - Amol Kelkar
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-27 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 3.0.4
24
+ type: :runtime
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: warden
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: devise
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: bundler
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: 1.0.0
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: jeweler
73
+ requirement: &id006 !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ~>
77
+ - !ruby/object:Gem::Version
78
+ version: 1.5.2
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: rcov
84
+ requirement: &id007 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ type: :development
91
+ prerelease: false
92
+ 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.
96
+ email: kelkar.amol@gmail.com
97
+ executables: []
98
+
99
+ extensions: []
100
+
101
+ extra_rdoc_files:
102
+ - LICENSE.txt
103
+ - README.rdoc
104
+ files:
105
+ - .document
106
+ - .rspec
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.rdoc
110
+ - Rakefile
111
+ - VERSION
112
+ - lib/devise_suspendable.rb
113
+ - spec/devise_suspendable_spec.rb
114
+ - spec/spec_helper.rb
115
+ has_rdoc: true
116
+ homepage: http://github.com/amolk/devise_suspendable
117
+ licenses:
118
+ - MIT
119
+ post_install_message:
120
+ rdoc_options: []
121
+
122
+ require_paths:
123
+ - lib
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ none: false
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ hash: -736303433424034158
130
+ segments:
131
+ - 0
132
+ version: "0"
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: "0"
139
+ requirements: []
140
+
141
+ rubyforge_project:
142
+ rubygems_version: 1.6.2
143
+ signing_key:
144
+ specification_version: 3
145
+ summary: Device module that provides a simple clean way to suspend an account
146
+ test_files:
147
+ - spec/devise_suspendable_spec.rb
148
+ - spec/spec_helper.rb