flexi_generators 0.2.10 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. data/.gitignore +17 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE +22 -0
  4. data/README.md +29 -0
  5. data/Rakefile +2 -16
  6. data/flexi_generators.gemspec +17 -114
  7. data/lib/flexi_generators.rb +11 -0
  8. data/lib/generators/flexi/config/config_generator.rb +25 -0
  9. data/lib/generators/flexi/config/templates/field_error.rb +9 -0
  10. data/lib/generators/flexi/config/templates/inflector_portuguese.rb +62 -0
  11. data/lib/generators/flexi/config/templates/pt-BR.yml +224 -0
  12. data/lib/generators/flexi/config/templates/will_paginate.rb +26 -0
  13. data/lib/generators/flexi/install/install_generator.rb +28 -0
  14. data/lib/generators/flexi/install/templates/application.css +15 -0
  15. data/lib/generators/flexi/install/templates/application.js +16 -0
  16. data/lib/generators/flexi/layout/layout_generator.rb +46 -0
  17. data/lib/generators/flexi/layout/templates/_flash.html.erb +4 -0
  18. data/lib/generators/flexi/layout/templates/_navbar.html.erb +6 -0
  19. data/lib/generators/flexi/layout/templates/_sidebar.html.erb +16 -0
  20. data/lib/generators/flexi/layout/templates/_user_dropdown.html.erb +11 -0
  21. data/lib/generators/flexi/layout/templates/application.css +16 -0
  22. data/lib/generators/flexi/layout/templates/dashboard.html.erb +49 -0
  23. data/lib/generators/flexi/layout/templates/error_messages_helper.rb +33 -0
  24. data/lib/generators/flexi/layout/templates/layout.css +8 -0
  25. data/lib/generators/flexi/layout/templates/layout.html.erb +76 -0
  26. data/lib/generators/flexi/layout/templates/layout_helper.rb +47 -0
  27. data/lib/generators/flexi/scaffold/scaffold_generator.rb +24 -109
  28. data/lib/generators/flexi/scaffold/templates/_form.html.erb +22 -0
  29. data/lib/generators/flexi/scaffold/templates/edit.html.erb +1 -0
  30. data/lib/generators/flexi/scaffold/templates/index.html.erb +36 -0
  31. data/lib/generators/flexi/scaffold/templates/new.html.erb +1 -0
  32. data/lib/generators/flexi/scaffold/templates/show.html.erb +21 -0
  33. data/lib/twitter-bootstrap/engine.rb +6 -0
  34. data/lib/twitter-bootstrap/railtie.rb +6 -0
  35. data/lib/twitter-bootstrap/version.rb +5 -0
  36. data/lib/version.rb +3 -0
  37. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  38. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  39. data/vendor/assets/javascripts/bootstrap.js +1825 -0
  40. data/vendor/assets/stylesheets/bootstrap-responsive.css +815 -0
  41. data/vendor/assets/stylesheets/bootstrap.css +4983 -0
  42. metadata +51 -89
  43. data/README.textile +0 -64
  44. data/VERSION +0 -1
  45. data/lib/generators/flexi.rb +0 -16
  46. data/lib/generators/flexi/auth/USAGE +0 -5
  47. data/lib/generators/flexi/auth/auth_generator.rb +0 -122
  48. data/lib/generators/flexi/auth/templates/authentication.rb +0 -55
  49. data/lib/generators/flexi/auth/templates/authlogic_session.rb +0 -2
  50. data/lib/generators/flexi/auth/templates/fixtures.yml +0 -24
  51. data/lib/generators/flexi/auth/templates/migration.rb +0 -16
  52. data/lib/generators/flexi/auth/templates/sessions_controller.rb +0 -26
  53. data/lib/generators/flexi/auth/templates/sessions_helper.rb +0 -2
  54. data/lib/generators/flexi/auth/templates/tests/testunit/sessions_controller.rb +0 -20
  55. data/lib/generators/flexi/auth/templates/tests/testunit/user.rb +0 -4
  56. data/lib/generators/flexi/auth/templates/tests/testunit/users_controller.rb +0 -23
  57. data/lib/generators/flexi/auth/templates/user.rb +0 -3
  58. data/lib/generators/flexi/auth/templates/users_controller.rb +0 -43
  59. data/lib/generators/flexi/auth/templates/users_helper.rb +0 -2
  60. data/lib/generators/flexi/auth/templates/views/erb/_error_messages.html.erb +0 -11
  61. data/lib/generators/flexi/auth/templates/views/erb/_menu.html.erb +0 -16
  62. data/lib/generators/flexi/auth/templates/views/erb/application.html.erb +0 -39
  63. data/lib/generators/flexi/auth/templates/views/erb/edit.html.erb +0 -24
  64. data/lib/generators/flexi/auth/templates/views/erb/index.html.erb +0 -27
  65. data/lib/generators/flexi/auth/templates/views/erb/login.html.erb +0 -22
  66. data/lib/generators/flexi/auth/templates/views/erb/new.html.erb +0 -24
  67. data/lib/generators/flexi/auth/templates/views/erb/show.html.erb +0 -16
  68. data/lib/generators/flexi/prepare/USAGE +0 -6
  69. data/lib/generators/flexi/prepare/prepare_generator.rb +0 -68
  70. data/lib/generators/flexi/prepare/templates/add.png +0 -0
  71. data/lib/generators/flexi/prepare/templates/admin_home_controller.rb +0 -6
  72. data/lib/generators/flexi/prepare/templates/admin_home_index.html.erb +0 -16
  73. data/lib/generators/flexi/prepare/templates/application.css +0 -279
  74. data/lib/generators/flexi/prepare/templates/application_helper.rb +0 -44
  75. data/lib/generators/flexi/prepare/templates/back.png +0 -0
  76. data/lib/generators/flexi/prepare/templates/bg.png +0 -0
  77. data/lib/generators/flexi/prepare/templates/bg2.png +0 -0
  78. data/lib/generators/flexi/prepare/templates/boxheader.gif +0 -0
  79. data/lib/generators/flexi/prepare/templates/btn-bg-hover.png +0 -0
  80. data/lib/generators/flexi/prepare/templates/btn-bg.png +0 -0
  81. data/lib/generators/flexi/prepare/templates/custom_field_error.rb +0 -12
  82. data/lib/generators/flexi/prepare/templates/delete.png +0 -0
  83. data/lib/generators/flexi/prepare/templates/edit.png +0 -0
  84. data/lib/generators/flexi/prepare/templates/inflector_portuguese.rb +0 -60
  85. data/lib/generators/flexi/prepare/templates/login.css +0 -142
  86. data/lib/generators/flexi/prepare/templates/login.html.erb +0 -26
  87. data/lib/generators/flexi/prepare/templates/logo.png +0 -0
  88. data/lib/generators/flexi/prepare/templates/menu.png +0 -0
  89. data/lib/generators/flexi/prepare/templates/messages/Thumbs.db +0 -0
  90. data/lib/generators/flexi/prepare/templates/messages/error.png +0 -0
  91. data/lib/generators/flexi/prepare/templates/messages/info.png +0 -0
  92. data/lib/generators/flexi/prepare/templates/messages/success.png +0 -0
  93. data/lib/generators/flexi/prepare/templates/messages/tip.png +0 -0
  94. data/lib/generators/flexi/prepare/templates/messages/warning.png +0 -0
  95. data/lib/generators/flexi/prepare/templates/pt-BR.yml +0 -206
  96. data/lib/generators/flexi/prepare/templates/routes.rb +0 -3
  97. data/lib/generators/flexi/prepare/templates/show.png +0 -0
  98. data/lib/generators/flexi/prepare/templates/site.css +0 -72
  99. data/lib/generators/flexi/prepare/templates/site.html.erb +0 -20
  100. data/lib/generators/flexi/prepare/templates/site_controller.rb +0 -9
  101. data/lib/generators/flexi/prepare/templates/site_helper.rb +0 -2
  102. data/lib/generators/flexi/prepare/templates/site_index.html.erb +0 -27
  103. data/lib/generators/flexi/prepare/templates/users.png +0 -0
  104. data/lib/generators/flexi/scaffold/USAGE +0 -5
  105. data/lib/generators/flexi/scaffold/templates/controller.rb +0 -43
  106. data/lib/generators/flexi/scaffold/templates/fixtures.yml +0 -9
  107. data/lib/generators/flexi/scaffold/templates/helper.rb +0 -2
  108. data/lib/generators/flexi/scaffold/templates/migration.rb +0 -14
  109. data/lib/generators/flexi/scaffold/templates/model.rb +0 -3
  110. data/lib/generators/flexi/scaffold/templates/tests/controller.rb +0 -50
  111. data/lib/generators/flexi/scaffold/templates/tests/helper.rb +0 -4
  112. data/lib/generators/flexi/scaffold/templates/tests/model.rb +0 -8
  113. data/lib/generators/flexi/scaffold/templates/views/erb/_error_messages.html.erb +0 -11
  114. data/lib/generators/flexi/scaffold/templates/views/erb/_form.html.erb +0 -13
  115. data/lib/generators/flexi/scaffold/templates/views/erb/edit.html.erb +0 -3
  116. data/lib/generators/flexi/scaffold/templates/views/erb/index.html.erb +0 -29
  117. data/lib/generators/flexi/scaffold/templates/views/erb/new.html.erb +0 -3
  118. data/lib/generators/flexi/scaffold/templates/views/erb/show.html.erb +0 -15
  119. data/template.rb +0 -15
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexi_generators
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 2
9
- - 10
10
- version: 0.2.10
8
+ - 3
9
+ - 0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leandro de Oliveira
@@ -15,99 +15,61 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-21 00:00:00 Z
18
+ date: 2012-06-13 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
- description: Generates authentication and custom scaffold templates.
22
- email: ol.leandro@gmail.com
21
+ description: "Rails generators scripts for scaffolding and layout files containing Twitter\xE2\x80\x99s Bootstrap CSS"
22
+ email:
23
+ - ol.leandro@gmail.com
23
24
  executables: []
