mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Remove data_mapper support.
Devise 1.1.0 will be released soon. This new version will support activerecord and mongoid as default ORMs. From now on, Devise will prefer ORM extensions as gems since this is the best way to handle dependencies. For example, to allow Devise to work with Datamapper, it requires at least activemodel, dm-rails and dm-timestamps. If the ORM support comes from Devise gem, we cannot add dm-rails and dm-timestamps as dependencies, relying on the developer and documentation to find these out and install them. Other ORMs may still be added to Devise, as long as they are supported by the community, extend Devise test suite to have all tests passing and they necessarily use ActiveModel::Validations.
This commit is contained in:
parent
6c49b428b3
commit
7774accb6c
10 changed files with 5 additions and 274 deletions
|
@ -38,7 +38,7 @@
|
|||
* E-mails now use any template available in the filesystem. Easy to create multipart e-mails
|
||||
* E-mails asks headers_for in the model to set the proper headers
|
||||
* Allow to specify haml in devise_views
|
||||
* Compatibility with Datamapper and Mongoid
|
||||
* Compatibility with Mongoid
|
||||
* Make config.devise available on config/application.rb
|
||||
* TokenAuthenticatable now works with HTTP Basic Auth
|
||||
* Allow :unlock_strategy to be :none and add :lock_strategy which can be :failed_attempts or none. Setting those values to :none means that you want to handle lock and unlocking by yourself
|
||||
|
|
12
Gemfile
12
Gemfile
|
@ -20,14 +20,4 @@ group :mongoid do
|
|||
gem "mongo"
|
||||
gem "mongoid", :git => "git://github.com/durran/mongoid.git"
|
||||
gem "bson_ext"
|
||||
end
|
||||
|
||||
group :data_mapper do
|
||||
gem 'dm-core', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-core'
|
||||
gem 'dm-migrations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-migrations'
|
||||
gem 'dm-sqlite-adapter', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-sqlite-adapter'
|
||||
gem 'dm-validations', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-validations'
|
||||
gem 'dm-serializer', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-serializer'
|
||||
gem 'dm-timestamps', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-timestamps'
|
||||
gem 'dm-rails', '~> 1.0.0', :git => 'git://github.com/datamapper/dm-rails'
|
||||
end
|
||||
end
|
114
Gemfile.lock
114
Gemfile.lock
|
@ -1,82 +1,3 @@
|
|||
GIT
|
||||
remote: git://github.com/datamapper/dm-core
|
||||
revision: 40ff12e
|
||||
specs:
|
||||
dm-core (1.0.0)
|
||||
addressable (~> 2.1)
|
||||
extlib (~> 0.9.15)
|
||||
dm-core (1.0.0)
|
||||
addressable (~> 2.1)
|
||||
extlib (~> 0.9.15)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-migrations
|
||||
revision: c72ba40
|
||||
specs:
|
||||
dm-migrations (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-migrations (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-rails
|
||||
revision: 8bf64e7
|
||||
specs:
|
||||
dm-rails (1.0.0)
|
||||
actionpack (~> 3.0.0.beta3)
|
||||
activesupport (~> 3.0.0.beta3)
|
||||
dm-active_model (~> 1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
railties (~> 3.0.0.beta3)
|
||||
dm-rails (1.0.0)
|
||||
actionpack (~> 3.0.0.beta3)
|
||||
activesupport (~> 3.0.0.beta3)
|
||||
dm-active_model (~> 1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
railties (~> 3.0.0.beta3)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-serializer
|
||||
revision: 1f0f617
|
||||
specs:
|
||||
dm-serializer (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
fastercsv (~> 1.5.3)
|
||||
json_pure (~> 1.4.3)
|
||||
dm-serializer (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
fastercsv (~> 1.5.3)
|
||||
json_pure (~> 1.4.3)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-sqlite-adapter
|
||||
revision: 2a8562b
|
||||
specs:
|
||||
dm-sqlite-adapter (1.0.0)
|
||||
dm-do-adapter (~> 1.0.0)
|
||||
do_sqlite3 (~> 0.10.2)
|
||||
dm-sqlite-adapter (1.0.0)
|
||||
dm-do-adapter (~> 1.0.0)
|
||||
do_sqlite3 (~> 0.10.2)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-timestamps
|
||||
revision: 791bad7
|
||||
specs:
|
||||
dm-timestamps (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-timestamps (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/datamapper/dm-validations
|
||||
revision: c793091
|
||||
specs:
|
||||
dm-validations (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-validations (1.0.0)
|
||||
dm-core (~> 1.0.0)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/durran/mongoid.git
|
||||
revision: 79b4d37
|
||||
|
@ -179,8 +100,6 @@ GEM
|
|||
specs:
|
||||
abstract (1.0.0)
|
||||
abstract (1.0.0)
|
||||
addressable (2.1.2)
|
||||
addressable (2.1.2)
|
||||
arel (0.4.0)
|
||||
activesupport (>= 3.0.0.beta)
|
||||
arel (0.4.0)
|
||||
|
@ -195,38 +114,12 @@ GEM
|
|||
builder (2.1.2)
|
||||
columnize (0.3.1)
|
||||
columnize (0.3.1)
|
||||
data_objects (0.10.2)
|
||||
addressable (~> 2.1)
|
||||
data_objects (0.10.2)
|
||||
addressable (~> 2.1)
|
||||
dm-active_model (1.0.0)
|
||||
activemodel (~> 3.0.0.beta3)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-active_model (1.0.0)
|
||||
activemodel (~> 3.0.0.beta3)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-do-adapter (1.0.0)
|
||||
data_objects (~> 0.10.1)
|
||||
dm-core (~> 1.0.0)
|
||||
dm-do-adapter (1.0.0)
|
||||
data_objects (~> 0.10.1)
|
||||
dm-core (~> 1.0.0)
|
||||
do_sqlite3 (0.10.2)
|
||||
data_objects (= 0.10.2)
|
||||
do_sqlite3 (0.10.2)
|
||||
data_objects (= 0.10.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
extlib (0.9.15)
|
||||
extlib (0.9.15)
|
||||
fastercsv (1.5.3)
|
||||
fastercsv (1.5.3)
|
||||
i18n (0.4.1)
|
||||
i18n (0.4.1)
|
||||
json_pure (1.4.3)
|
||||
json_pure (1.4.3)
|
||||
linecache (0.43)
|
||||
linecache (0.43)
|
||||
mail (2.2.5)
|
||||
|
@ -300,13 +193,6 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
bcrypt-ruby
|
||||
bson_ext
|
||||
dm-core (~> 1.0.0)!
|
||||
dm-migrations (~> 1.0.0)!
|
||||
dm-rails (~> 1.0.0)!
|
||||
dm-serializer (~> 1.0.0)!
|
||||
dm-sqlite-adapter (~> 1.0.0)!
|
||||
dm-timestamps (~> 1.0.0)!
|
||||
dm-validations (~> 1.0.0)!
|
||||
mocha
|
||||
mongo
|
||||
mongoid!
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
module Devise
|
||||
module Orm
|
||||
module DataMapper
|
||||
module Hook
|
||||
def devise_modules_hook!
|
||||
extend Schema
|
||||
include Compatibility
|
||||
yield
|
||||
return unless Devise.apply_schema
|
||||
devise_modules.each { |m| send(m) if respond_to?(m, true) }
|
||||
end
|
||||
end
|
||||
|
||||
module Schema
|
||||
include Devise::Schema
|
||||
|
||||
SCHEMA_OPTIONS = {
|
||||
:null => :required,
|
||||
:limit => :length
|
||||
}
|
||||
|
||||
# Tell how to apply schema methods. This automatically maps :limit to
|
||||
# :length and :null to :required.
|
||||
def apply_devise_schema(name, type, options={})
|
||||
SCHEMA_OPTIONS.each do |old_key, new_key|
|
||||
next unless options.key?(old_key)
|
||||
options[new_key] = options.delete(old_key)
|
||||
end
|
||||
|
||||
options.delete(:default) if options[:default].nil?
|
||||
property name, type, options
|
||||
end
|
||||
end
|
||||
|
||||
module Compatibility
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
module ClassMethods
|
||||
# Hooks for confirmable
|
||||
def before_create(*args)
|
||||
wrap_hook(:before, :create, *args)
|
||||
end
|
||||
|
||||
def after_create(*args)
|
||||
wrap_hook(:after, :create, *args)
|
||||
end
|
||||
|
||||
def before_save(*args)
|
||||
wrap_hook(:before, :save, *args)
|
||||
end
|
||||
|
||||
def wrap_hook(action, method, *args)
|
||||
options = args.extract_options!
|
||||
|
||||
args.each do |callback|
|
||||
send action, method, callback
|
||||
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
||||
def #{callback}
|
||||
super if #{options[:if] || true}
|
||||
end
|
||||
METHOD
|
||||
end
|
||||
end
|
||||
|
||||
# Add ActiveRecord like finder
|
||||
def find(*args)
|
||||
case args.first
|
||||
when :first, :all
|
||||
send(args.shift, *args)
|
||||
else
|
||||
get(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def changed?
|
||||
dirty?
|
||||
end
|
||||
|
||||
def save(options=nil)
|
||||
if options.is_a?(Hash) && options[:validate] == false
|
||||
save!
|
||||
else
|
||||
super()
|
||||
end
|
||||
end
|
||||
|
||||
def update_attributes(*args)
|
||||
update(*args)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
DataMapper::Model.append_extensions(Devise::Models)
|
||||
DataMapper::Model.append_extensions(Devise::Orm::DataMapper::Hook)
|
|
@ -9,8 +9,9 @@ Devise.setup do |config|
|
|||
# config.mailer = "Devise::Mailer"
|
||||
|
||||
# ==> ORM configuration
|
||||
# Load and configure the ORM. Supports :active_record (default), :mongoid
|
||||
# (bson_ext recommended) and :data_mapper (experimental).
|
||||
# Load and configure the ORM. Supports :active_record (default) and
|
||||
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
||||
# available as additional gems.
|
||||
require 'devise/orm/<%= options[:orm] %>'
|
||||
|
||||
# ==> Configuration for any authentication mechanism
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
require 'test_helper'
|
||||
|
||||
class ValidatableTest < ActiveSupport::TestCase
|
||||
extend Devise::TestSilencer if [:mongoid, :data_mapper].include?(DEVISE_ORM)
|
||||
|
||||
test 'should require email to be set' do
|
||||
user = new_user(:email => nil)
|
||||
assert user.invalid?
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
require 'rails/test_help'
|
||||
|
||||
DataMapper.auto_migrate!
|
||||
|
||||
class ActiveSupport::TestCase
|
||||
setup do
|
||||
User.all.destroy!
|
||||
Admin.all.destroy!
|
||||
end
|
||||
end
|
|
@ -1,12 +0,0 @@
|
|||
class Admin
|
||||
include DataMapper::Resource
|
||||
|
||||
property :id, Serial
|
||||
property :username, String
|
||||
|
||||
devise :database_authenticatable, :registerable, :timeoutable, :recoverable
|
||||
|
||||
def self.create!(*args)
|
||||
create(*args)
|
||||
end
|
||||
end
|
|
@ -1,2 +0,0 @@
|
|||
module Shim
|
||||
end
|
|
@ -1,23 +0,0 @@
|
|||
class User
|
||||
include DataMapper::Resource
|
||||
|
||||
extend Devise::Orm::DataMapper::Schema
|
||||
include Devise::Orm::DataMapper::Compatibility
|
||||
|
||||
property :id, Serial
|
||||
property :username, String
|
||||
|
||||
devise :database_authenticatable, :confirmable, :lockable, :recoverable,
|
||||
:registerable, :rememberable, :timeoutable, :token_authenticatable,
|
||||
:trackable, :validatable
|
||||
|
||||
timestamps :at
|
||||
|
||||
def self.create!(*args)
|
||||
create(*args)
|
||||
end
|
||||
|
||||
def self.destroy_all
|
||||
all.destroy
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue