flexi_generators 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. data/README.textile +71 -0
  2. data/Rakefile +38 -0
  3. data/VERSION +1 -0
  4. data/flexi_generators.gemspec +176 -0
  5. data/flexi_template.rb +28 -0
  6. data/generators/flexi_authentication/USAGE +50 -0
  7. data/generators/flexi_authentication/flexi_authentication_generator.rb +127 -0
  8. data/generators/flexi_authentication/lib/insert_commands.rb +74 -0
  9. data/generators/flexi_authentication/templates/admin_users_controller.rb +60 -0
  10. data/generators/flexi_authentication/templates/authentication.rb +61 -0
  11. data/generators/flexi_authentication/templates/authlogic_session.rb +2 -0
  12. data/generators/flexi_authentication/templates/fixtures.yml +24 -0
  13. data/generators/flexi_authentication/templates/migration.rb +30 -0
  14. data/generators/flexi_authentication/templates/sessions_controller.rb +52 -0
  15. data/generators/flexi_authentication/templates/sessions_helper.rb +2 -0
  16. data/generators/flexi_authentication/templates/tests/rspec/sessions_controller.rb +39 -0
  17. data/generators/flexi_authentication/templates/tests/rspec/user.rb +83 -0
  18. data/generators/flexi_authentication/templates/tests/rspec/users_controller.rb +26 -0
  19. data/generators/flexi_authentication/templates/tests/shoulda/sessions_controller.rb +40 -0
  20. data/generators/flexi_authentication/templates/tests/shoulda/user.rb +85 -0
  21. data/generators/flexi_authentication/templates/tests/shoulda/users_controller.rb +27 -0
  22. data/generators/flexi_authentication/templates/tests/testunit/sessions_controller.rb +36 -0
  23. data/generators/flexi_authentication/templates/tests/testunit/user.rb +88 -0
  24. data/generators/flexi_authentication/templates/tests/testunit/users_controller.rb +23 -0
  25. data/generators/flexi_authentication/templates/user.rb +43 -0
  26. data/generators/flexi_authentication/templates/users_helper.rb +2 -0
  27. data/generators/flexi_authentication/templates/views/erb/admin_user_edit.html.erb +23 -0
  28. data/generators/flexi_authentication/templates/views/erb/admin_user_index.html.erb +33 -0
  29. data/generators/flexi_authentication/templates/views/erb/admin_user_new.html.erb +23 -0
  30. data/generators/flexi_authentication/templates/views/erb/login.html.erb +38 -0
  31. data/generators/flexi_layout/USAGE +18 -0
  32. data/generators/flexi_layout/flexi_layout_generator.rb +51 -0
  33. data/generators/flexi_layout/lib/insert_commands.rb +28 -0
  34. data/generators/flexi_layout/templates/add.png +0 -0
  35. data/generators/flexi_layout/templates/admin_home_controller.rb +6 -0
  36. data/generators/flexi_layout/templates/admin_home_index.html.erb +16 -0
  37. data/generators/flexi_layout/templates/bg.png +0 -0
  38. data/generators/flexi_layout/templates/custom_field_error.rb +12 -0
  39. data/generators/flexi_layout/templates/helper.rb +19 -0
  40. data/generators/flexi_layout/templates/home_controller.rb +9 -0
  41. data/generators/flexi_layout/templates/home_helper.rb +2 -0
  42. data/generators/flexi_layout/templates/home_index.html.erb +17 -0
  43. data/generators/flexi_layout/templates/inflector_portuguese.rb +62 -0
  44. data/generators/flexi_layout/templates/layout.html.erb +47 -0
  45. data/generators/flexi_layout/templates/layout_login.html.erb +27 -0
  46. data/generators/flexi_layout/templates/layout_site.html.erb +22 -0
  47. data/generators/flexi_layout/templates/logo.png +0 -0
  48. data/generators/flexi_layout/templates/pt-BR.yml +143 -0
  49. data/generators/flexi_layout/templates/stylesheet.css +132 -0
  50. data/generators/flexi_layout/templates/stylesheet_login.css +73 -0
  51. data/generators/flexi_layout/templates/stylesheet_site.css +63 -0
  52. data/generators/flexi_layout/templates/users.png +0 -0
  53. data/generators/flexi_resource_scaffold/USAGE +29 -0
  54. data/generators/flexi_resource_scaffold/flexi_resource_scaffold_generator.rb +179 -0
  55. data/generators/flexi_resource_scaffold/templates/controller.rb +29 -0
  56. data/generators/flexi_resource_scaffold/templates/fixtures.yml +10 -0
  57. data/generators/flexi_resource_scaffold/templates/functional_test.rb +57 -0
  58. data/generators/flexi_resource_scaffold/templates/helper.rb +2 -0
  59. data/generators/flexi_resource_scaffold/templates/migration.rb +15 -0
  60. data/generators/flexi_resource_scaffold/templates/model.rb +2 -0
  61. data/generators/flexi_resource_scaffold/templates/old_migration.rb +13 -0
  62. data/generators/flexi_resource_scaffold/templates/rspec/functional_spec.rb +255 -0
  63. data/generators/flexi_resource_scaffold/templates/rspec/helper_spec.rb +11 -0
  64. data/generators/flexi_resource_scaffold/templates/rspec/routing_spec.rb +61 -0
  65. data/generators/flexi_resource_scaffold/templates/rspec/unit_spec.rb +11 -0
  66. data/generators/flexi_resource_scaffold/templates/rspec/views/edit_spec.rb +28 -0
  67. data/generators/flexi_resource_scaffold/templates/rspec/views/index_spec.rb +26 -0
  68. data/generators/flexi_resource_scaffold/templates/rspec/views/new_spec.rb +30 -0
  69. data/generators/flexi_resource_scaffold/templates/rspec/views/show_spec.rb +25 -0
  70. data/generators/flexi_resource_scaffold/templates/shoulda_functional_test.rb +19 -0
  71. data/generators/flexi_resource_scaffold/templates/unit_test.rb +7 -0
  72. data/generators/flexi_resource_scaffold/templates/view__form.erb +6 -0
  73. data/generators/flexi_resource_scaffold/templates/view__form.haml +5 -0
  74. data/generators/flexi_resource_scaffold/templates/view_edit.erb +8 -0
  75. data/generators/flexi_resource_scaffold/templates/view_edit.haml +11 -0
  76. data/generators/flexi_resource_scaffold/templates/view_index.erb +27 -0
  77. data/generators/flexi_resource_scaffold/templates/view_index.haml +19 -0
  78. data/generators/flexi_resource_scaffold/templates/view_new.erb +9 -0
  79. data/generators/flexi_resource_scaffold/templates/view_new.haml +9 -0
  80. data/generators/flexi_resource_scaffold/templates/view_show.erb +10 -0
  81. data/generators/flexi_resource_scaffold/templates/view_show.haml +9 -0
  82. data/generators/flexi_scaffold/USAGE +51 -0
  83. data/generators/flexi_scaffold/flexi_scaffold_generator.rb +232 -0
  84. data/generators/flexi_scaffold/templates/actions/create.rb +9 -0
  85. data/generators/flexi_scaffold/templates/actions/destroy.rb +6 -0
  86. data/generators/flexi_scaffold/templates/actions/edit.rb +3 -0
  87. data/generators/flexi_scaffold/templates/actions/index.rb +4 -0
  88. data/generators/flexi_scaffold/templates/actions/new.rb +3 -0
  89. data/generators/flexi_scaffold/templates/actions/show.rb +3 -0
  90. data/generators/flexi_scaffold/templates/actions/update.rb +9 -0
  91. data/generators/flexi_scaffold/templates/controller.rb +5 -0
  92. data/generators/flexi_scaffold/templates/fixtures.yml +9 -0
  93. data/generators/flexi_scaffold/templates/helper.rb +2 -0
  94. data/generators/flexi_scaffold/templates/migration.rb +16 -0
  95. data/generators/flexi_scaffold/templates/model.rb +3 -0
  96. data/generators/flexi_scaffold/templates/tests/rspec/actions/create.rb +11 -0
  97. data/generators/flexi_scaffold/templates/tests/rspec/actions/destroy.rb +6 -0
  98. data/generators/flexi_scaffold/templates/tests/rspec/actions/edit.rb +4 -0
  99. data/generators/flexi_scaffold/templates/tests/rspec/actions/index.rb +4 -0
  100. data/generators/flexi_scaffold/templates/tests/rspec/actions/new.rb +4 -0
  101. data/generators/flexi_scaffold/templates/tests/rspec/actions/show.rb +4 -0
  102. data/generators/flexi_scaffold/templates/tests/rspec/actions/update.rb +11 -0
  103. data/generators/flexi_scaffold/templates/tests/rspec/controller.rb +8 -0
  104. data/generators/flexi_scaffold/templates/tests/rspec/model.rb +7 -0
  105. data/generators/flexi_scaffold/templates/tests/shoulda/actions/create.rb +13 -0
  106. data/generators/flexi_scaffold/templates/tests/shoulda/actions/destroy.rb +8 -0
  107. data/generators/flexi_scaffold/templates/tests/shoulda/actions/edit.rb +6 -0
  108. data/generators/flexi_scaffold/templates/tests/shoulda/actions/index.rb +6 -0
  109. data/generators/flexi_scaffold/templates/tests/shoulda/actions/new.rb +6 -0
  110. data/generators/flexi_scaffold/templates/tests/shoulda/actions/show.rb +6 -0
  111. data/generators/flexi_scaffold/templates/tests/shoulda/actions/update.rb +13 -0
  112. data/generators/flexi_scaffold/templates/tests/shoulda/controller.rb +5 -0
  113. data/generators/flexi_scaffold/templates/tests/shoulda/model.rb +7 -0
  114. data/generators/flexi_scaffold/templates/tests/testunit/actions/create.rb +11 -0
  115. data/generators/flexi_scaffold/templates/tests/testunit/actions/destroy.rb +6 -0
  116. data/generators/flexi_scaffold/templates/tests/testunit/actions/edit.rb +4 -0
  117. data/generators/flexi_scaffold/templates/tests/testunit/actions/index.rb +4 -0
  118. data/generators/flexi_scaffold/templates/tests/testunit/actions/new.rb +4 -0
  119. data/generators/flexi_scaffold/templates/tests/testunit/actions/show.rb +4 -0
  120. data/generators/flexi_scaffold/templates/tests/testunit/actions/update.rb +11 -0
  121. data/generators/flexi_scaffold/templates/tests/testunit/controller.rb +5 -0
  122. data/generators/flexi_scaffold/templates/tests/testunit/model.rb +7 -0
  123. data/generators/flexi_scaffold/templates/views/erb/_form.html.erb +6 -0
  124. data/generators/flexi_scaffold/templates/views/erb/edit.html.erb +8 -0
  125. data/generators/flexi_scaffold/templates/views/erb/index.html.erb +41 -0
  126. data/generators/flexi_scaffold/templates/views/erb/new.html.erb +10 -0
  127. data/generators/flexi_scaffold/templates/views/erb/show.html.erb +19 -0
  128. data/generators/flexi_scaffold/templates/views/haml/_form.html.haml +10 -0
  129. data/generators/flexi_scaffold/templates/views/haml/edit.html.haml +14 -0
  130. data/generators/flexi_scaffold/templates/views/haml/index.html.haml +25 -0
  131. data/generators/flexi_scaffold/templates/views/haml/new.html.haml +7 -0
  132. data/generators/flexi_scaffold/templates/views/haml/show.html.haml +20 -0
  133. data/init.rb +2 -0
  134. data/lib/flexi_generators.rb +4 -0
  135. data/test/flexi_generators_test.rb +8 -0
  136. data/test/test_helper.rb +3 -0
  137. metadata +203 -0