24
25
 
25
26
  extensions: []
26
27
 
27
- extra_rdoc_files:
28
- - README.textile
28
+ extra_rdoc_files: []
29
+
29
30
  files:
30
- - README.textile
31
+ - .gitignore
32
+ - Gemfile
33
+ - LICENSE
34
+ - README.md
31
35
  - Rakefile
32
- - VERSION
33
36
  - flexi_generators.gemspec
34
- - lib/generators/flexi.rb
35
- - lib/generators/flexi/auth/USAGE
36
- - lib/generators/flexi/auth/auth_generator.rb
37
- - lib/generators/flexi/auth/templates/authentication.rb
38
- - lib/generators/flexi/auth/templates/authlogic_session.rb
39
- - lib/generators/flexi/auth/templates/fixtures.yml
40
- - lib/generators/flexi/auth/templates/migration.rb
41
- - lib/generators/flexi/auth/templates/sessions_controller.rb
42
- - lib/generators/flexi/auth/templates/sessions_helper.rb
43
- - lib/generators/flexi/auth/templates/tests/testunit/sessions_controller.rb
44
- - lib/generators/flexi/auth/templates/tests/testunit/user.rb
45
- - lib/generators/flexi/auth/templates/tests/testunit/users_controller.rb
46
- - lib/generators/flexi/auth/templates/user.rb
47
- - lib/generators/flexi/auth/templates/users_controller.rb
48
- - lib/generators/flexi/auth/templates/users_helper.rb
49
- - lib/generators/flexi/auth/templates/views/erb/_error_messages.html.erb
50
- - lib/generators/flexi/auth/templates/views/erb/_menu.html.erb
51
- - lib/generators/flexi/auth/templates/views/erb/application.html.erb
52
- - lib/generators/flexi/auth/templates/views/erb/edit.html.erb
53
- - lib/generators/flexi/auth/templates/views/erb/index.html.erb
54
- - lib/generators/flexi/auth/templates/views/erb/login.html.erb
55
- - lib/generators/flexi/auth/templates/views/erb/new.html.erb
56
- - lib/generators/flexi/auth/templates/views/erb/show.html.erb
57
- - lib/generators/flexi/prepare/USAGE
58
- - lib/generators/flexi/prepare/prepare_generator.rb
59
- - lib/generators/flexi/prepare/templates/add.png
60
- - lib/generators/flexi/prepare/templates/admin_home_controller.rb
61
- - lib/generators/flexi/prepare/templates/admin_home_index.html.erb
62
- - lib/generators/flexi/prepare/templates/application.css
63
- - lib/generators/flexi/prepare/templates/application_helper.rb
64
- - lib/generators/flexi/prepare/templates/back.png
65
- - lib/generators/flexi/prepare/templates/bg.png
66
- - lib/generators/flexi/prepare/templates/bg2.png
67
- - lib/generators/flexi/prepare/templates/boxheader.gif
68
- - lib/generators/flexi/prepare/templates/btn-bg-hover.png
69
- - lib/generators/flexi/prepare/templates/btn-bg.png
70
- - lib/generators/flexi/prepare/templates/custom_field_error.rb
71
- - lib/generators/flexi/prepare/templates/delete.png
72
- - lib/generators/flexi/prepare/templates/edit.png
73
- - lib/generators/flexi/prepare/templates/inflector_portuguese.rb
74
- - lib/generators/flexi/prepare/templates/login.css
75
- - lib/generators/flexi/prepare/templates/login.html.erb
76
- - lib/generators/flexi/prepare/templates/logo.png
77
- - lib/generators/flexi/prepare/templates/menu.png
78
- - lib/generators/flexi/prepare/templates/messages/Thumbs.db
79
- - lib/generators/flexi/prepare/templates/messages/error.png
80
- - lib/generators/flexi/prepare/templates/messages/info.png
81
- - lib/generators/flexi/prepare/templates/messages/success.png
82
- - lib/generators/flexi/prepare/templates/messages/tip.png
83
- - lib/generators/flexi/prepare/templates/messages/warning.png
84
- - lib/generators/flexi/prepare/templates/pt-BR.yml
85
- - lib/generators/flexi/prepare/templates/routes.rb
86
- - lib/generators/flexi/prepare/templates/show.png
87
- - lib/generators/flexi/prepare/templates/site.css
88
- - lib/generators/flexi/prepare/templates/site.html.erb
89
- - lib/generators/flexi/prepare/templates/site_controller.rb
90
- - lib/generators/flexi/prepare/templates/site_helper.rb
91
- - lib/generators/flexi/prepare/templates/site_index.html.erb
92
- - lib/generators/flexi/prepare/templates/users.png
93
- - lib/generators/flexi/scaffold/USAGE
37
+ - lib/flexi_generators.rb
38
+ - lib/generators/flexi/config/config_generator.rb
39
+ - lib/generators/flexi/config/templates/field_error.rb
40
+ - lib/generators/flexi/config/templates/inflector_portuguese.rb
41
+ - lib/generators/flexi/config/templates/pt-BR.yml
42
+ - lib/generators/flexi/config/templates/will_paginate.rb
43
+ - lib/generators/flexi/install/install_generator.rb
44
+ - lib/generators/flexi/install/templates/application.css
45
+ - lib/generators/flexi/install/templates/application.js
46
+ - lib/generators/flexi/layout/layout_generator.rb
47
+ - lib/generators/flexi/layout/templates/_flash.html.erb
48
+ - lib/generators/flexi/layout/templates/_navbar.html.erb
49
+ - lib/generators/flexi/layout/templates/_sidebar.html.erb
50
+ - lib/generators/flexi/layout/templates/_user_dropdown.html.erb
51
+ - lib/generators/flexi/layout/templates/application.css
52
+ - lib/generators/flexi/layout/templates/dashboard.html.erb
53
+ - lib/generators/flexi/layout/templates/error_messages_helper.rb
54
+ - lib/generators/flexi/layout/templates/layout.css
55
+ - lib/generators/flexi/layout/templates/layout.html.erb
56
+ - lib/generators/flexi/layout/templates/layout_helper.rb
94
57
  - lib/generators/flexi/scaffold/scaffold_generator.rb
