devise_invitable 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. data/README.rdoc +158 -45
  2. data/app/controllers/devise/invitations_controller.rb +61 -0
  3. data/app/views/devise/invitations/edit.html.erb +14 -0
  4. data/app/views/devise/invitations/new.html.erb +12 -0
  5. data/app/views/devise/mailer/invitation_instructions.html.erb +8 -0
  6. data/config/locales/en.yml +10 -0
  7. data/lib/devise_invitable/controllers/helpers.rb +4 -3
  8. data/lib/devise_invitable/controllers/url_helpers.rb +21 -17
  9. data/lib/devise_invitable/mailer.rb +8 -3
  10. data/lib/devise_invitable/model.rb +92 -38
  11. data/lib/devise_invitable/rails.rb +12 -2
  12. data/lib/devise_invitable/routes.rb +10 -26
  13. data/lib/devise_invitable/schema.rb +28 -3
  14. data/lib/devise_invitable/version.rb +3 -0
  15. data/lib/devise_invitable.rb +40 -12
  16. data/lib/generators/active_record/devise_invitable_generator.rb +13 -0
  17. data/lib/generators/active_record/templates/migration.rb +25 -0
  18. data/lib/generators/devise_invitable/devise_invitable_generator.rb +20 -0
  19. data/lib/generators/devise_invitable/install_generator.rb +49 -0
  20. data/lib/generators/devise_invitable/views_generator.rb +10 -0
  21. data/lib/generators/mongoid/devise_invitable_generator.rb +8 -0
  22. metadata +64 -95
  23. data/.document +0 -5
  24. data/.gitignore +0 -22
  25. data/Rakefile +0 -54
  26. data/VERSION +0 -1
  27. data/app/controllers/invitations_controller.rb +0 -44
  28. data/app/views/devise_mailer/invitation.html.erb +0 -8
  29. data/app/views/invitations/edit.html.erb +0 -14
  30. data/app/views/invitations/new.html.erb +0 -12
  31. data/devise_invitable.gemspec +0 -123
  32. data/init.rb +0 -1
  33. data/lib/devise_invitable/locales/en.yml +0 -5
  34. data/test/integration/invitable_test.rb +0 -122
  35. data/test/integration_tests_helper.rb +0 -39
  36. data/test/mailers/invitation_test.rb +0 -62
  37. data/test/model_tests_helper.rb +0 -41
  38. data/test/models/invitable_test.rb +0 -172
  39. data/test/models_test.rb +0 -35
  40. data/test/rails_app/app/controllers/admins_controller.rb +0 -6
  41. data/test/rails_app/app/controllers/application_controller.rb +0 -10
  42. data/test/rails_app/app/controllers/home_controller.rb +0 -4
  43. data/test/rails_app/app/controllers/users_controller.rb +0 -12
  44. data/test/rails_app/app/helpers/application_helper.rb +0 -3
  45. data/test/rails_app/app/models/user.rb +0 -4
  46. data/test/rails_app/app/views/home/index.html.erb +0 -0
  47. data/test/rails_app/config/boot.rb +0 -110
  48. data/test/rails_app/config/database.yml +0 -22
  49. data/test/rails_app/config/environment.rb +0 -44
  50. data/test/rails_app/config/environments/development.rb +0 -17
  51. data/test/rails_app/config/environments/production.rb +0 -28
  52. data/test/rails_app/config/environments/test.rb +0 -28
  53. data/test/rails_app/config/initializers/backtrace_silencers.rb +0 -7
  54. data/test/rails_app/config/initializers/devise.rb +0 -105
  55. data/test/rails_app/config/initializers/inflections.rb +0 -2
  56. data/test/rails_app/config/initializers/new_rails_defaults.rb +0 -21
  57. data/test/rails_app/config/initializers/session_store.rb +0 -15
  58. data/test/rails_app/config/routes.rb +0 -3
  59. data/test/rails_app/vendor/plugins/devise_invitable/init.rb +0 -1
  60. data/test/routes_test.rb +0 -20
  61. data/test/test_helper.rb +0 -58