data/README.textile ADDED
@@ -0,0 +1,71 @@
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 Tab Helper plugin
8
+ * Controllers and views generated with Resource Controller plugin
9
+
10
+ h2. Included Generators
11
+
12
+ * flexi_authentication: generates user model with sign up and log in.
13
+ * flexi_layout: generates generic layout, stylesheet, and helper files.
14
+ * flexi_scaffold: generates a controller and optional model/migration.
15
+ * flexi_resource_scaffold: generates a controller and optional model/migration (resource_controller plugin).
16
+
17
+ h2. Quickstart
18
+
19
+ These 4 simple steps are the essentials to get you smoothly up and running…
20
+
21
+ 1. Create your app and configure all dependencies
22
+ @rails appname -m http://github.com/leandroo/flexi_generators/raw/master/flexi_template.rb@
23
+ 2. Run @rake gems:install@ and @rake db:migrate@ to create your database and installs all required gems
24
+ 3. Start your server with @ruby script/server@
25
+ 4. Open up "http://localhost:3000":http://localhost:3000
26
+
27
+ h2. Dependencies
28
+
29
+ * Tabs Helper plugin: http://github.com/danielvlopes/tabs_helper
30
+ * Resource Controller plugin: http://github.com/giraffesoft/resource_controller
31
+ * Will Paginate plugin/gem: http://github.com/mislav/will_paginate
32
+ * Rails Footnotes plugin: http://github.com/josevalim/rails-footnotes
33
+ * JRails plugin: http://github.com/aaronchi/jrails
34
+
35
+ h2. Usage
36
+
37
+ <pre>
38
+ ruby script/generate flexi_layout
39
+ ...
40
+ ruby script/generate flexi_authentication
41
+ ...
42
+ ruby script/generate flexi_scaffold Post title:string body:text
43
+ or
44
+ ruby script/generate flexi_resource_scaffold Post title:string body:text
45
+ </pre>
46
+
47
+ h2. Screenshots
48
+
49
+ !http://img687.imageshack.us/img687/3579/homemk.png(Home layout)!
50
+
51
+ !http://img441.imageshack.us/img441/5562/autenticacao.png(Login layout)!
52
+
53
+ !http://img337.imageshack.us/img337/5549/adminkf.png(Admin layout)!
54
+
55
+ !http://img155.imageshack.us/img155/6107/newb.png(Scaffold New)!
56
+
57
+ !http://img219.imageshack.us/img219/2945/listc.png(Scaffold List)!
58
+
59
+ h2. TODO
60
+
61
+ * Support i18n
62
+ * Tests, tests, tests
63
+
64
+ h2. Autor
65
+
66
+ *Leandro de Oliveira*
67
+
68
+ Blog: "http://leandroo.com.br":http://leandroo.com.br
69
+ Github: "http://github.com/leandroo":http://github.com/leandroo
70
+
71
+ Copyright (c) 2009 Leandro de Oliveira, released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the flexi_generators plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the flexi_generators plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'Flexi-generators'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ begin
26
+ require 'jeweler'
27
+ Jeweler::Tasks.new do |gemspec|
28
+ gemspec.name = "flexi_generators"
29
+ gemspec.summary = "My useful Rails generator scripts."
30
+ gemspec.description = "Generates authentication and custom scaffold templates."
31
+ gemspec.email = "ol.leandro@gmail.com"
32
+ gemspec.homepage = "http://github.com/leandroo/flexi_generators"
33
+ gemspec.authors = ["Leandro de Oliveira"]
34
+ end
35
+ Jeweler::GemcutterTasks.new
36
+ rescue LoadError
37
+ puts "Jeweler not available. Install it with: gem install jeweler"
38
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,176 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{flexi_generators}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Leandro de Oliveira"]
12
+ s.date = %q{2010-09-09}
13
+ s.description = %q{Generates authentication and custom scaffold templates.}
14
+ s.email = %q{ol.leandro@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ "README.textile",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "flexi_generators.gemspec",
23
+ "flexi_template.rb",
24
+ "generators/flexi_authentication/USAGE",
25
+ "generators/flexi_authentication/flexi_authentication_generator.rb",
26
+ "generators/flexi_authentication/lib/insert_commands.rb",
27
+ "generators/flexi_authentication/templates/admin_users_controller.rb",
28
+ "generators/flexi_authentication/templates/authentication.rb",
29
+ "generators/flexi_authentication/templates/authlogic_session.rb",
30
+ "generators/flexi_authentication/templates/fixtures.yml",
31
+ "generators/flexi_authentication/templates/migration.rb",
32
+ "generators/flexi_authentication/templates/sessions_controller.rb",
33
+ "generators/flexi_authentication/templates/sessions_helper.rb",
34
+ "generators/flexi_authentication/templates/tests/rspec/sessions_controller.rb",
35
+ "generators/flexi_authentication/templates/tests/rspec/user.rb",
36
+ "generators/flexi_authentication/templates/tests/rspec/users_controller.rb",
37
+ "generators/flexi_authentication/templates/tests/shoulda/sessions_controller.rb",
38
+ "generators/flexi_authentication/templates/tests/shoulda/user.rb",
39
+ "generators/flexi_authentication/templates/tests/shoulda/users_controller.rb",
40
+ "generators/flexi_authentication/templates/tests/testunit/sessions_controller.rb",
41
+ "generators/flexi_authentication/templates/tests/testunit/user.rb",
42
+ "generators/flexi_authentication/templates/tests/testunit/users_controller.rb",
43
+ "generators/flexi_authentication/templates/user.rb",
44
+ "generators/flexi_authentication/templates/users_helper.rb",
45
+ "generators/flexi_authentication/templates/views/erb/admin_user_edit.html.erb",
46
+ "generators/flexi_authentication/templates/views/erb/admin_user_index.html.erb",
47
+ "generators/flexi_authentication/templates/views/erb/admin_user_new.html.erb",
48
+ "generators/flexi_authentication/templates/views/erb/login.html.erb",
49
+ "generators/flexi_layout/USAGE",
50
+ "generators/flexi_layout/flexi_layout_generator.rb",
51
+ "generators/flexi_layout/lib/insert_commands.rb",
52
+ "generators/flexi_layout/templates/add.png",
53
+ "generators/flexi_layout/templates/admin_home_controller.rb",
54
+ "generators/flexi_layout/templates/admin_home_index.html.erb",
55
+ "generators/flexi_layout/templates/bg.png",
56
+ "generators/flexi_layout/templates/custom_field_error.rb",
57
+ "generators/flexi_layout/templates/helper.rb",
58
+ "generators/flexi_layout/templates/home_controller.rb",
59
+ "generators/flexi_layout/templates/home_helper.rb",
60
+ "generators/flexi_layout/templates/home_index.html.erb",
61
+ "generators/flexi_layout/templates/inflector_portuguese.rb",
62
+ "generators/flexi_layout/templates/layout.html.erb",
63
+ "generators/flexi_layout/templates/layout_login.html.erb",
64
+ "generators/flexi_layout/templates/layout_site.html.erb",
65
+ "generators/flexi_layout/templates/logo.png",
66
+ "generators/flexi_layout/templates/pt-BR.yml",
67
+ "generators/flexi_layout/templates/stylesheet.css",
68
+ "generators/flexi_layout/templates/stylesheet_login.css",
69
+ "generators/flexi_layout/templates/stylesheet_site.css",
70
+ "generators/flexi_layout/templates/users.png",
71
+ "generators/flexi_resource_scaffold/USAGE",
72
+ "generators/flexi_resource_scaffold/flexi_resource_scaffold_generator.rb",
73
+ "generators/flexi_resource_scaffold/templates/controller.rb",
74
+ "generators/flexi_resource_scaffold/templates/fixtures.yml",
75
+ "generators/flexi_resource_scaffold/templates/functional_test.rb",
76
+ "generators/flexi_resource_scaffold/templates/helper.rb",
77
+ "generators/flexi_resource_scaffold/templates/migration.rb",
78
+ "generators/flexi_resource_scaffold/templates/model.rb",
79
+ "generators/flexi_resource_scaffold/templates/old_migration.rb",
80
+ "generators/flexi_resource_scaffold/templates/rspec/functional_spec.rb",
81
+ "generators/flexi_resource_scaffold/templates/rspec/helper_spec.rb",
82
+ "generators/flexi_resource_scaffold/templates/rspec/routing_spec.rb",
83
+ "generators/flexi_resource_scaffold/templates/rspec/unit_spec.rb",
84
+ "generators/flexi_resource_scaffold/templates/rspec/views/edit_spec.rb",
85
+ "generators/flexi_resource_scaffold/templates/rspec/views/index_spec.rb",
86
+ "generators/flexi_resource_scaffold/templates/rspec/views/new_spec.rb",
87
+ "generators/flexi_resource_scaffold/templates/rspec/views/show_spec.rb",
88
+ "generators/flexi_resource_scaffold/templates/shoulda_functional_test.rb",
89
+ "generators/flexi_resource_scaffold/templates/unit_test.rb",
90
+ "generators/flexi_resource_scaffold/templates/view__form.erb",
91
+ "generators/flexi_resource_scaffold/templates/view__form.haml",
92
+ "generators/flexi_resource_scaffold/templates/view_edit.erb",
93
+ "generators/flexi_resource_scaffold/templates/view_edit.haml",
94
+ "generators/flexi_resource_scaffold/templates/view_index.erb",
95
+ "generators/flexi_resource_scaffold/templates/view_index.haml",
96
+ "generators/flexi_resource_scaffold/templates/view_new.erb",
97
+ "generators/flexi_resource_scaffold/templates/view_new.haml",
98
+ "generators/flexi_resource_scaffold/templates/view_show.erb",
99
+ "generators/flexi_resource_scaffold/templates/view_show.haml",
100
+ "generators/flexi_scaffold/USAGE",
101
+ "generators/flexi_scaffold/flexi_scaffold_generator.rb",
102
+ "generators/flexi_scaffold/templates/actions/create.rb",
103
+ "generators/flexi_scaffold/templates/actions/destroy.rb",
104
+ "generators/flexi_scaffold/templates/actions/edit.rb",
105
+ "generators/flexi_scaffold/templates/actions/index.rb",
106
+ "generators/flexi_scaffold/templates/actions/new.rb",
107
+ "generators/flexi_scaffold/templates/actions/show.rb",
108
+ "generators/flexi_scaffold/templates/actions/update.rb",
109
+ "generators/flexi_scaffold/templates/controller.rb",
110
+ "generators/flexi_scaffold/templates/fixtures.yml",
111
+ "generators/flexi_scaffold/templates/helper.rb",
112
+ "generators/flexi_scaffold/templates/migration.rb",
113
+ "generators/flexi_scaffold/templates/model.rb",
114
+ "generators/flexi_scaffold/templates/tests/rspec/actions/create.rb",
115
+ "generators/flexi_scaffold/templates/tests/rspec/actions/destroy.rb",
116
+ "generators/flexi_scaffold/templates/tests/rspec/actions/edit.rb",
117
+ "generators/flexi_scaffold/templates/tests/rspec/actions/index.rb",
118
+ "generators/flexi_scaffold/templates/tests/rspec/actions/new.rb",
119
+ "generators/flexi_scaffold/templates/tests/rspec/actions/show.rb",
120
+ "generators/flexi_scaffold/templates/tests/rspec/actions/update.rb",
121
+ "generators/flexi_scaffold/templates/tests/rspec/controller.rb",
122
+ "generators/flexi_scaffold/templates/tests/rspec/model.rb",
123
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/create.rb",
124
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/destroy.rb",
125
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/edit.rb",
126
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/index.rb",
127
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/new.rb",
128
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/show.rb",
129
+ "generators/flexi_scaffold/templates/tests/shoulda/actions/update.rb",
130
+ "generators/flexi_scaffold/templates/tests/shoulda/controller.rb",
131
+ "generators/flexi_scaffold/templates/tests/shoulda/model.rb",
132
+ "generators/flexi_scaffold/templates/tests/testunit/actions/create.rb",
133
+ "generators/flexi_scaffold/templates/tests/testunit/actions/destroy.rb",
134
+ "generators/flexi_scaffold/templates/tests/testunit/actions/edit.rb",
135
+ "generators/flexi_scaffold/templates/tests/testunit/actions/index.rb",
136
+ "generators/flexi_scaffold/templates/tests/testunit/actions/new.rb",
137
+ "generators/flexi_scaffold/templates/tests/testunit/actions/show.rb",
138
+ "generators/flexi_scaffold/templates/tests/testunit/actions/update.rb",
139
+ "generators/flexi_scaffold/templates/tests/testunit/controller.rb",
140
+ "generators/flexi_scaffold/templates/tests/testunit/model.rb",
141
+ "generators/flexi_scaffold/templates/views/erb/_form.html.erb",
142
+ "generators/flexi_scaffold/templates/views/erb/edit.html.erb",
143
+ "generators/flexi_scaffold/templates/views/erb/index.html.erb",
144
+ "generators/flexi_scaffold/templates/views/erb/new.html.erb",
145
+ "generators/flexi_scaffold/templates/views/erb/show.html.erb",
146
+ "generators/flexi_scaffold/templates/views/haml/_form.html.haml",
147
+ "generators/flexi_scaffold/templates/views/haml/edit.html.haml",
148
+ "generators/flexi_scaffold/templates/views/haml/index.html.haml",
149
+ "generators/flexi_scaffold/templates/views/haml/new.html.haml",
150
+ "generators/flexi_scaffold/templates/views/haml/show.html.haml",
151
+ "init.rb",
152
+ "lib/flexi_generators.rb",
153
+ "test/flexi_generators_test.rb",
154
+ "test/test_helper.rb"
155
+ ]
156
+ s.homepage = %q{http://github.com/leandroo/flexi_generators}
157
+ s.rdoc_options = ["--charset=UTF-8"]
158
+ s.require_paths = ["lib"]
159
+ s.rubygems_version = %q{1.3.7}
160
+ s.summary = %q{My useful Rails generator scripts.}
161
+ s.test_files = [
162
+ "test/flexi_generators_test.rb",
163
+ "test/test_helper.rb"
164
+ ]
165
+
166
+ if s.respond_to? :specification_version then
167
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
168
+ s.specification_version = 3
169
+
170
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
171
+ else
172
+ end
173
+ else
174
+ end
175
+ end
176
+
data/flexi_template.rb ADDED
@@ -0,0 +1,28 @@
1
+ # commands
2
+ run "rm public/index.html"
3
+ run "rm README"
4
+ run "rm doc/README_FOR_APP"
5
+
6
+ # plugins
7
+ plugin "tabs_helper", :git => "git://github.com/leandroo/tabs_helper.git"
8
+ plugin "resource_controller", :git => "git://github.com/jamesgolick/resource_controller.git"
9
+ plugin "jrails", :git => "git://github.com/aaronchi/jrails.git"
10
+ plugin "rails-footnotes", :git => "git://github.com/josevalim/rails-footnotes.git"
11
+ plugin "flexi_generators", :git => "git://github.com/leandroo/flexi_generators.git"
12
+
13
+ # gems
14
+ gem 'will_paginate', :version=> '2.3.11', :source => 'http://gemcutter.org'
15
+
16
+ # locales
17
+ environment %(config.i18n.default_locale = "pt-BR")
18
+
19
+ # generators
20
+ generate :flexi_layout
21
+ generate :flexi_authentication
22
+
23
+ # tasks
24
+ #rake 'gems:install', :sudo => true
25
+ #rake 'gems:unpack', :sudo => true
26
+ #rake 'jrails:js:scrub'
27
+ #rake 'jrails:js:install'
28
+ #rake 'db:migrate'
@@ -0,0 +1,50 @@
1
+ Description:
2
+ Generates a user model, users controller, and sessions controller. The
3
+ users controller handles the registration and the sessions controller
4
+ handles authentication. This is similar to restful_authentication, but
5
+ simpler.
6
+
7
+ IMPORTANT: This generator uses the "title" helper method which is generated
8
+ by the flexi_layout generator. You may want to run that generator first.
9
+
10
+ Usage:
11
+ If you do not pass any arguments, the model name will default to "user", and
12
+ the authentication controller will default to "session". You can override
13
+ each of these respectively by passing one or two arguments. Either name can
14
+ be CamelCased or under_scored.
15
+
16
+ Make sure to setup the authlogic gem if you are using that option.
17
+
18
+ config.gem "authlogic"
19
+
20
+ Examples:
21
+ script/generate flexi_authentication
22
+
23
+ Creates user model, users_controller, and sessions_controller.
24
+
25
+ script/generate flexi_authentication account
26
+
27
+ Creates account model, accounts_controller, and sessions_controller.
28
+
29
+ script/generate flexi_authentication Account UserSession
30
+
31
+ Creates account model, accounts_controller, and user_sessions_controller.
32
+
33
+ Methods:
34
+ There are several methods generated which you can use in your application.
35
+ Here's a common example of what you might add to your layout.
36
+
37
+ <% if logged_in? %>
38
+ Welcome <%= current_user.username %>! Not you?
39
+ <%= link_to "Log out", logout_path %>
40
+ <% else %>
41
+ <%= link_to "Sign up", signup_path %> or
42
+ <%= link_to "log in", login_path %>.
43
+ <% end %>
44
+
45
+ You can also restrict unregistered users from accessing a controller using
46
+ a before filter. For example.
47
+
48
+ before_filter :login_required, :except => [:index, :show]
49
+
50
+ See the generated file lib/authentication.rb for details.
@@ -0,0 +1,127 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
+ class FlexiAuthenticationGenerator < Rails::Generator::Base
3
+ attr_accessor :user_name, :session_name
4
+
5
+ def initialize(runtime_args, runtime_options = {})
6
+ super
7
+
8
+ #@user_name = @args[0] || 'user'
9
+ @user_name = 'user'
10
+ @session_name = @args[1] || (options[:authlogic] ? @user_name + '_session' : 'session')
11
+ end
12
+
13
+ def manifest
14
+ record do |m|
15
+ m.directory "app/models"
16
+ m.directory "app/controllers"
17
+ m.directory "app/controllers/admin"
18
+ m.directory "app/helpers"
19
+ m.directory "app/views"
20
+ m.directory "app/views/admin"
21
+ m.directory "lib"
22
+ m.directory "app/views/admin/#{user_plural_name}"
23
+ m.template "user.rb", "app/models/#{user_singular_name}.rb"
24
+ m.template "authlogic_session.rb", "app/models/#{user_singular_name}_session.rb" if options[:authlogic]
25
+ m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
26
+ #admin_user
27
+ m.template "admin_users_controller.rb", "app/controllers/admin/#{user_plural_name}_controller.rb"
28
+ m.template "views/erb/admin_user_index.html.erb", "app/views/admin/#{user_plural_name}/index.html.erb"
29
+ m.template "views/erb/admin_user_new.html.erb", "app/views/admin/#{user_plural_name}/new.html.erb"
30
+ m.template "views/erb/admin_user_edit.html.erb", "app/views/admin/#{user_plural_name}/edit.html.erb"
31
+
32
+ m.directory "app/views/#{session_plural_name}"
33
+ m.template "sessions_controller.rb", "app/controllers/#{session_plural_name}_controller.rb"
34
+ m.template "sessions_helper.rb", "app/helpers/#{session_plural_name}_helper.rb"
35
+ m.template "views/erb/login.html.erb", "app/views/#{session_plural_name}/new.html.erb"
36
+
37
+ m.template "authentication.rb", "lib/authentication.rb"
38
+ m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
39
+
40
+ m.route_resources session_plural_name
41
+ m.route_name :login, 'login', :controller => session_plural_name, :action => 'new'
42
+ m.route_name :logout, 'logout', :controller => session_plural_name, :action => 'destroy'
43
+
44
+ m.insert_into "app/controllers/#{application_controller_name}.rb", 'include Authentication'
45
+ m.insert_into "app/controllers/#{application_controller_name}.rb", 'before_filter :login_required'
46
+
47
+ if test_framework == :rspec
48
+ m.directory "spec"
49
+ m.directory "spec/fixtures"
50
+ m.directory "spec/controllers"
51
+ m.directory "spec/models"
52
+ m.template "fixtures.yml", "spec/fixtures/#{user_plural_name}.yml"
53
+ m.template "tests/rspec/user.rb", "spec/models/#{user_singular_name}_spec.rb"
54
+ m.template "tests/rspec/users_controller.rb", "spec/controllers/#{user_plural_name}_controller_spec.rb"
55
+ m.template "tests/rspec/sessions_controller.rb", "spec/controllers/#{session_plural_name}_controller_spec.rb"
56
+ else
57
+ m.directory "test"
58
+ m.directory "test/fixtures"
59
+ m.directory "test/functional"
60
+ m.directory "test/unit"
61
+ m.template "fixtures.yml", "test/fixtures/#{user_plural_name}.yml"
62
+ m.template "tests/#{test_framework}/user.rb", "test/unit/#{user_singular_name}_test.rb"
63
+ m.template "tests/#{test_framework}/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
64
+ m.template "tests/#{test_framework}/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
65
+ end
66
+ end
67
+ end
68
+
69
+ def user_singular_name
70
+ user_name.underscore
71
+ end
72
+
73
+ def user_plural_name
74
+ user_singular_name.pluralize
75
+ end
76
+
77
+ def user_class_name
78
+ user_name.camelize
79
+ end
80
+
81
+ def user_plural_class_name
82
+ user_plural_name.camelize
83
+ end
84
+
85
+ def session_singular_name
86
+ session_name.underscore
87
+ end
88
+
89
+ def session_plural_name
90
+ session_singular_name.pluralize
91
+ end
92
+
93
+ def session_class_name
94
+ session_name.camelize
95
+ end
96
+
97
+ def session_plural_class_name
98
+ session_plural_name.camelize
99
+ end
100
+
101
+ def application_controller_name
102
+ Rails.version >= '2.3.0' ? 'application_controller' : 'application'
103
+ end
104
+
105
+ protected
106
+
107
+ def test_framework
108
+ options[:test_framework] ||= File.exist?(destination_path("spec")) ? :rspec : :testunit
109
+ end
110
+
111
+ def add_options!(opt)
112
+ opt.separator ''
113
+ opt.separator 'Options:'
114
+ opt.on("--testunit", "Use test/unit for test files.") { options[:test_framework] = :testunit }
115
+ opt.on("--rspec", "Use RSpec for test files.") { options[:test_framework] = :rspec }
116
+ opt.on("--shoulda", "Use Shoulda for test files.") { options[:test_framework] = :shoulda }
117
+ #opt.on("--authlogic", "Use Authlogic for authentication.") { |v| options[:authlogic] = true }
118
+ end
119
+
120
+ def banner
121
+ <<-EOS
122
+ Creates user model and controllers to handle registration and authentication.
123
+
124
+ USAGE: #{$0} #{spec.name} [user_name] [sessions_controller_name]
125
+ EOS
126
+ end
127
+ end
@@ -0,0 +1,74 @@
1
+ Rails::Generator::Commands::Create.class_eval do
2
+ def route_resource(*resources)
3
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
4
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
5
+
6
+ logger.route "map.resource #{resource_list}"
7
+ unless options[:pretend]
8
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
9
+ "#{match}\n map.resource #{resource_list}\n"
10
+ end
11
+ end
12
+ end
13
+
14
+ def route_name(name, path, route_options = {})
15
+ sentinel = 'ActionController::Routing::Routes.draw do |map|'
16
+
17
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
18
+ unless options[:pretend]
19
+ gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
20
+ "#{match}\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
21
+ end
22
+ end
23
+ end
24
+
25
+ def insert_into(file, line)
26
+ logger.insert "#{line} into #{file}"
27
+ unless options[:pretend]
28
+ gsub_file file, /^(class|module) .+$/ do |match|
29
+ "#{match}\n #{line}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ Rails::Generator::Commands::Destroy.class_eval do
36
+ def route_resource(*resources)
37
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
38
+ look_for = "\n map.resource #{resource_list}\n"
39
+ logger.route "map.resource #{resource_list}"
40
+ unless options[:pretend]
41
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
42
+ end
43
+ end
44
+
45
+ def route_name(name, path, route_options = {})
46
+ look_for = "\n map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
47
+ logger.route "map.#{name} '#{path}', :controller => '#{route_options[:controller]}', :action => '#{route_options[:action]}'"
48
+ unless options[:pretend]
49
+ gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
50
+ end
51
+ end
52
+
53
+ def insert_into(file, line)
54
+ logger.remove "#{line} from #{file}"
55
+ unless options[:pretend]
56
+ gsub_file file, "\n #{line}", ''
57
+ end
58
+ end
59
+ end
60
+
61
+ Rails::Generator::Commands::List.class_eval do
62
+ def route_resource(*resources)
63
+ resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
64
+ logger.route "map.resource #{resource_list}"
65
+ end
66
+
67
+ def route_name(name, path, options = {})
68
+ logger.route "map.#{name} '#{path}', :controller => '{options[:controller]}', :action => '#{options[:action]}'"
69
+ end
70
+
71
+ def insert_into(file, line)
72
+ logger.insert "#{line} into #{file}"
73
+ end
74
+ end
@@ -0,0 +1,60 @@
1
+ class Admin::UsersController < ApplicationController
2
+ current_tab :users
3
+
4
+ def index
5
+ @users = User.paginate :page => params[:page], :per_page => 15
6
+
7
+ respond_to do |format|
8
+ format.html
9
+ end
10
+ end
11
+
12
+ def new
13
+ @user = User.new
14
+
15
+ respond_to do |format|
16
+ format.html
17
+ end
18
+ end
19
+
20
+ def edit
21
+ @user = User.find(params[:id])
22
+ end
23
+
24
+ def create
25
+ @user = User.new(params[:user])
26
+
27
+ respond_to do |format|
28
+ if @user.save
29
+ #session[:user_id] = @user.id
30
+ flash[:notice] = "Usuário adicionado com sucesso!"
31
+ format.html { redirect_to(admin_users_url) }
32
+ else
33
+ format.html { render :action => "new" }
34
+ end
35
+ end
36
+ end
37
+
38
+ def update
39
+ @user = User.find(params[:id])
40
+
41
+ respond_to do |format|
42
+ if @user.update_attributes(params[:user])
43
+ flash[:notice] = 'Usuário foi alterado com sucesso!'
44
+ format.html { redirect_to(admin_users_url) }
45
+ else
46
+ format.html { render :action => "edit" }
47
+ end
48
+ end
49
+ end
50
+
51
+ def destroy
52
+ @user = User.find(params[:id])
53
+ @user.destroy
54
+
55
+ respond_to do |format|
56
+ format.html { redirect_to(login_url) }
57
+ end
58
+ end
59
+
60
+ end