95
- - lib/generators/flexi/scaffold/templates/controller.rb
96
- - lib/generators/flexi/scaffold/templates/fixtures.yml
97
- - lib/generators/flexi/scaffold/templates/helper.rb
98
- - lib/generators/flexi/scaffold/templates/migration.rb
99
- - lib/generators/flexi/scaffold/templates/model.rb
100
- - lib/generators/flexi/scaffold/templates/tests/controller.rb
101
- - lib/generators/flexi/scaffold/templates/tests/helper.rb
102
- - lib/generators/flexi/scaffold/templates/tests/model.rb
103
- - lib/generators/flexi/scaffold/templates/views/erb/_error_messages.html.erb
104
- - lib/generators/flexi/scaffold/templates/views/erb/_form.html.erb
105
- - lib/generators/flexi/scaffold/templates/views/erb/edit.html.erb
106
- - lib/generators/flexi/scaffold/templates/views/erb/index.html.erb
107
- - lib/generators/flexi/scaffold/templates/views/erb/new.html.erb
108
- - lib/generators/flexi/scaffold/templates/views/erb/show.html.erb
109
- - template.rb
110
- homepage: http://github.com/leandroo/flexi_generators
58
+ - lib/generators/flexi/scaffold/templates/_form.html.erb
59
+ - lib/generators/flexi/scaffold/templates/edit.html.erb
60
+ - lib/generators/flexi/scaffold/templates/index.html.erb
61
+ - lib/generators/flexi/scaffold/templates/new.html.erb
62
+ - lib/generators/flexi/scaffold/templates/show.html.erb
63
+ - lib/twitter-bootstrap/engine.rb
64
+ - lib/twitter-bootstrap/railtie.rb
65
+ - lib/twitter-bootstrap/version.rb
66
+ - lib/version.rb
67
+ - vendor/assets/images/glyphicons-halflings-white.png
68
+ - vendor/assets/images/glyphicons-halflings.png
69
+ - vendor/assets/javascripts/bootstrap.js
70
+ - vendor/assets/stylesheets/bootstrap-responsive.css
71
+ - vendor/assets/stylesheets/bootstrap.css
72
+ homepage: https://github.com/leandroo/flexi_generators
111
73
  licenses: []
