devise_simply_stored 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source :rubygems
2
+
3
+ # Specify your gem's dependencies in devise_simply_stored.gemspec
4
+ gem 'devise'
5
+ gem 'couch_potato' , :git => 'git://github.com/bterkuile/couch_potato.git'
6
+ gem 'simply_stored' , :git => 'git://github.com/bterkuile/simply_stored.git'
7
+ gemspec
8
+ group :test do
9
+ gem 'rspec'
10
+ gem 'ruby-debug19', :require => 'ruby-debug'
11
+ end
data/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ = devise_simply_stored
2
+ add it to your Gemfile:
3
+ gem 'devise_simply_stored'
4
+
5
+ to your devise config (devise.rb)
6
+ class User
7
+ include SimplyStored::Couch
8
+ include Devise::Orm::SimplyStored
9
+
10
+ devise :database_authenticatable, :registerable,
11
+ :recoverable, :rememberable, :trackable, :validatable
12
+
13
+ end
14
+
15
+
16
+ == Note on Patches/Pull Requests
17
+
18
+ * Fork the project.
19
+ * Make your feature addition or bug fix.
20
+ * Add tests for it. This is important so I don't break it in a
21
+ future version unintentionally.
22
+ * Commit, do not mess with rakefile, version, or history.
23
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
24
+ * Send me a pull request. Bonus points for topic branches.
25
+
26
+ == Copyright
27
+
28
+ Copyright (c) 2012 Benjamin ter Kuile. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "devise_simply_stored/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "devise_simply_stored"
7
+ s.version = DeviseSimplyStored::VERSION
8
+ s.authors = ["Benjamin ter Kuile"]
9
+ s.email = ["bterkuile@gmail.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{This gem enables devise for simply_stored}
12
+ s.description = %q{This gem enables devise for simply_stored}
13
+
14
+ s.rubyforge_project = "devise_simply_stored"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ s.add_runtime_dependency "devise"
24
+ end
@@ -0,0 +1,47 @@
1
+ module Devise
2
+ module Orm
3
+ module SimplyStored
4
+ def self.included(klass)
5
+ klass.send(:extend, ::Devise::Models)
6
+ klass.send(:extend, Hook)
7
+ klass.send(:extend, Schema)
8
+ end
9
+ module Hook
10
+ def devise_modules_hook!
11
+ yield
12
+ return unless Devise.apply_schema
13
+ devise_modules.each { |m| send(m) if respond_to?(m, true) }
14
+ end
15
+ def to_adapter
16
+ self
17
+ end
18
+ def find_first(conditions)
19
+ if conditions.any?
20
+ send(:"find_by_#{conditions.keys.join('_and_')}", *conditions.values)
21
+ else
22
+ first
23
+ end
24
+ end
25
+ def get(ary)
26
+ find Array.wrap(ary).first
27
+ end
28
+ end
29
+
30
+ module Schema
31
+ include Devise::Schema
32
+
33
+ # Tell how to apply schema methods
34
+ def apply_devise_schema(name, type, options={})
35
+ type = Time if type == DateTime
36
+ type = Fixnum if type == Integer
37
+ property name, { :type => type }.merge!(options)
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+ module SimplyStored::Couch
44
+ def [](val)
45
+ attributes[val]
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module DeviseSimplyStored
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,6 @@
1
+
2
+ require "devise_simply_stored/version"
3
+ require 'devise/orm/simply_stored'
4
+ module DeviseSimplyStored
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,89 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+ before :each do
5
+ @user = User.new
6
+ end
7
+
8
+ it "should not add double properties" do
9
+ User.property_names.size.should == User.property_names.uniq.size
10
+ end
11
+
12
+ describe 'accessing attributes' do
13
+ it "should access attributes through [] on record" do
14
+ @user.email = 'test@example.com'
15
+ @user[:email].should == 'test@example.com'
16
+ end
17
+ end
18
+ describe :database_authenticatable do
19
+
20
+ it "should add email correctly" do
21
+ property = User.properties.find{|p| p.name == :email }
22
+ property.should_not be_nil
23
+ property.type.should == String
24
+ end
25
+ it "should add encrypted_password correctly" do
26
+ property = User.properties.find{|p| p.name == :encrypted_password }
27
+ property.should_not be_nil
28
+ property.type.should == String
29
+ end
30
+
31
+ it "should set encrypted_password by password= assignment" do
32
+ @user.encrypted_password.should be_blank
33
+ @user.password = '12345'
34
+ @user.encrypted_password.should_not be_blank
35
+ end
36
+ end
37
+ describe :rememberable do
38
+ it "should add remember_token correctly" do
39
+ property = User.properties.find{|p| p.name == :remember_token }
40
+ property.should_not be_nil
41
+ property.type.should == String
42
+ end
43
+ it "should add remember_created_at correctly" do
44
+ property = User.properties.find{|p| p.name == :remember_created_at }
45
+ property.should_not be_nil
46
+ property.type.should == Time
47
+ end
48
+ end
49
+
50
+ describe :rememberable do
51
+ it "should add reset_password_token correctly" do
52
+ property = User.properties.find{|p| p.name == :reset_password_token }
53
+ property.should_not be_nil
54
+ property.type.should == String
55
+ end
56
+ it "should add reset_password_sent_at correctly" do
57
+ property = User.properties.find{|p| p.name == :reset_password_sent_at }
58
+ property.should_not be_nil
59
+ property.type.should == Time
60
+ end
61
+ end
62
+ describe :trackable do
63
+ it "should add sign_in_count correctly" do
64
+ property = User.properties.find{|p| p.name == :sign_in_count}
65
+ property.should_not be_nil
66
+ property.type.should == Fixnum
67
+ end
68
+ it "should add current_sign_in_at correctly" do
69
+ property = User.properties.find{|p| p.name == :current_sign_in_at }
70
+ property.should_not be_nil
71
+ property.type.should == Time
72
+ end
73
+ it "should add last_sign_in_at correctly" do
74
+ property = User.properties.find{|p| p.name == :last_sign_in_at }
75
+ property.should_not be_nil
76
+ property.type.should == Time
77
+ end
78
+ it "should add current_sign_in_ip correctly" do
79
+ property = User.properties.find{|p| p.name == :current_sign_in_ip}
80
+ property.should_not be_nil
81
+ property.type.should == String
82
+ end
83
+ it "should add last_sign_in_ip correctly" do
84
+ property = User.properties.find{|p| p.name == :last_sign_in_ip}
85
+ property.should_not be_nil
86
+ property.type.should == String
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ Bundler.require
4
+ require 'devise_simply_stored'
5
+
6
+ # SETUP devise. Important to do before loading models
7
+ Devise.setup do |config|
8
+ config.stretches = 10
9
+ config.case_insensitive_keys = [ :email ]
10
+ config.reset_password_within = 2.hours
11
+ end
12
+ Dir[File.join(File.dirname(__FILE__), 'support', '**', '*.rb')].each{|f| require f}
13
+ RSpec.configure do |config|
14
+ # some (optional) config here
15
+ end
@@ -0,0 +1,6 @@
1
+ class User
2
+ include SimplyStored::Couch
3
+ include Devise::Orm::SimplyStored
4
+
5
+ devise :database_authenticatable, :recoverable, :rememberable, :trackable
6
+ end
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: devise_simply_stored
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Benjamin ter Kuile
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-28 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: devise
16
+ requirement: &70211603046780 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70211603046780
25
+ description: This gem enables devise for simply_stored
26
+ email:
27
+ - bterkuile@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.rdoc
35
+ - Rakefile
36
+ - devise_simply_stored.gemspec
37
+ - lib/devise/orm/simply_stored.rb
38
+ - lib/devise_simply_stored.rb
39
+ - lib/devise_simply_stored/version.rb
40
+ - spec/models/user_spec.rb
41
+ - spec/spec_helper.rb
42
+ - spec/support/user_model.rb
43
+ homepage: ''
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project: devise_simply_stored
63
+ rubygems_version: 1.8.15
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: This gem enables devise for simply_stored
67
+ test_files:
68
+ - spec/models/user_spec.rb
69
+ - spec/spec_helper.rb
70
+ - spec/support/user_model.rb