mm-devise 1.1.10 → 1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Changelog.txt ADDED
@@ -0,0 +1,9 @@
1
+ June 5, 2011
2
+ ---
3
+ Merged with bmarini/v-0-9-support to be compatible with MongoMapper 0.9
4
+ Updated various dependencies and removed dependency to rails-generators gem
5
+ Bumped version to 1.2
6
+
7
+ March 28, 2011
8
+ ---
9
+ Merged with digioi/master to be compatible with MongoMapper 0.9
data/Gemfile CHANGED
@@ -1,31 +1,29 @@
1
1
  source :rubygems
2
- source 'http://gems.github.com/'
3
-
4
- gem "rails"
5
-
6
2
 
7
3
  group :test do
8
4
  gem "test-unit", "~> 2.0.9"
9
- gem "webrat", "~> 0.7.0"
5
+ gem "webrat", "~> 0.7.2"
10
6
  gem "mocha", "~> 0.9.8", :require => false
11
7
  end
12
8
 
13
9
  group :default do
14
- gem "webrat", "~> 0.7.0"
10
+ gem "rails", "~> 3.0.7"
11
+ gem "webrat", "~> 0.7.2"
15
12
 
16
- gem "bcrypt-ruby", :require => "bcrypt"
17
- gem "oauth2"
18
- gem "warden", ">= 0.10.7"
19
- gem 'mongo_mapper', '>= 0.8.4'
20
- gem 'sugar-high', '~> 0.3.4'
21
- gem 'devise', '>= 1.1.1'
22
- gem 'rails3-generators', '>= 0.13.0'
23
- gem 'jnunemaker-validatable', '~> 1.8.1'
24
- gem 'bson_ext', '>= 1.0.9'
25
-
13
+ gem 'mongo_mapper', '~> 0.9.0'
14
+ gem 'sugar-high', '~> 0.4.3'
15
+ gem 'devise', '>= 1.2.0'
16
+ # gem 'rails3-generators', '>= 0.14.0'
17
+ gem 'bson_ext', '>= 1.2.0'
18
+
19
+ gem 'rake', '>= 0.8.7'
26
20
  gem "orm_adapter"
27
- gem "omniauth"
28
-
21
+ gem "oa-oauth", '~> 0.2.0', :require => "omniauth/oauth"
22
+ gem "oa-openid", '~> 0.2.0', :require => "omniauth/openid"
23
+
24
+ platforms :mri_18 do
25
+ gem "SystemTimer"
26
+ end
29
27
 
30
28
  end
31
29
 
data/README.markdown CHANGED
@@ -2,10 +2,14 @@
2
2
 