112
74
 
113
75
  post_install_message:
@@ -136,9 +98,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
98
  requirements: []
137
99
 
138
100
  rubyforge_project:
139
- rubygems_version: 1.7.2
101
+ rubygems_version: 1.8.17
140
102
  signing_key:
141
103
  specification_version: 3
142
- summary: My useful Rails generator scripts.
104
+ summary: ""
143
105
  test_files: []
144
106
 
data/README.textile DELETED
@@ -1,64 +0,0 @@
1
- h1. Flexi Generators
2
-
3
- My Rails generator scripts. Generates controllers, views, layouts and stylesheets with:
4
-
5
- * Login layout
6
- * App layout
7
- * Menus with Menu Builder plugin
8
- * Pagination with Will Paginate plugin
9
-
10
- h2. Instalation
11
-
12
- Rail2
13
-
14
- For more details about configuration in Rails 2 look "here":http://github.com/leandroo/flexi_generators/tree/v0.1.0
15
-
16
- Rails3
17
-
18
- <pre>
19
- gem "flexi_generators"
20
- </pre>
21
-
22
- h2. Included Generators
23
-
24
- * flexi_prepare: generates initial files anda configurations.
25
- * flexi_auth: generates user model with sign up and log in.
26
- * flexi_scaffold: generates custom scaffold.
27
-
28
- h2. Quickstart Rails 3
29
-
30
- These 4 simple steps are the essentials to get you smoothly up and running…
31
-
32
- 1. Create your app and configure all dependencies
33
- @rails new appname -m http://leandroo.com.br/flexi_generators/template.rb@
34
- 2. Run @bundle install@, @rake db:migrate@ and @rake db:seed@ to installs all required gems and create your database
35
- 3. Start your server with @rails server@
36
- 4. Open up "http://localhost:3000":http://localhost:3000
37
-
38
- h2. Usage
39
-
40
- <pre>
41
- rails g flexi_prepare
42
- ...
43
- rails g flexi_auth
44
- ...
45
- rails g flexi_scaffold Post title:string body:text
46
- </pre>
47
-
48
- h2. Screenshots
49
-
50
- !http://img697.imageshack.us/img697/1245/flexigenerators.jpg(Flexi)!
51
-
52
- h2. TODO
53
-
54
- * i18n
55
- * Tests, tests, tests
56
-
57
- h2. Autor
58
-
59
- *Leandro de Oliveira*
60
-
61
- Blog: "http://leandroo.com.br":http://leandroo.com.br
62
- Github: "http://github.com/leandroo":http://github.com/leandroo
63
-
64
- Copyright (c) 2009 Leandro de Oliveira, released under the MIT license
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.10
@@ -1,16 +0,0 @@
1
- require 'rails/generators/base'
2
-
3
- module Flexi
4
- module Generators
5
- class Base < Rails::Generators::Base #:nodoc:
6
- def self.source_root
7
- @_flexi_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'flexi', generator_name, 'templates'))
8
- end
9
-
10
- def self.banner
11
- "#{$0} flexi:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
12
- end
13
- end
14
- end
15
- end
16
-
@@ -1,5 +0,0 @@
1
- Description:
2
- The flexi:auth generator creates a custom authentication with Authlogic gem and users CRUD.
3
-
4
- Example:
5
- rails generate flexi:auth
@@ -1,122 +0,0 @@
1
- require 'generators/flexi'
2
- require 'rails/generators/migration'
3
-
4
- module Flexi
5
- module Generators
6
- class AuthGenerator < Base
7
- include Rails::Generators::Migration
8
-
9
- argument :user_name, :type => :string, :default => 'user', :banner => 'user_name'
10
- argument :session_name, :type => :string, :default => "user_session", :banner => 'sessions_controller_name'
11
-
12
- def generate_auth
13
- gem 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git'
14
- end
15
-
16
- def create_model_files
17
- template 'user.rb', "app/models/#{user_singular_name}.rb"
18
- template 'authlogic_session.rb', "app/models/#{user_singular_name}_session.rb"
19
- end
20
-
21
- def create_controller_files
22
- template 'users_controller.rb', "app/controllers/admin/#{user_plural_name}_controller.rb"
23
- template 'sessions_controller.rb', "app/controllers/#{session_plural_name}_controller.rb"
24
- end
25
-
26
- def create_helper_files
27
- template 'users_helper.rb', "app/helpers/#{user_plural_name}_helper.rb"
28
- template 'sessions_helper.rb', "app/helpers/#{session_plural_name}_helper.rb"
29
- end
30
-
31
- def create_view_files
32
- template "views/erb/login.html.erb", "app/views/#{session_plural_name}/new.html.erb"
33
- template "views/erb/index.html.erb", "app/views/admin/#{user_plural_name}/index.html.erb"
34
- template "views/erb/show.html.erb", "app/views/admin/#{user_plural_name}/show.html.erb"
35
- template "views/erb/new.html.erb", "app/views/admin/#{user_plural_name}/new.html.erb"
36
- template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
37
- template "views/erb/edit.html.erb", "app/views/admin/#{user_plural_name}/edit.html.erb"
38
- template "views/erb/application.html.erb", "app/views/layouts/application.html.erb"
39
- template "views/erb/_menu.html.erb", "app/views/layouts/_menu.html.erb"
40
- end
41
-
42
- def create_lib_files
43
- template 'authentication.rb', 'config/initializers/authentication.rb'
44
- end
45
-
46
- def create_routes
47
- route "match 'admin' => '#{session_plural_name}#new'"
48
- route "match 'login' => '#{session_plural_name}#new', :as => :login"
49
- route "match 'logout' => '#{session_plural_name}#destroy', :as => :logout"
50
- route "resources #{session_plural_name.to_sym.inspect}"
51
- inject_into_file "config/routes.rb", "\n\tresources #{user_plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
52
- end
53
-
54
- def create_include_line
55
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " before_filter :login_required\n"
56
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
57
- end
58
-
59
- def create_test_files
60
- template 'fixtures.yml', "test/fixtures/#{user_plural_name}.yml"
61
- template "tests/testunit/user.rb", "test/unit/#{user_singular_name}_test.rb"
62
- template "tests/testunit/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
63
- template "tests/testunit/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
64
- end
65
-
66
- def create_migration
67
- migration_template 'migration.rb', "db/migrate/create_#{user_plural_name}.rb"
68
- end
69
-
70
- def create_seed
71
- append_file "db/seeds.rb","#{user_class_name}.create(:username => 'admin', :password => 'admin123', :password_confirmation => 'admin123', :email => 'admin@example.com')"
72
- end
73
-
74
- private
75
-
76
- def session_name
77
- user_name + '_session'
78
- end
79
-
80
- def user_singular_name
81
- user_name.underscore
82
- end
83
-
84
- def user_plural_name
85
- user_singular_name.pluralize
86
- end
87
-
88
- def user_class_name
89
- user_name.camelize
90
- end
91
-
92
- def user_plural_class_name
93
- user_plural_name.camelize
94
- end
95
-
96
- def session_singular_name
97
- session_name.underscore
98
- end
99
-
100
- def session_plural_name
101
- session_singular_name.pluralize
102
- end
103
-
104
- def session_class_name
105
- session_name.camelize
106
- end
107
-
108
- def session_plural_class_name
109
- session_plural_name.camelize
110
- end
111
-
112
- def self.next_migration_number(dirname) #:nodoc:
113
- if ActiveRecord::Base.timestamped_migrations
114
- Time.now.utc.strftime("%Y%m%d%H%M%S")
115
- else
116
- "%.3d" % (current_migration_number(dirname) + 1)
117
- end
118
- end
119
-
120
- end
121
- end
122
- end
@@ -1,55 +0,0 @@
1
- # encoding: utf-8
2
- # This module is included in your application controller which makes
3
- # several methods available to all controllers and views. Here's a
4
- # common example you might add to your application layout file.
5
- #
6
- # <%% if logged_in? %>
7
- # Welcome <%%= current_<%= user_singular_name %>.username %>! Not you?
8
- # <%%= link_to "Log out", logout_path %>
9
- # <%% else %>
10
- # <%%= link_to "Sign up", signup_path %> or
11
- # <%%= link_to "log in", login_path %>.
12
- # <%% end %>
13
- #
14
- # You can also restrict unregistered users from accessing a controller using
15
- # a before filter. For example.
16
- #
17
- # before_filter :login_required, :except => [:index, :show]
18
- module Authentication
19
- def self.included(controller)
20
- controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?, :redirect_to_target_or_default
21
- end
22
-
23
- def current_<%= session_singular_name %>
24
- return @current_<%= session_singular_name %> if defined?(@current_<%= session_singular_name %>)
25
- @current_<%= session_singular_name %> = <%= session_class_name %>.find
26
- end
27
-
28
- def current_<%= user_singular_name %>
29
- return @current_<%= user_singular_name %> if defined?(@current_<%= user_singular_name %>)
30
- @current_<%= user_singular_name %> = current_<%= session_singular_name %> && current_<%= session_singular_name %>.record
31
- end
32
-
33
- def logged_in?
34
- current_<%= user_singular_name %>
35
- end
36
-
37
- def login_required
38
- unless logged_in?
39
- flash[:error] = "Você precisa estar logado para poder acessar esta página."
40
- store_target_location
41
- redirect_to login_url
42
- end
43
- end
44
-
45
- def redirect_to_target_or_default(default)
46
- redirect_to(session[:return_to] || default)
47
- session[:return_to] = nil
48
- end
49
-
50
- private
51
-
52
- def store_target_location
53
- session[:return_to] = request.request_uri
54
- end
55
- end
@@ -1,2 +0,0 @@
1
- class <%= session_class_name %> < Authlogic::Session::Base
2
- end