@@ -1,29 +1,13 @@
1
- module DeviseInvitable
2
- module Routes #:doc:
3
- # Adds route generation for invitable. This method is responsible to
4
- # generate all needed routes for devise, based on what modules you have
5
- # defined in your model.
6
- # Examples: Let's say you have an User model configured to use
7
- # invitable module. After creating this inside your routes:
8
- #
9
- # map.devise_for :users
10
- #
11
- # this method is going to look inside your User model and create the
12
- # needed routes:
13
- #
14
- # # Invitation routes for Invitable, if User model has :invitable configured
15
- # new_user_invitation GET /users/invitation/new(.:format) {:controller=>"invitations", :action=>"new"}
16
- # user_invitation PUT /users/invitation(.:format) {:controller=>"invitations", :action=>"update"}
17
- # POST /users/invitation(.:format) {:controller=>"invitations", :action=>"create"}
18
- # accept_user_invitation GET /users/invitation/accept(.:format) {:controller=>"invitations", :action=>"edit"}
19
- #
20
-
21
- protected
22
- def invitable(routes, mapping)
23
- routes.resource :invitation, :only => [:new, :create, :update], :as => mapping.path_names[:invitation]
24
- routes.send(:"accept_#{mapping.name}_invitation", mapping.path_names[:accept] || 'accept', :controller => 'invitations', :action => 'edit', :name_prefix => nil, :path_prefix => "#{mapping.as}/invitation", :conditions => { :method => :get })
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+
4
+ protected
5
+ def devise_invitation(mapping, controllers)
6
+ resource :invitation, :only => [:new, :create, :update],
7
+ :path => mapping.path_names[:invitation], :controller => controllers[:invitations] do
8
+ get :edit, :path => mapping.path_names[:accept], :as => :accept
25
9
  end
10
+ end
11
+
26
12
  end
27
13
  end
28
-
29
- ActionDispatch::Routing::Mapper.send :include, DeviseInvitable::Routes
@@ -1,9 +1,34 @@
1
1
  module DeviseInvitable
2
2
  module Schema
3
- # Creates invitation_token and invitation_sent_at.
3
+ # Add invitation_token and invitation_sent_at columns in the resource's database table.
4
+ #
5
+ # Examples
6
+ #
7
+ # # For a new resource migration:
8
+ # create_table :the_resources do
9
+ # t.database_authenticatable :null => false # you need at least this
10
+ # t.invitable
11
+ # ...
12
+ # end
13
+ # add_index :the_resources, :invitation_token # for invitable
14
+ #
15
+ # # or if the resource's table already exists, define a migration and put this in:
16
+ # change_table :the_resources do |t|
17
+ # t.string :invitation_token, :limit => 60
18
+ # t.datetime :invitation_sent_at
19
+ # t.index :invitation_token # for invitable
20
+ # end
21
+ #
22
+ # # And allow encrypted_password to be null:
23
+ # change_column :the_resources, :encrypted_password, :string, :null => true
24
+ # # the following line is only if you use Devise's encryptable module!
25
+ # change_column :the_resources, :password_salt, :string, :null => true
4
26
  def invitable
5
- apply_schema :invitation_token, String, :limit => 20
6
- apply_schema :invitation_sent_at, DateTime
27
+ apply_devise_schema :invitation_token, String, :limit => 60
28
+ apply_devise_schema :invitation_sent_at, DateTime
29
+ apply_devise_schema :invitation_limit, Integer
30
+ apply_devise_schema :invited_by_id, Integer
31
+ apply_devise_schema :invited_by_type, String
7
32
  end
8
33
  end
9
34
  end
