hero_generator 0.0.1.alpha7 → 0.0.1.beta
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/hero/authentication/authentication_generator.rb +51 -19
- data/lib/generators/hero/config/USAGE +8 -0
- data/lib/generators/hero/config/config_generator.rb +24 -0
- data/lib/generators/hero/config/templates/config.yml +12 -0
- data/lib/generators/hero/config/templates/load_config.rb +2 -0
- data/lib/hero_generator/version.rb +1 -1
- metadata +12 -9
- data/lib/generators/hero/authentication/templates/config/routes.rb +0 -29
- /data/lib/generators/hero/authentication/templates/migrations/{20120213162337_create_users.rb → create_users.rb} +0 -0
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'generators/hero'
|
2
|
-
|
2
|
+
require 'rails/generators/migration'
|
3
3
|
|
4
4
|
module Hero
|
5
5
|
module Generators
|
6
6
|
class AuthenticationGenerator < Base
|
7
|
-
|
7
|
+
include Rails::Generators::Migration
|
8
8
|
|
9
9
|
attr_accessor :user_name, :session_name
|
10
10
|
|
@@ -12,18 +12,24 @@ module Hero
|
|
12
12
|
argument :session_name, :type => :string, :default => "session"
|
13
13
|
|
14
14
|
|
15
|
-
def
|
15
|
+
def create_model_files
|
16
16
|
template "models/user.rb", "app/models/#{user_singular_name}.rb"
|
17
17
|
template "models/authentication.rb", "app/models/authentication.rb"
|
18
|
-
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_controller_files
|
19
21
|
template "controllers/users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
|
20
22
|
template "controllers/settings_controller.rb", "app/controllers/settings_controller.rb"
|
21
23
|
template "controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
|
22
24
|
template "controllers/confirmation_controller.rb", "app/controllers/confirmation_controller.rb"
|
23
|
-
template "controllers/application_controller.rb", "app/controllers/application_controller.rb"
|
24
|
-
|
25
|
+
template "controllers/application_controller.rb", "app/controllers/application_controller.rb"
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_mailer_files
|
25
29
|
template "mailers/confirmation_mailer.rb", "app/mailers/confirmation_mailer.rb"
|
26
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_views
|
27
33
|
template "views/confirmation/new_email_token.html.haml", "app/views/confirmation/new_email_token.html.haml"
|
28
34
|
template "views/confirmation/order_new_password.html.haml", "app/views/confirmation/order_new_password.html.haml"
|
29
35
|
template "views/confirmation/password_token.html.haml", "app/views/confirmation/password_token.html.haml"
|
@@ -40,35 +46,52 @@ module Hero
|
|
40
46
|
template "views/sessions/new.html.haml", "app/views/sessions/new.html.haml"
|
41
47
|
template "views/settings/index.html.haml", "app/views/settings/index.html.haml"
|
42
48
|
template "views/users/new.html.haml", "app/views/users/new.html.haml"
|
43
|
-
|
44
|
-
|
45
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_config_files
|
52
|
+
template "config/config.yml", "config/app_config.yml"
|
46
53
|
template "config/initializers/action_mailer.rb", "config/initializers/action_mailer.rb"
|
47
|
-
template "config/initializers/load_config.rb", "config/initializers/load_config.rb"
|
48
|
-
template "migrations/20120213162337_create_users.rb", "db/migrate/20120213162337_create_users.rb"
|
49
|
-
template "config/routes.rb", "config/routes.rb"
|
50
54
|
template "config/locales/en.yml", "config/locales/en.yml"
|
51
|
-
|
52
|
-
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_migration
|
58
|
+
migration_template 'migrations/create_users.rb', "db/migrate/create_#{user_plural_name}.rb"
|
59
|
+
end
|
60
|
+
|
61
|
+
def create_test_files
|
53
62
|
template "tests/spec/controllers/sessions_controller_spec.rb", "spec/controllers/sessions_controller_spec.rb"
|
54
63
|
template "tests/spec/controllers/users_controller_spec.rb", "spec/controllers/users_controller_spec.rb"
|
55
|
-
|
56
64
|
template "tests/spec/models/user_spec.rb", "spec/models/user_spec.rb"
|
57
65
|
template "tests/spec/requests/new_email_request_spec.rb", "spec/requests/new_email_request_spec.rb"
|
58
66
|
template "tests/spec/requests/password_resets_spec.rb", "spec/requests/password_resets_spec.rb"
|
59
67
|
template "tests/spec/requests/user_confirmation_spec.rb", "spec/requests/user_confirmation_spec.rb"
|
60
68
|
template "tests/spec/requests/user_sign_in_spec.rb", "spec/requests/user_sign_in_spec.rb"
|
61
69
|
template "tests/spec/requests/user_sign_up_spec.rb", "spec/requests/user_sign_up_spec.rb"
|
62
|
-
|
63
70
|
template "tests/spec/routing/confirmation_mailer_spec.rb", "spec/routing/confirmation_mailer_spec.rb"
|
64
|
-
|
65
71
|
template "tests/spec/support/mailer_macros.rb", "spec/support/mailer_macros.rb"
|
66
|
-
|
67
72
|
template "tests/spec/factories.rb", "spec/factories.rb"
|
68
73
|
template "tests/spec/spec_helper.rb", "spec/spec_helper.rb"
|
69
74
|
end
|
70
75
|
|
71
76
|
|
77
|
+
def create_routes
|
78
|
+
route "resources #{user_plural_name.to_sym.inspect}"
|
79
|
+
route "resources #{session_plural_name.to_sym.inspect}"
|
80
|
+
route "get 'log_out' => '#{session_plural_name.to_sym.inspect}#destroy', :as => 'log_out'"
|
81
|
+
route "get 'registrieren' => '#{user_singular_name}#new', :as => 'sign_up_form'"
|
82
|
+
route "post 'sign_up' => '#{user_singular_name}#create', :as => 'sign_up'"
|
83
|
+
route "match 'confirm/resend_confirmation' => 'confirmation#resend_signup_token', :as => 'resend_signup_token'"
|
84
|
+
route "match 'confirm/:action(/:token)', :controller => :confirmation, :as => 'confirm'"
|
85
|
+
route "match 'log_in' => '#{session_plural_name.to_sym.inspect}#new', :as => 'log_in', :via => :get"
|
86
|
+
route "match 'log_in' => '#{session_plural_name.to_sym.inspect}#create', :as => 'log_in', :via => :post"
|
87
|
+
route "get 'recover_password_auth(/:token)' => 'confirmation#recover_password_auth', :as => 'recover_password_auth'"
|
88
|
+
route "match 'recover_password(/:token)' => 'confirmation#recover_password', :as => 'recover_password'"
|
89
|
+
route "match 'new_email(/:token)' => 'confirmation#new_email', :as => 'new_email'"
|
90
|
+
route "match 'request_password' => 'confirmation#order_new_password', :as => 'order_new_password'"
|
91
|
+
route "match 'notice' => 'application#notice', :as => 'notice'"
|
92
|
+
route "root :to => '#{user_singular_name}#new'"
|
93
|
+
end
|
94
|
+
|
72
95
|
private
|
73
96
|
|
74
97
|
def user_singular_name
|
@@ -102,6 +125,15 @@ module Hero
|
|
102
125
|
def session_plural_class_name
|
103
126
|
session_plural_name.camelize
|
104
127
|
end
|
128
|
+
|
129
|
+
def self.next_migration_number(dirname) #:nodoc:
|
130
|
+
if ActiveRecord::Base.timestamped_migrations
|
131
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
132
|
+
else
|
133
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
105
137
|
end
|
106
138
|
end
|
107
139
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'generators/hero'
|
2
|
+
|
3
|
+
module Hero
|
4
|
+
module Generators
|
5
|
+
class ConfigGenerator < Base
|
6
|
+
argument :config_name, :type => :string, :default => 'app'
|
7
|
+
|
8
|
+
def create_config
|
9
|
+
template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
|
10
|
+
copy_file "config.yml", "config/#{file_name}_config.yml"
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def file_name
|
16
|
+
config_name.underscore
|
17
|
+
end
|
18
|
+
|
19
|
+
def constant_name
|
20
|
+
config_name.underscore.upcase
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hero_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-02-24 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec-rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &74291790 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '2.6'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *74291790
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bcrypt-ruby
|
27
|
-
requirement: &
|
27
|
+
requirement: &74291220 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.1.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *74291220
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &74290940 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: 3.0.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *74290940
|
47
47
|
description: Write a gem description
|
48
48
|
email:
|
49
49
|
- guido@boyke.de
|
@@ -89,13 +89,16 @@ files:
|
|
89
89
|
- lib/generators/hero/authentication/templates/config/initializers/load_config.rb
|
90
90
|
- lib/generators/hero/authentication/templates/config/config.yml
|
91
91
|
- lib/generators/hero/authentication/templates/config/locales/en.yml
|
92
|
-
- lib/generators/hero/authentication/templates/
|
93
|
-
- lib/generators/hero/authentication/templates/migrations/20120213162337_create_users.rb
|
92
|
+
- lib/generators/hero/authentication/templates/migrations/create_users.rb
|
94
93
|
- lib/generators/hero/authentication/templates/controllers/confirmation_controller.rb
|
95
94
|
- lib/generators/hero/authentication/templates/controllers/users_controller.rb
|
96
95
|
- lib/generators/hero/authentication/templates/controllers/settings_controller.rb
|
97
96
|
- lib/generators/hero/authentication/templates/controllers/application_controller.rb
|
98
97
|
- lib/generators/hero/authentication/templates/controllers/sessions_controller.rb
|
98
|
+
- lib/generators/hero/config/USAGE
|
99
|
+
- lib/generators/hero/config/templates/config.yml
|
100
|
+
- lib/generators/hero/config/templates/load_config.rb
|
101
|
+
- lib/generators/hero/config/config_generator.rb
|
99
102
|
- lib/generators/hero.rb
|
100
103
|
- Gemfile
|
101
104
|
- Rakefile
|
@@ -1,29 +0,0 @@
|
|
1
|
-
Wrkplc::Application.routes.draw do
|
2
|
-
default_url_options :host => "localhost:3000"
|
3
|
-
|
4
|
-
get "log_out" => "sessions#destroy", :as => "log_out"
|
5
|
-
get "registrieren" => "users#new", :as => "sign_up_form"
|
6
|
-
post "sign_up" => "users#create", :as => "sign_up"
|
7
|
-
|
8
|
-
match 'confirm/resend_confirmation' => "confirmation#resend_signup_token", :as => 'resend_signup_token'
|
9
|
-
match 'confirm/:action(/:token)', :controller => :confirmation, :as => 'confirm'
|
10
|
-
|
11
|
-
|
12
|
-
match "log_in" => "sessions#new", :as => "log_in", :via => :get
|
13
|
-
match "log_in" => "sessions#create", :as => "log_in", :via => :post
|
14
|
-
|
15
|
-
get 'recover_password_auth(/:token)' => "confirmation#recover_password_auth", :as => 'recover_password_auth'
|
16
|
-
match 'recover_password(/:token)' => "confirmation#recover_password", :as => 'recover_password'
|
17
|
-
|
18
|
-
match 'new_email(/:token)' => "confirmation#new_email", :as => 'new_email'
|
19
|
-
|
20
|
-
match 'request_password' => "confirmation#order_new_password", :as => 'order_new_password'
|
21
|
-
|
22
|
-
match 'notice' => 'application#notice', :as => 'notice'
|
23
|
-
|
24
|
-
root :to => "users#new"
|
25
|
-
|
26
|
-
resources :users
|
27
|
-
resources :sessions
|
28
|
-
match '/:controller(/:action(/:id))'
|
29
|
-
end
|
File without changes
|