3
3
  *mm-devise* will let you use [devise](http://github.com/plataformatec/devise) with [MongoMapper](http://github.com/jnunemaker/mongomapper).
4
4
 
5
- *mm-devise* is intended for use with *Rails 3* and *Devise 1.1.5* and above. It may work with earlier versions of devise.
5
+ *mm-devise* is intended for use with *Rails 3+* and *Devise 1.2* and above. It may work with earlier versions of devise.
6
6
 
7
7
  This README only covers *mm-devise* specifics. Make sure to read the [devise README](http://github.com/plataformatec/devise/blob/master/README.rdoc)
8
8
 
9
+ ## Status update, June 2011
10
+
11
+ Recently upgraded to (hopefully!) support Devise > 1.2 and MongoMapper 0.9.0.
12
+
9
13
  ## Usage options
10
14
 
11
15
  The gem gives you the options of 2 ORM setups depending on what library you wish to use for validations:
@@ -25,18 +29,13 @@ ActiveModel support will likely be part of *MongoMapper 1.0* (as mentioned by jn
25
29
 
26
30
  Add *devise*, *mm-devise* and *MongoMapper* gems to your Gemfile (your Rails app Gemfile). The following gems are required
27
31
 
28
- <pre> gem 'mongo_mapper', '>= 0.8.2'
32
+ <pre> gem 'mongo_mapper', '>= 0.9.0'
29
33
  gem 'jnunemaker-validatable', '>= 1.8.4'
30
- gem 'bson_ext', '>= 1.0.9'
31
- gem 'devise', '>= 1.1.1'
32
- gem 'mm-devise', '>= 1.1.8'
33
- # gem 'rails3-generators', '>= 0.14.0' # optional</pre>
34
+ gem 'devise', '>= 1.2'
35
+ gem 'mm-devise', '>= 1.2'
36
+ </pre>
34
37
 
35
- You can install [rails3-generators](http://github.com/indirect/rails3-generators) which includes a *mongo_mapper* Model generator
36
-
37
- <pre>gem install rails3-generators</pre>
38
-
39
- Alternatively use bundler to install all required gems in your Rails 3 app
38
+ Use bundler to install all required gems in your Rails 3 app
40
39
 
41
40
  <pre>bundle install</pre>
42
41
 
@@ -49,6 +48,8 @@ configuration options and you MUST take a look at it. Make sure to specify
49
48
  either <code>mongo_mapper</code> or <code>mongo_mapper_active_model</code> (ActiveModel::Validations)
50
49
  as the orm in the configuration file.
51
50
 
51
+ Note: Is this still required in recent versions of Devise > 1.2 ?
52
+
52
53
  <pre>require 'devise/orm/mongo_mapper'</pre>
53
54
 
54
55
  Note: The model generator should do this automatically.
@@ -77,8 +78,13 @@ cd mm-devise
77
78
  bundle install
78
79
  rake test</pre>
79
80
 
80
- When you run <code>rake test</code>, you will (as of Aug 6, 2010) still get a few errors and failures.
81
- This is NOT due to any errors in <code>mm-devise</code> but rather due to a few "issues" with a few of the devise tests themselves IMO.
81
+ ## Gem install
82
+
83
+ <pre>$ rake install</pre>
84
+
85
+ ## Gem release (push to RubyGems)
86
+
87
+ <pre>$ gem push pkg/mm-devis-xxxx.gem</pre>
82
88
 
83
89
  ## Note on Patches/Pull Requests
84
90
 
@@ -96,6 +102,7 @@ This is NOT due to any errors in <code>mm-devise</code> but rather due to a few
96
102
 
97
103
  ## Contributors
98
104
 
105
+ *bmarini* - Updated to support MongoMapper 0.9 (June 2011)
99
106
  *bhbryant* - Fixed some issues and updated gem (Jan 2011)
100
107
  *Jared Morgan* - Created the dm-devise gem which was used as a template for the development of this gem.
101
108
  Also made suggestions for a few critical fixes and improvements in the code. Thanks :)
data/Rakefile CHANGED
@@ -1,17 +1,16 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  require 'rake'
4
+ include Rake::DSL if defined?(Rake::DSL)
5
+
4
6
  require 'bundler'
5
7
  Bundler::GemHelper.install_tasks
6
8
 
7
-
8
9
  require 'rake/testtask'
9
10
  require 'rake/rdoctask'
10
11
  require File.join(File.dirname(__FILE__), 'lib', 'mm-devise', 'version')
11
12
 
12
13
  desc 'Run Devise tests using MongoMapper. Specify path to devise with DEVISE_PATH'
13
-
14
-
15
14
  Rake::TestTask.new(:test) do |test|
16
15
  ENV['DEVISE_ORM'] ||= 'mongo_mapper'
17
16
  ENV['DEVISE_PATH'] ||= File.join(File.dirname(__FILE__), '../devise')
@@ -27,56 +26,5 @@ Rake::TestTask.new(:test) do |test|
27
26
  test.verbose = true
28
27
  end
29
28
 
30
- desc 'Default: run tests for all ORMs.'
31
- task :default => :tests
32
-
33
- =begin
34
- desc 'Default: run tests for all MongoMapper ORM setups.'
35
- task :default => :pre_commit
36
-
37
- desc 'Run Devise tests for all MongoMapper ORM setups.'
38
- task :pre_commit do
39
- Dir[File.join(File.dirname(__FILE__), 'test', 'orm', '*.rb')].each do |file|
40
- orm = File.basename(file).split(".").first
41
- ENV['DEVISE_PATH'] ||= File.expand_path('../devise')
42
- system "rake test DEVISE_ORM=#{orm} DEVISE_PATH=#{ENV['DEVISE_PATH']}"
43
- end
44
- end
45
-
46
-
47
- task :test
48
-
49
- desc 'Generate documentation for dm-devise.'
50
- Rake::RDocTask.new(:rdoc) do |rdoc|
51
- rdoc.rdoc_dir = 'rdoc'
52
- rdoc.title = 'mm-devise #{version}'
53
- rdoc.options << '--line-numbers' << '--inline-source'
54
- rdoc.rdoc_files.include('README.rdoc')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
57
-
58
- begin
59
- require 'jeweler'
60
- Jeweler::Tasks.new do |gem|
61
- gem.name = "mm-devise"
62
- gem.version = MongoMapper::Devise::VERSION.dup
63
- gem.summary = %Q{Support for using MongoMapper ORM with devise}
64
- gem.description = %Q{dm-devise adds MongoMapper support to devise (http://github.com/plataformatec/devise) for authentication support for Rails}
65
- gem.email = "jmorgan@morgancreative.net"
66
- gem.homepage = "http://github.com/kristianmandrup/mm-devise"
67
- gem.authors = ["Kristian Mandrup"]
68
- gem.add_dependency 'mongo_mapper', '>= 0.8.4'
69
- gem.add_dependency 'bson', '>= 1.0.9'
70
- gem.add_dependency 'rails3-generators', '>= 0.13.0'
71
- gem.add_dependency 'jnunemaker-validatable', '>= 1.8.1'
72
- gem.add_dependency 'devise', '>= 1.1.1'
73
- gem.add_dependency 'sugar-high', '~> 0.3.0'
74
- gem.add_dependency 'warden', '>= 0.10.7'
75
- gem.add_dependency 'bcrypt-ruby', '>= 2.1.2'
76
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
77
- end
78
- Jeweler::GemcutterTasks.new
79
- rescue LoadError
80
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
81
- end
82
- =end
29
+ desc 'Default: run tests for MongoMapper'
30
+ task :default => :test
@@ -1,26 +1,37 @@
1
- require 'mongo_mapper'
2
- require 'devise/orm/mongo_mapper/compatibility'
3
- require 'devise/orm/mongo_mapper/schema'
4
- require 'devise/orm/mongo_mapper/date_time'
5
- require 'devise/orm/mongo_mapper/mm-validations'
1
+ require 'orm_adapter/adapters/mongo_mapper'
6
2
 
7
3
  module Devise
8
4
  module Orm
9
5
  module MongoMapper
6
+ extend ActiveSupport::Concern
7
+
8
+ included do
9
+ extend Devise::Models
10
+ extend Devise::Orm::MongoMapper::Hook
11
+ end
12
+
10
13
  module Hook
11
14
  def devise_modules_hook!
12
15
  extend Schema
13
- include Compatibility
14
- include Validatable
15
16
  yield
16
17
  return unless Devise.apply_schema
17
18
  devise_modules.each { |m| send(m) if respond_to?(m, true) }
18
- end
19
+ end
20
+
19
21
  end
22
+
23
+ module Schema
24
+ include Devise::Schema
25
+
26
+ # Tell how to apply schema methods
27
+ def apply_devise_schema(name, type, options={})
28
+ type = Time if type == DateTime
29
+ key(name, type, options)
30
+ end
31
+ end
32
+
20
33
  end
21
34
  end
22
35
  end
23
36
 
24
- MongoMapper::Document.append_extensions(Devise::Models)
25
- MongoMapper::Document.append_extensions(Devise::Orm::MongoMapper::Hook)
26
-
37
+ MongoMapper::Document.plugin Devise::Orm::MongoMapper
@@ -1,5 +1,5 @@
1
1
  module MongoMapper
2
2
  module Devise
3
- VERSION = '1.1.10'.freeze
3
+ VERSION = '1.2' #.freeze
4
4
  end
5
5
  end
data/mm-devise.gemspec CHANGED
@@ -1,104 +1,23 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "mm-devise/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{mm-devise}
8
- s.version = "1.1.10"
6
+ s.name = "mm-devise"
7
+ s.version = MongoMapper::Devise::VERSION
8
+ s.date = "2011-06-01"
9
+ s.summary = %Q{Support for using MongoMapper ORM with devise}
10
+ s.description = %Q{dm-devise adds MongoMapper support to devise (http://github.com/plataformatec/devise) for authentication support for Rails}
11
+ s.email = "kmandrup@gmail.com"
12
+ s.homepage = "http://github.com/kristianmandrup/mm-devise"
13
+ s.authors = ["Kristian Mandrup"]
14
+ s.files = Dir.glob("lib/**/*") + %w(Changelog.txt mm-devise.gemspec Gemfile LICENSE Rakefile README.markdown)
15
+ s.test_files = Dir.glob("test/**/*")
9
16
 
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2011-01-11}
13
- s.description = %q{dm-devise adds MongoMapper support to devise (http://github.com/plataformatec/devise) for authentication support for Rails}
14
- s.email = %q{jmorgan@morgancreative.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.markdown"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".gitignore",
22
- "Gemfile",
23
- "LICENSE",
24
- "README.markdown",
25
- "Rakefile",
26
- "lib/devise/orm/mongo_mapper.rb",
27
- "lib/devise/orm/mongo_mapper/compatibility.rb",
28
- "lib/devise/orm/mongo_mapper/date_time.rb",
29
- "lib/devise/orm/mongo_mapper/mm-validations.rb",
30
- "lib/devise/orm/mongo_mapper/schema.rb",
31
- "lib/devise/orm/mongo_mapper_active_model.rb",
32
- "lib/generators/mongo_mapper/devise_generator.rb",
33
- "lib/mm-devise/version.rb",
34
- "mm-devise.gemspec",
35
- "test/mongo_mapper/compatibility_test.rb",
36
- "test/orm/mongo_mapper.rb",
37
- "test/orm/mongo_mapper_active_model.rb",
38
- "test/overrides/mm_validations_test.rb",
39
- "test/overrides/mongo_mapper_test.rb",
40
- "test/rails_app/app/mongo_mapper/admin.rb",
41
- "test/rails_app/app/mongo_mapper/shim.rb",
42
- "test/rails_app/app/mongo_mapper/user.rb",
43
- "test/rails_app/app/mongo_mapper_active_model/admin.rb",
44
- "test/rails_app/app/mongo_mapper_active_model/user.rb",
45
- "test/rails_app/config/application.rb",
46
- "test/rails_app/config/environment.rb",
47
- "test/test_helper.rb"
48
- ]
49
- s.homepage = %q{http://github.com/kristianmandrup/mm-devise}
50
- s.rdoc_options = ["--charset=UTF-8"]
51
- s.require_paths = ["lib"]
52
- s.rubygems_version = %q{1.3.7}
53
- s.summary = %q{Support for using MongoMapper ORM with devise}
54
- s.test_files = [
55
- "test/mongo_mapper/compatibility_test.rb",
56
- "test/orm/mongo_mapper.rb",
57
- "test/orm/mongo_mapper_active_model.rb",
58
- "test/overrides/mm_validations_test.rb",
59
- "test/overrides/mongo_mapper_test.rb",
60
- "test/rails_app/app/mongo_mapper/admin.rb",
61
- "test/rails_app/app/mongo_mapper/shim.rb",
62
- "test/rails_app/app/mongo_mapper/user.rb",
63
- "test/rails_app/app/mongo_mapper_active_model/admin.rb",
64
- "test/rails_app/app/mongo_mapper_active_model/user.rb",
65
- "test/rails_app/config/application.rb",
66
- "test/rails_app/config/environment.rb",
67
- "test/test_helper.rb"
68
- ]
17
+ s.add_dependency 'mongo_mapper', '>= 0.9.0'
18
+ s.add_dependency 'devise', '>= 1.2'
19
+ # s.add_dependency 'rails3-generators', '>= 0.14.0'
20
+ s.add_dependency 'sugar-high', '~> 0.4.3'
21
+ s.add_dependency "SystemTimer", "~> 1.2" if RUBY_VERSION < "1.9"
69
22
 
70
- if s.respond_to? :specification_version then
71
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
72
- s.specification_version = 3
73
-
74
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
75
- s.add_runtime_dependency(%q<mongo_mapper>, [">= 0.8.4"])
76
- s.add_runtime_dependency(%q<bson>, [">= 1.0.9"])
77
- s.add_runtime_dependency(%q<rails3-generators>, [">= 0.13.0"])
78
- s.add_runtime_dependency(%q<jnunemaker-validatable>, [">= 1.8.1"])
79
- s.add_runtime_dependency(%q<devise>, [">= 1.1.1"])
80
- s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.0"])
81
- s.add_runtime_dependency(%q<warden>, [">= 0.10.7"])
82
- s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
83
- else
84
- s.add_dependency(%q<mongo_mapper>, [">= 0.8.4"])
85
- s.add_dependency(%q<bson>, [">= 1.0.9"])
86
- s.add_dependency(%q<rails3-generators>, [">= 0.13.0"])
87
- s.add_dependency(%q<jnunemaker-validatable>, [">= 1.8.1"])
88
- s.add_dependency(%q<devise>, [">= 1.1.1"])
89
- s.add_dependency(%q<sugar-high>, ["~> 0.3.4"])
90
- s.add_dependency(%q<warden>, [">= 0.10.7"])
91
- s.add_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
92
- end
93
- else
94
- s.add_dependency(%q<mongo_mapper>, [">= 0.8.4"])
95
- s.add_dependency(%q<bson>, [">= 1.0.9"])
96
- s.add_dependency(%q<rails3-generators>, [">= 0.13.0"])
97
- s.add_dependency(%q<jnunemaker-validatable>, [">= 1.8.1"])
98
- s.add_dependency(%q<devise>, [">= 1.1.1"])
99
- s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
100
- s.add_dependency(%q<warden>, [">= 0.10.7"])
101
- s.add_dependency(%q<bcrypt-ruby>, [">= 2.1.2"])
102
- end
103
23
  end
104
-
@@ -1,30 +1,10 @@
1
- require 'rails/test_help'
1
+ MongoMapper.connection = Mongo::Connection.new('127.0.0.1', 27017)
2
+ MongoMapper.database = "devise-test-suite"
3
+ MongoMapper.database.collections.each { |c| c.drop_indexes }
2
4
 
3
5
  class ActiveSupport::TestCase
4
6
  setup do
5
- User.destroy_all
6
- Admin.destroy_all
7
- end
8
- end
9
-
10
- module MongoMapper
11
- module Validate
12
- class ValidationErrors
13
-
14
- # ActiveModel prepends field names in +#full_messages+, and so the
15
- # expected result of calling errors[field_name] will not include the
16
- # field name in the message. However, DM expects the field name to be
17
- # included in the original message. Assuming that the field name will
18
- # begin the message, just strip it out (plus the following space) for
19
- # testing purposes. This has no effect on #full_messages.
20
-
21
- # def [](property_name)
22
- # if property_errors = errors[property_name.to_sym]
23
- # property_errors.collect do |message|
24
- # message[(property_name.to_s.length + 1)..-1]
25
- # end
26
- # end
27
- # end
28
- end
7
+ User.collection.remove
8
+ Admin.collection.remove
29
9
  end
30
10
  end
@@ -2,11 +2,9 @@ require 'shared_admin'
2
2
 
3
3
  class Admin
4
4
  include MongoMapper::Document
5
+ include Shim
6
+ include SharedAdmin
5
7
 
6
- key :username, String
7
-
8
+ key :remember_token, String
8
9
  timestamps!
9
-
10
- include SharedAdmin
11
- include Shim
12
10
  end
@@ -1,21 +1,7 @@
1
- # Shim should be included after SharedUser / SharedAdmin
2
1
  module Shim
3
- def self.included(klass)
4
- klass.extend(ModelMethods)
5
- end
2
+ extend ::ActiveSupport::Concern
6
3
 
7
- module ModelMethods
8
- # Override version in SharedUser which uses #find_by_email.
9
- def find_for_facebook_oauth(access_token, signed_in_resource=nil)
10
- data = ActiveSupport::JSON.decode(access_token.get('/me'))
11
- user = signed_in_resource || User.first(:email => data["email"]) || User.new
12
- user.update_with_facebook_oauth(access_token, data)
13
- user.save
14
- user
15
- end
16
-
17
- def create!(*args)
18
- create(*args)
19
- end
4
+ included do
5
+ self.include_root_in_json = true
20
6
  end
21
7
  end