@@ -0,0 +1,3 @@
1
+ module DeviseInvitable
2
+ VERSION = '0.4.0'
3
+ end
@@ -1,17 +1,45 @@
1
- unless defined?(Devise)
2
- require 'devise'
3
- end
4
-
5
- Devise.module_eval do
6
- # Time interval where the invitation token is valid.
7
- mattr_accessor :invite_for
8
- @@invite_for = 0
9
- end
10
- Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model'
11
-
12
- module DeviseInvitable; end
1
+ require 'devise'
13
2
 
14
3
  require 'devise_invitable/mailer'
15
4
  require 'devise_invitable/routes'
16
5
  require 'devise_invitable/schema'
6
+ require 'devise_invitable/controllers/url_helpers'
7
+ require 'devise_invitable/controllers/helpers'
17
8
  require 'devise_invitable/rails'
9
+
10
+ module Devise
11
+ # Public: Validity period of the invitation token (default: 0). If
12
+ # invite_for is 0 or nil, the invitation will never expire.
13
+ # Set invite_for in the Devise configuration file (in config/initializers/devise.rb).
14
+ #
15
+ # config.invite_for = 2.weeks # => The invitation token will be valid 2 weeks
16
+ mattr_accessor :invite_for
17
+ @@invite_for = 0
18
+
19
+ # Public: Flag that force a record to be valid before being actually invited
20
+ # (default: false).
21
+ #
22
+ # Examples (in config/initializers/devise.rb)
23
+ #
24
+ # config.validate_on_invite = true
25
+ mattr_accessor :validate_on_invite
26
+ @@validate_on_invite = false
27
+
28
+ # Public: number of invitations the user is allowed to send
29
+ #
30
+ # Examples (in config/initializers/devise.rb)
31
+ #
32
+ # config.invitation_limit = nil
33
+ mattr_accessor :invitation_limit
34
+ @@invitation_limit = nil
35
+
36
+ # Public: The key to be used to check existing users when sending an invitation
37
+ #
38
+ # Examples (in config/initializers/devise.rb)
39
+ #
40
+ # config.invite_key = :email
41
+ mattr_accessor :invite_key
42
+ @@invite_key = :email
43
+ end
44
+
45
+ Devise.add_module :invitable, :controller => :invitations, :model => 'devise_invitable/model', :route => :invitation
@@ -0,0 +1,13 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module ActiveRecord
4
+ module Generators
5
+ class DeviseInvitableGenerator < ActiveRecord::Generators::Base
6
+ source_root File.expand_path("../templates", __FILE__)
7
+
8
+ def copy_devise_migration
9
+ migration_template "migration.rb", "db/migrate/devise_invitable_add_to_#{table_name}"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ class DeviseInvitableAddTo<%= table_name.camelize %> < ActiveRecord::Migration
2
+ def self.up
3
+ change_table :<%= table_name %> do |t|
4
+ t.string :invitation_token, :limit => 60
5
+ t.datetime :invitation_sent_at
6
+ t.integer :invitation_limit
7
+ t.references :invited_by, :polymorphic => true
8
+ t.index :invitation_token # for invitable
9
+ t.index :invited_by_id
10
+ end
11
+
12
+ # And allow null encrypted_password and password_salt:
13
+ change_column_null :<%= table_name %>, :encrypted_password, true
14
+ <% if class_name.constantize.columns_hash['password_salt'] -%>
15
+ change_column_null :<%= table_name %>, :password_salt, true
16
+ <% end -%>
17
+ end
18
+
19
+ def self.down
20
+ change_table :<%= table_name %> do |t|
21
+ remove_references :invited_by, :polymorphic => true
22
+ remove :invitation_limit, :invitation_sent_at, :invitation_token
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,20 @@
1
+ module DeviseInvitable
2
+ module Generators
3
+ class DeviseInvitableGenerator < Rails::Generators::NamedBase
4
+ namespace "devise_invitable"
5
+
6
+ desc "Add :invitable directive in the given model. Also generate migration for ActiveRecord"
7
+
8
+ # def devise_generate_model
9
+ # invoke "devise", [name]
10
+ # end
11
+
12
+ def inject_devise_invitable_content
13
+ path = File.join("app", "models", "#{file_path}.rb")
14
+ inject_into_file(path, "invitable, :", :after => "devise :") if File.exists?(path)
15
+ end
16
+
17
+ hook_for :orm
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ module DeviseInvitable
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+ desc "Add DeviseInvitable config variables to the Devise initializer and copy DeviseInvitable locale files to your application."
6
+
7
+ # def devise_install
8
+ # invoke "devise:install"
9
+ # end
10
+
11
+ def add_config_options_to_initializer
12
+ devise_initializer_path = "config/initializers/devise.rb"
13
+ if File.exist?(devise_initializer_path)
14
+ old_content = File.read(devise_initializer_path)
15
+
16
+ if old_content.match(Regexp.new(/^\s# ==> Configuration for :invitable\n/))
17
+ false
18
+ else
19
+ inject_into_file(devise_initializer_path, :before => " # ==> Configuration for :confirmable\n") do
20
+ <<-CONTENT
21
+ # ==> Configuration for :invitable
22
+ # The period the generated invitation token is valid, after
23
+ # this period, the invited resource won't be able to accept the invitation.
24
+ # When invite_for is 0 (the default), the invitation won't expire.
25
+ # config.invite_for = 2.weeks
26
+
27
+ # Number of invitations users can send.
28
+ # If invitation_limit is nil, users can send unlimited invitations.
29
+ # If invitation_limit is 0, users can't send invitations.
30
+ # If invitation_limit n > 0, users can send n invitations.
31
+ # Default: nil
32
+ # config.invitation_limit = 5
33
+
34
+ # The key to be used to check existing users when sending an invitation
35
+ # config.invite_key = :email
36
+
37
+ CONTENT
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def copy_locale
44
+ copy_file "../../../config/locales/en.yml", "config/locales/devise_invitable.en.yml"
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,10 @@
1
+ require 'generators/devise/views_generator'
2
+
3
+ module DeviseInvitable
4
+ module Generators
5
+ class ViewsGenerator < Devise::Generators::ViewsGenerator
6
+ source_root File.expand_path("../../../../app/views", __FILE__)
7
+ desc 'Copies all DeviseInvitable views to your application.'
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ require 'generators/devise/orm_helpers'
2
+
3
+ module Mongoid
4
+ module Generators
5
+ class DeviseInvitableGenerator < Rails::Generators::NamedBase
6
+ end
7
+ end
8
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_invitable
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 15
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
- - 3
8
+ - 4
8
9
  - 0
9
- version: 0.3.0
10
+ version: 0.4.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sergio Cambra
@@ -14,160 +15,128 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-17 00:00:00 +02:00
18
+ date: 2011-03-31 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
- name: mocha
22
+ name: bundler
22
23
  prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
24
26
  requirements:
25
- - - ">="
27
+ - - ~>
26
28
  - !ruby/object:Gem::Version
29
+ hash: 25
27
30
  segments:
31
+ - 1
28
32
  - 0
29
- version: "0"
33
+ - 7
34
+ version: 1.0.7
30
35
  type: :development
31
36
  version_requirements: *id001
32
37
  - !ruby/object:Gem::Dependency
33
- name: webrat
38
+ name: rails
34
39
  prerelease: false
35
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
36
42
  requirements:
37
- - - ">="
43
+ - - ~>
38
44
  - !ruby/object:Gem::Version
45
+ hash: 7
39
46
  segments:
47
+ - 3
40
48
  - 0
41
- version: "0"
42
- type: :development
49
+ - 0
50
+ version: 3.0.0
51
+ type: :runtime
43
52
  version_requirements: *id002
44
53
  - !ruby/object:Gem::Dependency
45
54
  name: devise
46
55
  prerelease: false
47
56
  requirement: &id003 !ruby/object:Gem::Requirement
57
+ none: false
48
58
  requirements:
49
59
  - - ~>
50
60
  - !ruby/object:Gem::Version
61
+ hash: 31
51
62
  segments:
52
63
  - 1
53
- - 1
64
+ - 2
54
65
  - 0
55
- version: 1.1.0
66
+ version: 1.2.0
56
67
  type: :runtime
57
68
  version_requirements: *id003
58
- description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation setting the password
59
- email: sergio@entrecables.com
69
+ description: It adds support for send invitations by email (it requires to be authenticated) and accept the invitation by setting a password.
70
+ email:
71
+ - sergio@entrecables.com
60
72
  executables: []
61
73
 
62
74
  extensions: []
63
75
 
64
- extra_rdoc_files:
65
- - LICENSE
66
- - README.rdoc
76
+ extra_rdoc_files: []
77
+
67
78
  files:
68
- - .document
69
- - .gitignore
70
- - LICENSE
71
- - README.rdoc
72
- - Rakefile
73
- - VERSION
74
- - app/controllers/invitations_controller.rb
75
- - app/views/devise_mailer/invitation.html.erb
76
- - app/views/invitations/edit.html.erb
77
- - app/views/invitations/new.html.erb
78
- - devise_invitable.gemspec
79
- - init.rb
79
+ - app/controllers/devise/invitations_controller.rb
80
+ - app/views/devise/invitations/edit.html.erb
81
+ - app/views/devise/invitations/new.html.erb
82
+ - app/views/devise/mailer/invitation_instructions.html.erb
83
+ - config/locales/en.yml
80
84
  - lib/devise_invitable.rb
81
- - lib/devise_invitable/controllers/helpers.rb
82
- - lib/devise_invitable/controllers/url_helpers.rb
83
- - lib/devise_invitable/locales/en.yml
84
85
  - lib/devise_invitable/mailer.rb
85
86
  - lib/devise_invitable/model.rb
86
87
  - lib/devise_invitable/rails.rb
87
88
  - lib/devise_invitable/routes.rb
88
89
  - lib/devise_invitable/schema.rb
89
- - test/integration/invitable_test.rb
90
- - test/integration_tests_helper.rb
91
- - test/mailers/invitation_test.rb
92
- - test/model_tests_helper.rb
93
- - test/models/invitable_test.rb
94
- - test/models_test.rb
95
- - test/rails_app/app/controllers/admins_controller.rb
96
- - test/rails_app/app/controllers/application_controller.rb
97
- - test/rails_app/app/controllers/home_controller.rb
98
- - test/rails_app/app/controllers/users_controller.rb
99
- - test/rails_app/app/helpers/application_helper.rb
100
- - test/rails_app/app/models/user.rb
101
- - test/rails_app/app/views/home/index.html.erb
102
- - test/rails_app/config/boot.rb
103
- - test/rails_app/config/database.yml
104
- - test/rails_app/config/environment.rb
105
- - test/rails_app/config/environments/development.rb
106
- - test/rails_app/config/environments/production.rb
107
- - test/rails_app/config/environments/test.rb
108
- - test/rails_app/config/initializers/backtrace_silencers.rb
109
- - test/rails_app/config/initializers/devise.rb
110
- - test/rails_app/config/initializers/inflections.rb
111
- - test/rails_app/config/initializers/new_rails_defaults.rb
112
- - test/rails_app/config/initializers/session_store.rb
113
- - test/rails_app/config/routes.rb
114
- - test/rails_app/vendor/plugins/devise_invitable/init.rb
115
- - test/routes_test.rb
116
- - test/test_helper.rb
90
+ - lib/devise_invitable/controllers/helpers.rb
91
+ - lib/devise_invitable/controllers/url_helpers.rb
92
+ - lib/devise_invitable/version.rb
93
+ - lib/generators/active_record/devise_invitable_generator.rb
94
+ - lib/generators/active_record/templates/migration.rb
95
+ - lib/generators/devise_invitable/views_generator.rb
96
+ - lib/generators/devise_invitable/devise_invitable_generator.rb
97
+ - lib/generators/devise_invitable/install_generator.rb
98
+ - lib/generators/mongoid/devise_invitable_generator.rb
99
+ - LICENSE
100
+ - README.rdoc
117
101
  has_rdoc: true
118
- homepage: http://github.com/scambra/devise_invitable
102
+ homepage: https://github.com/scambra/devise_invitable
119
103
  licenses: []
120
104
 
121
105
  post_install_message:
122
106
  rdoc_options:
107
+ - --main
108
+ - README.rdoc
123
109
  - --charset=UTF-8
124
110
  require_paths:
125
111
  - lib
126
112
  required_ruby_version: !ruby/object:Gem::Requirement
113
+ none: false
127
114
  requirements:
128
115
  - - ">="
129
116
  - !ruby/object:Gem::Version
117
+ hash: 59
130
118
  segments:
131
- - 0
132
- version: "0"
119
+ - 1
120
+ - 8
121
+ - 6
122
+ version: 1.8.6
133
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
+ none: false
134
125
  requirements:
135
126
  - - ">="
136
127
  - !ruby/object:Gem::Version
128
+ hash: 23
137
129
  segments:
138
- - 0
139
- version: "0"
130
+ - 1
131
+ - 3
132
+ - 6
133
+ version: 1.3.6
140
134
  requirements: []
141
135
 
142
136
  rubyforge_project:
143
- rubygems_version: 1.3.6
137
+ rubygems_version: 1.5.2
144
138
  signing_key:
145
139
  specification_version: 3
146
- summary: An invitation strategy for devise
147
- test_files:
148
- - test/integration/invitable_test.rb
149
- - test/integration_tests_helper.rb
150
- - test/mailers/invitation_test.rb
151
- - test/model_tests_helper.rb
152
- - test/models/invitable_test.rb
153
- - test/models_test.rb
154
- - test/rails_app/app/controllers/admins_controller.rb
155
- - test/rails_app/app/controllers/application_controller.rb
156
- - test/rails_app/app/controllers/home_controller.rb
157
- - test/rails_app/app/controllers/users_controller.rb
158
- - test/rails_app/app/helpers/application_helper.rb
159
- - test/rails_app/app/models/user.rb
160
- - test/rails_app/config/boot.rb
161
- - test/rails_app/config/environment.rb
162
- - test/rails_app/config/environments/development.rb
163
- - test/rails_app/config/environments/production.rb
164
- - test/rails_app/config/environments/test.rb
165
- - test/rails_app/config/initializers/backtrace_silencers.rb
166
- - test/rails_app/config/initializers/inflections.rb
167
- - test/rails_app/config/initializers/new_rails_defaults.rb
168
- - test/rails_app/config/initializers/session_store.rb
169
- - test/rails_app/config/initializers/devise.rb
170
- - test/rails_app/config/routes.rb
171
- - test/rails_app/vendor/plugins/devise_invitable/init.rb
172
- - test/routes_test.rb
173
- - test/test_helper.rb
140
+ summary: An invitation strategy for Devise
141
+ test_files: []
142
+
data/.document DELETED
@@ -1,5 +0,0 @@
1
- README.rdoc
2
- lib/**/*.rb
3
- bin/*
4
- features/**/*.feature
5
- LICENSE
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
- test/rails_app/log
data/Rakefile DELETED
@@ -1,54 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "devise_invitable"
8
- gem.summary = %Q{An invitation strategy for devise}
9
- gem.description = %Q{It adds support for send invitations by email (it requires to be authenticated) and accept the invitation setting the password}
10
- gem.email = "sergio@entrecables.com"
11
- gem.homepage = "http://github.com/scambra/devise_invitable"
12
- gem.authors = ["Sergio Cambra"]
13
- gem.add_development_dependency 'mocha'
14
- gem.add_development_dependency 'webrat'
15
- gem.add_dependency 'devise', '~> 1.1.0'
16
- end
17
- Jeweler::GemcutterTasks.new
18
- rescue LoadError
19
- puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
20
- end
21
-
22
- require 'rake/testtask'
23
- Rake::TestTask.new(:test) do |test|
24
- test.libs << 'lib' << 'test'
25
- test.pattern = 'test/**/*_test.rb'
26
- test.verbose = true
27
- end
28
-
29
- begin
30
- require 'rcov/rcovtask'
31
- Rcov::RcovTask.new do |test|
32
- test.libs << 'test'
33
- test.pattern = 'test/**/test_*.rb'
34
- test.verbose = true
35
- end
36
- rescue LoadError
37
- task :rcov do
38
- abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
39
- end
40
- end
41
-
42
- task :test => :check_dependencies
43
-
44
- task :default => :test
45
-
46
- require 'rake/rdoctask'
47
- Rake::RDocTask.new do |rdoc|
48
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
-
50
- rdoc.rdoc_dir = 'rdoc'
51
- rdoc.title = "devise_invitable #{version}"
52
- rdoc.rdoc_files.include('README*')
53
- rdoc.rdoc_files.include('lib/**/*.rb')
54
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.3.0
@@ -1,44 +0,0 @@
1
- class InvitationsController < ApplicationController
2
- include Devise::Controllers::InternalHelpers
3
-
4
- before_filter :authenticate_resource!, :only => [:new, :create]
5
- before_filter :require_no_authentication, :only => [:edit, :update]
6
- helper_method :after_sign_in_path_for
7
-
8
- # GET /resource/invitation/new
9
- def new
10
- build_resource
11
- render_with_scope :new
12
- end
13
-
14
- # POST /resource/invitation
15
- def create
16
- self.resource = resource_class.send_invitation(params[resource_name])
17
-
18
- if resource.errors.empty?
19
- set_flash_message :notice, :send_instructions
20
- redirect_to after_sign_in_path_for(resource_name)
21
- else
22
- render_with_scope :new
23
- end
24
- end
25
-
26
- # GET /resource/invitation/accept?invitation_token=abcdef
27
- def edit
28
- self.resource = resource_class.new
29
- resource.invitation_token = params[:invitation_token]
30
- render_with_scope :edit
31
- end
32
-
33
- # PUT /resource/invitation
34
- def update
35
- self.resource = resource_class.accept_invitation!(params[resource_name])
36
-
37
- if resource.errors.empty?
38
- set_flash_message :notice, :updated
39
- sign_in_and_redirect(resource_name, resource)
40
- else
41
- render_with_scope :edit
42
- end
43
- end
44
- end
@@ -1,8 +0,0 @@
1
- Hello <%= @resource.email %>!
2
-
3
- Someone has invited you to <%= root_url %>, you can accept it through the link below.
4
-
5
- <%= link_to 'Accept invitation', accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %>
6
-
7
- If you don't want to accept the invitation, please ignore this email.
8
- Your account won't be created until you access the link above and set your password.
@@ -1,14 +0,0 @@
1
- <h2>Set your password</h2>
2
-
3
- <% form_for resource_name, resource, :url => invitation_path(resource_name), :html => { :method => :put } do |f| %>
4
- <%= f.error_messages %>
5
- <%= f.hidden_field :invitation_token %>
6
-
7
- <p><%= f.label :password %></p>
8
- <p><%= f.password_field :password %></p>
9
-
10
- <p><%= f.label :password_confirmation %></p>
11
- <p><%= f.password_field :password_confirmation %></p>
12
-
13
- <p><%= f.submit "Set my password" %></p>
14
- <% end %>