i0n_rails3_generators 0.2.11 → 0.2.12
Sign up to get free protection for your applications and to get access to all the features.
data/config/version.yml
CHANGED
@@ -1,48 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
config.
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
1
|
+
module i0n
|
2
|
+
module Generators
|
3
|
+
class AuthenticationGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
def gemfile
|
8
|
+
gem("bcrypt-ruby")
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup_application
|
12
|
+
application do
|
13
|
+
'
|
14
|
+
# Configure sensitive parameters which will be filtered from the log file.
|
15
|
+
config.filter_parameters += [:password, :password_confirmation]
|
16
|
+
|
17
|
+
config.autoload_paths += %W(#{Rails.root}/lib)
|
18
|
+
'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_authentication_lib_and_include_in_application_helper
|
23
|
+
copy_file "lib/authentication.rb", "#{Rails.root}/lib/authentication.rb"
|
24
|
+
inject_into_class("app/controllers/application_controller.rb", "include Authentication")
|
25
|
+
end
|
26
|
+
|
27
|
+
def create_routes
|
28
|
+
route("match 'register' => 'users#new', :as => :register")
|
29
|
+
route("resources :users")
|
30
|
+
route("resources :user_sessions, :only => [:new, :create, :destroy]")
|
31
|
+
route("match 'login' => 'user_sessions#new', :as => :login")
|
32
|
+
route("match 'logout' => 'user_sessions#destroy', :as => :logout")
|
33
|
+
end
|
34
|
+
|
35
|
+
def create_models
|
36
|
+
generate("model", "user email:string password_hash:string password_salt:string")
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_controllers
|
40
|
+
generate("controller", "user_sessions")
|
41
|
+
generate("controller", "users")
|
42
|
+
inject_into_class("app/controllers/users_controller.rb", IO.read("#{AuthenticationGenerator.source_root}/app/controllers/_users_controller.rb"))
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_views
|
46
|
+
directory "app/views/users", "#{Rails.root}/app/views/users"
|
47
|
+
directory "app/view/user_sessions", "#{Rails.root}/app/views/user_sessions"
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
23
51
|
end
|
24
|
-
|
25
|
-
def create_routes
|
26
|
-
route("match 'register' => 'users#new', :as => :register")
|
27
|
-
route("resources :users")
|
28
|
-
route("resources :user_sessions, :only => [:new, :create, :destroy]")
|
29
|
-
route("match 'login' => 'user_sessions#new', :as => :login")
|
30
|
-
route("match 'logout' => 'user_sessions#destroy', :as => :logout")
|
31
|
-
end
|
32
|
-
|
33
|
-
def create_models
|
34
|
-
generate("model", "user email:string password_hash:string password_salt:string")
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_controllers
|
38
|
-
generate("controller", "user_sessions")
|
39
|
-
generate("controller", "users")
|
40
|
-
inject_into_class("app/controllers/users_controller.rb", IO.read("#{AuthenticationGenerator.source_root}/app/controllers/_users_controller.rb"))
|
41
|
-
end
|
42
|
-
|
43
|
-
def create_views
|
44
|
-
directory "app/views/users", "#{Rails.root}/app/views/users"
|
45
|
-
directory "app/view/user_sessions", "#{Rails.root}/app/views/user_sessions"
|
46
|
-
end
|
47
|
-
|
48
52
|
end
|