devise_couchrest_model 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +25 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +22 -0
- data/devise_couchrest_model.gemspec +23 -0
- data/lib/devise/orm/couchrest_model.rb +3 -0
- data/lib/devise/orm/couchrest_model/date_time.rb +8 -0
- data/lib/devise_couchrest_model.rb +5 -0
- data/lib/devise_couchrest_model/version.rb +3 -0
- data/test/orm/couchrest_model.rb +8 -0
- data/test/rails_app/app/couchrest_model/admin.rb +69 -0
- data/test/rails_app/app/couchrest_model/shim.rb +21 -0
- data/test/rails_app/app/couchrest_model/user.rb +95 -0
- data/test/rails_app/config/application.rb +37 -0
- data/test/rails_app/config/environment.rb +5 -0
- data/test/test_helper.rb +28 -0
- metadata +120 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
group :test do
|
4
|
+
gem "test-unit", "~> 2.0.9"
|
5
|
+
gem "webrat", "~> 0.7.0"
|
6
|
+
gem "mocha", "~> 0.9.8", :require => false
|
7
|
+
end
|
8
|
+
|
9
|
+
group :default do
|
10
|
+
gem "rails", "~> 3.2.0"
|
11
|
+
gem "webrat", "~> 0.7.0"
|
12
|
+
|
13
|
+
gem 'couchrest_model', '~> 2.0.0.beta2'
|
14
|
+
gem 'devise', '>= 2.1.0'
|
15
|
+
gem 'devise-encryptable'
|
16
|
+
gem 'bson_ext', '>= 1.2.0'
|
17
|
+
|
18
|
+
gem 'rake', '>= 0.8.7'
|
19
|
+
gem "orm_adapter"
|
20
|
+
gem "orm_adapter_couchrest_model"
|
21
|
+
# gem "oa-oauth", '~> 0.3.0', :require => "omniauth/oauth"
|
22
|
+
# gem "oa-openid", '~> 0.3.0', :require => "omniauth/openid"
|
23
|
+
gem "omniauth-openid", '~>1.0.0'
|
24
|
+
gem "omniauth-facebook", '~>1.2.0'
|
25
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Winfield
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# DeviseCouchrestModel
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'devise_couchrest_model'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install devise_couchrest_model
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
desc 'Run Devise tests using couchrest_model. Specify path to devise with DEVISE_PATH'
|
6
|
+
Rake::TestTask.new(:test) do |test|
|
7
|
+
ENV['DEVISE_ORM'] ||= 'couchrest_model'
|
8
|
+
ENV['DEVISE_PATH'] ||= File.join(File.dirname(__FILE__), '../devise')
|
9
|
+
unless File.exist?(ENV['DEVISE_PATH'])
|
10
|
+
puts "Specify the path to devise (e.g. rake DEVISE_PATH=/path/to/devise). Not found at #{ENV['DEVISE_PATH']}"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
|
14
|
+
test.libs << 'lib' << 'test'
|
15
|
+
test.libs << "#{ENV['DEVISE_PATH']}/lib"
|
16
|
+
test.libs << "#{ENV['DEVISE_PATH']}/test"
|
17
|
+
test.test_files = FileList["#{ENV['DEVISE_PATH']}/test/**/*_test.rb"] + FileList['test/**/*_test.rb']
|
18
|
+
test.verbose = true
|
19
|
+
end
|
20
|
+
|
21
|
+
desc 'Default: run tests for couchrest_model'
|
22
|
+
task :default => :test
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/devise_couchrest_model/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["lainuo"]
|
6
|
+
gem.email = ["winfield301@gmail.com"]
|
7
|
+
gem.description = %q{devise couchrest_model plugin}
|
8
|
+
gem.summary = %q{devise couchrest_model plugin}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "devise_couchrest_model"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = DeviseCouchrestModel::VERSION
|
17
|
+
|
18
|
+
gem.rubyforge_project = "devise_couchrest_model"
|
19
|
+
|
20
|
+
gem.add_dependency "couchrest_model", "2.0.0.beta2"
|
21
|
+
gem.add_dependency "orm_adapter_couchrest_model"
|
22
|
+
gem.add_dependency "devise", ">= 2.1"
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'shared_admin'
|
2
|
+
|
3
|
+
class Admin < CouchRest::Model::Base
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# attr_accessible is used by SharedUser. Instead of trying to make a
|
7
|
+
# a compatibility method, ignore it and set writer option to private on
|
8
|
+
# confirmation_token property.
|
9
|
+
def attr_accessible(*args); nil; end
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_attribute(name, value)
|
13
|
+
update_attributes(Hash[name, value])
|
14
|
+
end
|
15
|
+
|
16
|
+
def active?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
include SharedAdmin
|
21
|
+
include Shim
|
22
|
+
|
23
|
+
use_database CouchRest.database!("http://127.0.0.1:5984/devise-test-suite")
|
24
|
+
|
25
|
+
## Database authenticatable
|
26
|
+
property :email
|
27
|
+
property :encrypted_password
|
28
|
+
|
29
|
+
## Recoverable
|
30
|
+
property :reset_password_token
|
31
|
+
property :reset_password_sent_at, Time
|
32
|
+
|
33
|
+
## Rememberable
|
34
|
+
property :remember_created_at, Time
|
35
|
+
|
36
|
+
## Confirmable
|
37
|
+
property :confirmation_token
|
38
|
+
property :confirmed_at, Time
|
39
|
+
property :confirmation_sent_at, Time
|
40
|
+
property :unconfirmed_email
|
41
|
+
|
42
|
+
## Lockable
|
43
|
+
property :locked_at, Time
|
44
|
+
|
45
|
+
|
46
|
+
timestamps!
|
47
|
+
|
48
|
+
design do
|
49
|
+
## Database authenticatable
|
50
|
+
view :by_email
|
51
|
+
view :by_encrypted_password
|
52
|
+
|
53
|
+
## Recoverable
|
54
|
+
view :by_reset_password_token
|
55
|
+
view :by_reset_password_sent_at
|
56
|
+
|
57
|
+
## Rememberable
|
58
|
+
view :by_remember_created_at
|
59
|
+
|
60
|
+
## Confirmable
|
61
|
+
view :by_confirmation_token
|
62
|
+
view :by_confirmed_at
|
63
|
+
view :by_confirmation_sent_at
|
64
|
+
view :by_unconfirmed_email
|
65
|
+
|
66
|
+
## Lockable
|
67
|
+
view :by_locked_at
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Shim should be included after SharedUser / SharedAdmin
|
2
|
+
module Shim
|
3
|
+
def self.included(klass)
|
4
|
+
klass.extend(ModelMethods)
|
5
|
+
end
|
6
|
+
|
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
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'shared_user'
|
2
|
+
|
3
|
+
class User < CouchRest::Model::Base
|
4
|
+
|
5
|
+
class << self
|
6
|
+
# attr_accessible is used by SharedUser. Instead of trying to make a
|
7
|
+
# a compatibility method, ignore it and set writer option to private on
|
8
|
+
# confirmation_token property.
|
9
|
+
def attr_accessible(*args); nil; end
|
10
|
+
end
|
11
|
+
|
12
|
+
def update_attribute(name, value)
|
13
|
+
update_attributes(Hash[name, value])
|
14
|
+
end
|
15
|
+
|
16
|
+
def active?
|
17
|
+
false
|
18
|
+
end
|
19
|
+
|
20
|
+
include SharedUser
|
21
|
+
include Shim
|
22
|
+
use_database CouchRest.database!("http://127.0.0.1:5984/devise-test-suite")
|
23
|
+
|
24
|
+
property :username
|
25
|
+
property :facebook_token
|
26
|
+
|
27
|
+
## Database authenticatable
|
28
|
+
property :email, :default => ""
|
29
|
+
property :encrypted_password, :default => ""
|
30
|
+
|
31
|
+
## Recoverable
|
32
|
+
property :reset_password_token
|
33
|
+
property :reset_password_sent_at, Time
|
34
|
+
|
35
|
+
## Rememberable
|
36
|
+
property :remember_created_at, Time
|
37
|
+
|
38
|
+
## Trackable
|
39
|
+
property :sign_in_count, Integer, :default => 0
|
40
|
+
property :current_sign_in_at, Time
|
41
|
+
property :last_sign_in_at, Time
|
42
|
+
property :current_sign_in_ip
|
43
|
+
property :last_sign_in_ip
|
44
|
+
|
45
|
+
## Confirmable
|
46
|
+
property :confirmation_token
|
47
|
+
property :confirmed_at, Time
|
48
|
+
property :confirmation_sent_at, Time
|
49
|
+
|
50
|
+
## Lockable
|
51
|
+
property :failed_attempts, Integer, :default => 0
|
52
|
+
property :locked_at, Time
|
53
|
+
property :unlock_token
|
54
|
+
|
55
|
+
## Token authenticatable
|
56
|
+
property :authentication_token
|
57
|
+
|
58
|
+
timestamps!
|
59
|
+
|
60
|
+
design do
|
61
|
+
view :by_username
|
62
|
+
view :by_facebook_token
|
63
|
+
|
64
|
+
## Database authenticatable
|
65
|
+
view :by_email
|
66
|
+
view :by_encrypted_password
|
67
|
+
|
68
|
+
## Recoverable
|
69
|
+
view :by_reset_password_token
|
70
|
+
view :by_reset_password_sent_at
|
71
|
+
|
72
|
+
## Rememberable
|
73
|
+
view :by_remember_created_at
|
74
|
+
|
75
|
+
## Trackable
|
76
|
+
view :by_sign_in_count
|
77
|
+
view :by_current_sign_in_at
|
78
|
+
view :by_last_sign_in_at
|
79
|
+
view :by_current_sign_in_ip
|
80
|
+
view :by_last_sign_in_ip
|
81
|
+
|
82
|
+
## Confirmable
|
83
|
+
view :by_confirmation_token
|
84
|
+
view :by_confirmed_at
|
85
|
+
view :by_confirmation_sent_at
|
86
|
+
|
87
|
+
## Lockable
|
88
|
+
view :by_failed_attempts
|
89
|
+
view :by_locked_at
|
90
|
+
view :by_unlock_token
|
91
|
+
|
92
|
+
## Token authenticatable
|
93
|
+
view :by_authentication_token
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
APP_ROOT = File.expand_path("#{DEVISE_PATH}/test/rails_app")
|
2
|
+
require "#{APP_ROOT}/config/boot"
|
3
|
+
|
4
|
+
require "action_controller/railtie"
|
5
|
+
require "action_mailer/railtie"
|
6
|
+
require "active_resource/railtie"
|
7
|
+
require "rails/test_unit/railtie"
|
8
|
+
|
9
|
+
Bundler.require :default
|
10
|
+
|
11
|
+
begin
|
12
|
+
require "#{DEVISE_ORM}/railtie"
|
13
|
+
rescue LoadError
|
14
|
+
end
|
15
|
+
|
16
|
+
require "devise"
|
17
|
+
|
18
|
+
module RailsApp
|
19
|
+
class Application < Rails::Application
|
20
|
+
# Add additional load paths for your own custom dirs
|
21
|
+
config.root = APP_ROOT
|
22
|
+
config.autoload_paths.reject!{ |p| p =~ /\/app\/(\w+)$/ && !%w(controllers helpers views).include?($1) }
|
23
|
+
config.autoload_paths += [ File.expand_path("#{File.dirname(__FILE__)}/../app/#{DEVISE_ORM}") ]
|
24
|
+
|
25
|
+
# Configure generators values. Many other options are available, be sure to check the documentation.
|
26
|
+
# config.generators do |g|
|
27
|
+
# g.orm :active_record
|
28
|
+
# g.template_engine :erb
|
29
|
+
# g.test_framework :test_unit, :fixture => true
|
30
|
+
# end
|
31
|
+
|
32
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
33
|
+
config.filter_parameters << :password
|
34
|
+
|
35
|
+
config.action_mailer.default_url_options = { :host => "localhost:3000" }
|
36
|
+
end
|
37
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
ENV["RAILS_ENV"] = "test"
|
2
|
+
DEVISE_ORM = (ENV["DEVISE_ORM"] || :couchrest_model).to_sym
|
3
|
+
DEVISE_PATH = ENV['DEVISE_PATH']
|
4
|
+
|
5
|
+
puts "\n==> Devise.orm = #{DEVISE_ORM.inspect}"
|
6
|
+
|
7
|
+
require "rails_app/config/environment"
|
8
|
+
require "rails/test_help"
|
9
|
+
require "orm/#{DEVISE_ORM}"
|
10
|
+
|
11
|
+
|
12
|
+
I18n.load_path << "#{DEVISE_PATH}/test/support/locale/en.yml"
|
13
|
+
|
14
|
+
require 'mocha'
|
15
|
+
require 'webrat'
|
16
|
+
Webrat.configure do |config|
|
17
|
+
config.mode = :rails
|
18
|
+
config.open_error_files = false
|
19
|
+
end
|
20
|
+
|
21
|
+
# Add support to load paths so we can overwrite broken webrat setup
|
22
|
+
$:.unshift "#{DEVISE_PATH}/test/support"
|
23
|
+
Dir["#{DEVISE_PATH}/test/support/**/*.rb"].each { |f| require f }
|
24
|
+
|
25
|
+
# For generators
|
26
|
+
require "rails/generators/test_case"
|
27
|
+
require "generators/devise/install_generator"
|
28
|
+
require "generators/devise/views_generator"
|
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: devise_couchrest_model
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- lainuo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: couchrest_model
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 2.0.0.beta2
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.0.0.beta2
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: orm_adapter_couchrest_model
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: devise
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.1'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
description: devise couchrest_model plugin
|
63
|
+
email:
|
64
|
+
- winfield301@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- devise_couchrest_model.gemspec
|
75
|
+
- lib/devise/orm/couchrest_model.rb
|
76
|
+
- lib/devise/orm/couchrest_model/date_time.rb
|
77
|
+
- lib/devise_couchrest_model.rb
|
78
|
+
- lib/devise_couchrest_model/version.rb
|
79
|
+
- test/orm/couchrest_model.rb
|
80
|
+
- test/rails_app/app/couchrest_model/admin.rb
|
81
|
+
- test/rails_app/app/couchrest_model/shim.rb
|
82
|
+
- test/rails_app/app/couchrest_model/user.rb
|
83
|
+
- test/rails_app/config/application.rb
|
84
|
+
- test/rails_app/config/environment.rb
|
85
|
+
- test/test_helper.rb
|
86
|
+
homepage: ''
|
87
|
+
licenses: []
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
none: false
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
segments:
|
99
|
+
- 0
|
100
|
+
hash: 403539192290744090
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
103
|
+
requirements:
|
104
|
+
- - ! '>='
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubyforge_project: devise_couchrest_model
|
109
|
+
rubygems_version: 1.8.24
|
110
|
+
signing_key:
|
111
|
+
specification_version: 3
|
112
|
+
summary: devise couchrest_model plugin
|
113
|
+
test_files:
|
114
|
+
- test/orm/couchrest_model.rb
|
115
|
+
- test/rails_app/app/couchrest_model/admin.rb
|
116
|
+
- test/rails_app/app/couchrest_model/shim.rb
|
117
|
+
- test/rails_app/app/couchrest_model/user.rb
|
118
|
+
- test/rails_app/config/application.rb
|
119
|
+
- test/rails_app/config/environment.rb
|
120
|
+
- test/test_helper.rb
|