flexi_generators 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/README.textile +83 -70
  2. data/Rakefile +0 -22
  3. data/VERSION +1 -1
  4. data/flexi_generators.gemspec +75 -136
  5. data/init.rb +0 -1
  6. data/lib/flexi_generators.rb +2 -4
  7. data/lib/generators/flexi_auth/USAGE +5 -0
  8. data/lib/generators/flexi_auth/flexi_auth_generator.rb +117 -0
  9. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/authentication.rb +2 -9
  10. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/authlogic_session.rb +0 -0
  11. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/fixtures.yml +0 -0
  12. data/lib/generators/flexi_auth/templates/migration.rb +16 -0
  13. data/lib/generators/flexi_auth/templates/sessions_controller.rb +25 -0
  14. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/sessions_helper.rb +0 -0
  15. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/tests/testunit/sessions_controller.rb +1 -17
  16. data/lib/generators/flexi_auth/templates/tests/testunit/user.rb +4 -0
  17. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/tests/testunit/users_controller.rb +1 -1
  18. data/lib/generators/flexi_auth/templates/user.rb +3 -0
  19. data/lib/generators/flexi_auth/templates/users_controller.rb +42 -0
  20. data/{generators/flexi_authentication → lib/generators/flexi_auth}/templates/users_helper.rb +0 -0
  21. data/lib/generators/flexi_auth/templates/views/erb/_error_messages.html.erb +11 -0
  22. data/lib/generators/flexi_auth/templates/views/erb/edit.html.erb +24 -0
  23. data/lib/generators/flexi_auth/templates/views/erb/index.html.erb +27 -0
  24. data/lib/generators/flexi_auth/templates/views/erb/login.html.erb +22 -0
  25. data/lib/generators/flexi_auth/templates/views/erb/new.html.erb +24 -0
  26. data/lib/generators/flexi_auth/templates/views/erb/show.html.erb +16 -0
  27. data/lib/generators/flexi_prepare/USAGE +6 -0
  28. data/lib/generators/flexi_prepare/flexi_prepare_generator.rb +56 -0
  29. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/add.png +0 -0
  30. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/admin_home_controller.rb +0 -0
  31. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/admin_home_index.html.erb +1 -1
  32. data/lib/generators/flexi_prepare/templates/application.css +278 -0
  33. data/lib/generators/flexi_prepare/templates/application.html.erb +57 -0
  34. data/lib/generators/flexi_prepare/templates/application_helper.rb +42 -0
  35. data/lib/generators/flexi_prepare/templates/back.png +0 -0
  36. data/lib/generators/flexi_prepare/templates/bg.png +0 -0
  37. data/lib/generators/flexi_prepare/templates/bg2.png +0 -0
  38. data/lib/generators/flexi_prepare/templates/boxheader.gif +0 -0
  39. data/lib/generators/flexi_prepare/templates/btn-bg-hover.png +0 -0
  40. data/lib/generators/flexi_prepare/templates/btn-bg.png +0 -0
  41. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/custom_field_error.rb +1 -1
  42. data/lib/generators/flexi_prepare/templates/delete.png +0 -0
  43. data/lib/generators/flexi_prepare/templates/edit.png +0 -0
  44. data/lib/generators/flexi_prepare/templates/inflector_portuguese.rb +59 -0
  45. data/lib/generators/flexi_prepare/templates/login.css +142 -0
  46. data/lib/generators/flexi_prepare/templates/login.html.erb +26 -0
  47. data/lib/generators/flexi_prepare/templates/logo.png +0 -0
  48. data/lib/generators/flexi_prepare/templates/menu.png +0 -0
  49. data/lib/generators/flexi_prepare/templates/messages/Thumbs.db +0 -0
  50. data/lib/generators/flexi_prepare/templates/messages/error.png +0 -0
  51. data/lib/generators/flexi_prepare/templates/messages/info.png +0 -0
  52. data/lib/generators/flexi_prepare/templates/messages/success.png +0 -0
  53. data/lib/generators/flexi_prepare/templates/messages/tip.png +0 -0
  54. data/lib/generators/flexi_prepare/templates/messages/warning.png +0 -0
  55. data/lib/generators/flexi_prepare/templates/pt-BR.yml +204 -0
  56. data/lib/generators/flexi_prepare/templates/show.png +0 -0
  57. data/{generators/flexi_layout/templates/stylesheet_site.css → lib/generators/flexi_prepare/templates/site.css} +32 -23
  58. data/lib/generators/flexi_prepare/templates/site.html.erb +20 -0
  59. data/{generators/flexi_layout/templates/home_controller.rb → lib/generators/flexi_prepare/templates/site_controller.rb} +1 -1
  60. data/lib/generators/flexi_prepare/templates/site_helper.rb +2 -0
  61. data/lib/generators/flexi_prepare/templates/site_index.html.erb +27 -0
  62. data/{generators/flexi_layout → lib/generators/flexi_prepare}/templates/users.png +0 -0
  63. data/lib/generators/flexi_scaffold/USAGE +8 -0
  64. data/lib/generators/flexi_scaffold/flexi_scaffold_generator.rb +98 -0
  65. data/lib/generators/flexi_scaffold/templates/controller.rb +42 -0
  66. data/{generators → lib/generators}/flexi_scaffold/templates/fixtures.yml +3 -3
  67. data/{generators → lib/generators}/flexi_scaffold/templates/helper.rb +1 -1
  68. data/{generators → lib/generators}/flexi_scaffold/templates/migration.rb +3 -5
  69. data/lib/generators/flexi_scaffold/templates/model.rb +3 -0
  70. data/lib/generators/flexi_scaffold/templates/tests/controller.rb +50 -0
  71. data/lib/generators/flexi_scaffold/templates/tests/helper.rb +4 -0
  72. data/{test/flexi_generators_test.rb → lib/generators/flexi_scaffold/templates/tests/model.rb} +2 -2
  73. data/lib/generators/flexi_scaffold/templates/views/erb/_error_messages.html.erb +11 -0
  74. data/lib/generators/flexi_scaffold/templates/views/erb/_form.html.erb +13 -0
  75. data/lib/generators/flexi_scaffold/templates/views/erb/edit.html.erb +3 -0
  76. data/lib/generators/flexi_scaffold/templates/views/erb/index.html.erb +29 -0
  77. data/lib/generators/flexi_scaffold/templates/views/erb/new.html.erb +3 -0
  78. data/lib/generators/flexi_scaffold/templates/views/erb/show.html.erb +15 -0
  79. data/template.rb +6 -0
  80. metadata +79 -137
  81. data/flexi_template.rb +0 -28
  82. data/generators/flexi_authentication/USAGE +0 -50
  83. data/generators/flexi_authentication/flexi_authentication_generator.rb +0 -127
  84. data/generators/flexi_authentication/lib/insert_commands.rb +0 -74
  85. data/generators/flexi_authentication/templates/admin_users_controller.rb +0 -60
  86. data/generators/flexi_authentication/templates/migration.rb +0 -30
  87. data/generators/flexi_authentication/templates/sessions_controller.rb +0 -52
  88. data/generators/flexi_authentication/templates/tests/rspec/sessions_controller.rb +0 -39
  89. data/generators/flexi_authentication/templates/tests/rspec/user.rb +0 -83
  90. data/generators/flexi_authentication/templates/tests/rspec/users_controller.rb +0 -26
  91. data/generators/flexi_authentication/templates/tests/shoulda/sessions_controller.rb +0 -40
  92. data/generators/flexi_authentication/templates/tests/shoulda/user.rb +0 -85
  93. data/generators/flexi_authentication/templates/tests/shoulda/users_controller.rb +0 -27
  94. data/generators/flexi_authentication/templates/tests/testunit/user.rb +0 -88
  95. data/generators/flexi_authentication/templates/user.rb +0 -43
  96. data/generators/flexi_authentication/templates/views/erb/admin_user_edit.html.erb +0 -23
  97. data/generators/flexi_authentication/templates/views/erb/admin_user_index.html.erb +0 -33
  98. data/generators/flexi_authentication/templates/views/erb/admin_user_new.html.erb +0 -23
  99. data/generators/flexi_authentication/templates/views/erb/login.html.erb +0 -38
  100. data/generators/flexi_layout/USAGE +0 -18
  101. data/generators/flexi_layout/flexi_layout_generator.rb +0 -51
  102. data/generators/flexi_layout/lib/insert_commands.rb +0 -28
  103. data/generators/flexi_layout/templates/bg.png +0 -0
  104. data/generators/flexi_layout/templates/helper.rb +0 -19
  105. data/generators/flexi_layout/templates/home_helper.rb +0 -2
  106. data/generators/flexi_layout/templates/home_index.html.erb +0 -17
  107. data/generators/flexi_layout/templates/inflector_portuguese.rb +0 -62
  108. data/generators/flexi_layout/templates/layout.html.erb +0 -47
  109. data/generators/flexi_layout/templates/layout_login.html.erb +0 -27
  110. data/generators/flexi_layout/templates/layout_site.html.erb +0 -22
  111. data/generators/flexi_layout/templates/logo.png +0 -0
  112. data/generators/flexi_layout/templates/pt-BR.yml +0 -143
  113. data/generators/flexi_layout/templates/stylesheet.css +0 -132
  114. data/generators/flexi_layout/templates/stylesheet_login.css +0 -73
  115. data/generators/flexi_resource_scaffold/USAGE +0 -29
  116. data/generators/flexi_resource_scaffold/flexi_resource_scaffold_generator.rb +0 -179
  117. data/generators/flexi_resource_scaffold/templates/controller.rb +0 -29
  118. data/generators/flexi_resource_scaffold/templates/fixtures.yml +0 -10
  119. data/generators/flexi_resource_scaffold/templates/functional_test.rb +0 -57
  120. data/generators/flexi_resource_scaffold/templates/helper.rb +0 -2
  121. data/generators/flexi_resource_scaffold/templates/migration.rb +0 -15
  122. data/generators/flexi_resource_scaffold/templates/model.rb +0 -2
  123. data/generators/flexi_resource_scaffold/templates/old_migration.rb +0 -13
  124. data/generators/flexi_resource_scaffold/templates/rspec/functional_spec.rb +0 -255
  125. data/generators/flexi_resource_scaffold/templates/rspec/helper_spec.rb +0 -11
  126. data/generators/flexi_resource_scaffold/templates/rspec/routing_spec.rb +0 -61
  127. data/generators/flexi_resource_scaffold/templates/rspec/unit_spec.rb +0 -11
  128. data/generators/flexi_resource_scaffold/templates/rspec/views/edit_spec.rb +0 -28
  129. data/generators/flexi_resource_scaffold/templates/rspec/views/index_spec.rb +0 -26
  130. data/generators/flexi_resource_scaffold/templates/rspec/views/new_spec.rb +0 -30
  131. data/generators/flexi_resource_scaffold/templates/rspec/views/show_spec.rb +0 -25
  132. data/generators/flexi_resource_scaffold/templates/shoulda_functional_test.rb +0 -19
  133. data/generators/flexi_resource_scaffold/templates/unit_test.rb +0 -7
  134. data/generators/flexi_resource_scaffold/templates/view__form.erb +0 -6
  135. data/generators/flexi_resource_scaffold/templates/view__form.haml +0 -5
  136. data/generators/flexi_resource_scaffold/templates/view_edit.erb +0 -8
  137. data/generators/flexi_resource_scaffold/templates/view_edit.haml +0 -11
  138. data/generators/flexi_resource_scaffold/templates/view_index.erb +0 -27
  139. data/generators/flexi_resource_scaffold/templates/view_index.haml +0 -19
  140. data/generators/flexi_resource_scaffold/templates/view_new.erb +0 -9
  141. data/generators/flexi_resource_scaffold/templates/view_new.haml +0 -9
  142. data/generators/flexi_resource_scaffold/templates/view_show.erb +0 -10
  143. data/generators/flexi_resource_scaffold/templates/view_show.haml +0 -9
  144. data/generators/flexi_scaffold/USAGE +0 -51
  145. data/generators/flexi_scaffold/flexi_scaffold_generator.rb +0 -232
  146. data/generators/flexi_scaffold/templates/actions/create.rb +0 -9
  147. data/generators/flexi_scaffold/templates/actions/destroy.rb +0 -6
  148. data/generators/flexi_scaffold/templates/actions/edit.rb +0 -3
  149. data/generators/flexi_scaffold/templates/actions/index.rb +0 -4
  150. data/generators/flexi_scaffold/templates/actions/new.rb +0 -3
  151. data/generators/flexi_scaffold/templates/actions/show.rb +0 -3
  152. data/generators/flexi_scaffold/templates/actions/update.rb +0 -9
  153. data/generators/flexi_scaffold/templates/controller.rb +0 -5
  154. data/generators/flexi_scaffold/templates/model.rb +0 -3
  155. data/generators/flexi_scaffold/templates/tests/rspec/actions/create.rb +0 -11
  156. data/generators/flexi_scaffold/templates/tests/rspec/actions/destroy.rb +0 -6
  157. data/generators/flexi_scaffold/templates/tests/rspec/actions/edit.rb +0 -4
  158. data/generators/flexi_scaffold/templates/tests/rspec/actions/index.rb +0 -4
  159. data/generators/flexi_scaffold/templates/tests/rspec/actions/new.rb +0 -4
  160. data/generators/flexi_scaffold/templates/tests/rspec/actions/show.rb +0 -4
  161. data/generators/flexi_scaffold/templates/tests/rspec/actions/update.rb +0 -11
  162. data/generators/flexi_scaffold/templates/tests/rspec/controller.rb +0 -8
  163. data/generators/flexi_scaffold/templates/tests/rspec/model.rb +0 -7
  164. data/generators/flexi_scaffold/templates/tests/shoulda/actions/create.rb +0 -13
  165. data/generators/flexi_scaffold/templates/tests/shoulda/actions/destroy.rb +0 -8
  166. data/generators/flexi_scaffold/templates/tests/shoulda/actions/edit.rb +0 -6
  167. data/generators/flexi_scaffold/templates/tests/shoulda/actions/index.rb +0 -6
  168. data/generators/flexi_scaffold/templates/tests/shoulda/actions/new.rb +0 -6
  169. data/generators/flexi_scaffold/templates/tests/shoulda/actions/show.rb +0 -6
  170. data/generators/flexi_scaffold/templates/tests/shoulda/actions/update.rb +0 -13
  171. data/generators/flexi_scaffold/templates/tests/shoulda/controller.rb +0 -5
  172. data/generators/flexi_scaffold/templates/tests/shoulda/model.rb +0 -7
  173. data/generators/flexi_scaffold/templates/tests/testunit/actions/create.rb +0 -11
  174. data/generators/flexi_scaffold/templates/tests/testunit/actions/destroy.rb +0 -6
  175. data/generators/flexi_scaffold/templates/tests/testunit/actions/edit.rb +0 -4
  176. data/generators/flexi_scaffold/templates/tests/testunit/actions/index.rb +0 -4
  177. data/generators/flexi_scaffold/templates/tests/testunit/actions/new.rb +0 -4
  178. data/generators/flexi_scaffold/templates/tests/testunit/actions/show.rb +0 -4
  179. data/generators/flexi_scaffold/templates/tests/testunit/actions/update.rb +0 -11
  180. data/generators/flexi_scaffold/templates/tests/testunit/controller.rb +0 -5
  181. data/generators/flexi_scaffold/templates/tests/testunit/model.rb +0 -7
  182. data/generators/flexi_scaffold/templates/views/erb/_form.html.erb +0 -6
  183. data/generators/flexi_scaffold/templates/views/erb/edit.html.erb +0 -8
  184. data/generators/flexi_scaffold/templates/views/erb/index.html.erb +0 -41
  185. data/generators/flexi_scaffold/templates/views/erb/new.html.erb +0 -10
  186. data/generators/flexi_scaffold/templates/views/erb/show.html.erb +0 -19
  187. data/generators/flexi_scaffold/templates/views/haml/_form.html.haml +0 -10
  188. data/generators/flexi_scaffold/templates/views/haml/edit.html.haml +0 -14
  189. data/generators/flexi_scaffold/templates/views/haml/index.html.haml +0 -25
  190. data/generators/flexi_scaffold/templates/views/haml/new.html.haml +0 -7
  191. data/generators/flexi_scaffold/templates/views/haml/show.html.haml +0 -20
  192. data/test/test_helper.rb +0 -3
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate flexi_scaffold Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,98 @@
1
+ require 'rails/generators/migration'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ class FlexiScaffoldGenerator < Rails::Generators::Base
5
+ include Rails::Generators::Migration
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ no_tasks { attr_accessor :model_name, :model_attributes }
9
+ argument :model_name, :type => :string, :required => true, :banner => 'ModelName'
10
+ argument :args_for_m, :type => :array, :default => [], :banner => 'model:attributes'
11
+
12
+ def initialize(*args, &block)
13
+ super
14
+ @model_attributes = []
15
+
16
+ args_for_m.each do |arg|
17
+ if arg.include?(':')
18
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
19
+ end
20
+ end
21
+
22
+ @model_attributes.uniq!
23
+
24
+ if @model_attributes.empty?
25
+ if model_exists?
26
+ model_columns_for_attributes.each do |column|
27
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
28
+ end
29
+ else
30
+ @model_attributes << Rails::Generators::GeneratedAttribute.new('name', 'string')
31
+ end
32
+ end
33
+ end
34
+
35
+ def create_model
36
+ template 'model.rb', "app/models/#{singular_name}.rb"
37
+ template "tests/model.rb", "test/unit/#{singular_name}_test.rb"
38
+ template 'fixtures.yml', "test/fixtures/#{plural_name}.yml"
39
+ end
40
+
41
+ def create_controller
42
+ template "controller.rb", "app/controllers/admin/#{plural_name}_controller.rb"
43
+ inject_into_file "config/routes.rb", "\n\tresources #{plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
44
+ template "tests/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
45
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
46
+ template "tests/helper.rb", "test/unit/helpers/#{plural_name}_controller_test.rb"
47
+ end
48
+
49
+ def create_view_files
50
+ template "views/erb/index.html.erb", "app/views/admin/#{plural_name}/index.html.erb"
51
+ template "views/erb/_form.html.erb", "app/views/admin/#{plural_name}/_form.html.erb"
52
+ template "views/erb/show.html.erb", "app/views/admin/#{plural_name}/show.html.erb"
53
+ template "views/erb/new.html.erb", "app/views/admin/#{plural_name}/new.html.erb"
54
+ template "views/erb/edit.html.erb", "app/views/admin/#{plural_name}/edit.html.erb"
55
+ template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
56
+ end
57
+
58
+ def create_migration
59
+ migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
60
+ end
61
+
62
+ private
63
+
64
+ def singular_name
65
+ model_name.underscore
66
+ end
67
+
68
+ def plural_name
69
+ model_name.underscore.pluralize
70
+ end
71
+
72
+ def class_name
73
+ model_name.camelize
74
+ end
75
+
76
+ def plural_class_name
77
+ plural_name.camelize
78
+ end
79
+
80
+ def model_exists?
81
+ File.exist? destination_path("app/models/#{singular_name}.rb")
82
+ end
83
+
84
+ def model_columns_for_attributes
85
+ class_name.constantize.columns.reject do |column|
86
+ column.name.to_s =~ /^(id|created_at|updated_at)$/
87
+ end
88
+ end
89
+
90
+ def self.next_migration_number(dirname) #:nodoc:
91
+ if ActiveRecord::Base.timestamped_migrations
92
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
93
+ else
94
+ "%.3d" % (current_migration_number(dirname) + 1)
95
+ end
96
+ end
97
+
98
+ end
@@ -0,0 +1,42 @@
1
+ class Admin::<%= plural_class_name %>Controller < ApplicationController
2
+ menu_item :<%= plural_name %>
3
+ respond_to :html
4
+
5
+ def index
6
+ @<%= plural_name %> = <%= class_name %>.paginate :page => params[:page],
7
+ :per_page => 15
8
+ respond_with(:admin, @<%= plural_name %>)
9
+ end
10
+
11
+ def show
12
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
13
+ respond_with(:admin, @<%= singular_name %>)
14
+ end
15
+
16
+ def new
17
+ @<%= singular_name %> = <%= class_name %>.new
18
+ respond_with(:admin, @<%= singular_name %>)
19
+ end
20
+
21
+ def edit
22
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
23
+ end
24
+
25
+ def create
26
+ @<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
27
+ flash[:notice] = '<%= class_name %> foi criado com sucesso.' if @<%= singular_name %>.save
28
+ respond_with(:admin, @<%= singular_name %>)
29
+ end
30
+
31
+ def update
32
+ @<%= singular_name %> = <%= class_name %>.new(params[:id])
33
+ flash[:notice] = '<%= class_name %> foi alterado com sucesso.' if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
34
+ respond_with(:admin, @<%= singular_name %>)
35
+ end
36
+
37
+ def destroy
38
+ @<%= singular_name %> = <%= class_name %>.find(params[:id])
39
+ flash[:notice] = '<%= class_name %> foi excluído com sucesso.' if @<%= singular_name %>.destroy
40
+ respond_with(:admin, @<%= singular_name %>)
41
+ end
42
+ end
@@ -1,9 +1,9 @@
1
1
  one:
2
- <%- for attribute in attributes -%>
2
+ <%- for attribute in model_attributes -%>
3
3
  <%= attribute.name %>: <%= attribute.default %>
4
4
  <%- end -%>
5
5
 
6
6
  two:
7
- <%- for attribute in attributes -%>
7
+ <%- for attribute in model_attributes -%>
8
8
  <%= attribute.name %>: <%= attribute.default %>
9
- <%- end -%>
9
+ <%- end -%>
@@ -1,2 +1,2 @@
1
1
  module <%= plural_class_name %>Helper
2
- end
2
+ end
@@ -1,16 +1,14 @@
1
1
  class Create<%= plural_class_name %> < ActiveRecord::Migration
2
2
  def self.up
3
3
  create_table :<%= plural_name %> do |t|
4
- <%- for attribute in attributes -%>
4
+ <%- for attribute in model_attributes -%>
5
5
  t.<%= attribute.type %> :<%= attribute.name %>
6
- <%- end -%>
7
- <%- unless options[:skip_timestamps] -%>
6
+ <%- end -%>
8
7
  t.timestamps
9
- <%- end -%>
10
8
  end
11
9
  end
12
10
 
13
11
  def self.down
14
12
  drop_table :<%= plural_name %>
15
13
  end
16
- end
14
+ end
@@ -0,0 +1,3 @@
1
+ class <%= class_name %> < ActiveRecord::Base
2
+ attr_accessible <%= model_attributes.map { |a| ":#{a.name}" }.join(", ") %>
3
+ end
@@ -0,0 +1,50 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ setup do
5
+ @<%= singular_name %> = <%= plural_name %>(:one)
6
+ end
7
+
8
+ test "should get index" do
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:<%= plural_name %>)
12
+ end
13
+
14
+ test "should get new" do
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ test "should create <%= singular_name %>" do
20
+ assert_difference('<%= class_name %>.count') do
21
+ post :create, :<%= singular_name %> => @<%= singular_name %>.attributes
22
+ end
23
+
24
+ assert_redirected_to admin_<%= singular_name %>_path(assigns(:<%= singular_name %>))
25
+ end
26
+
27
+ test "should show <%= singular_name %>" do
28
+ get :show, :id => @<%= singular_name %>.to_param
29
+ assert_response :success
30
+ end
31
+
32
+ test "should get edit" do
33
+ get :edit, :id => @<%= singular_name %>.to_param
34
+ assert_response :success
35
+ end
36
+
37
+ test "should update post" do
38
+ put :update, :id => @<%= singular_name %>.to_param, :<%= singular_name %> => @<%= singular_name %>.attributes
39
+ assert_redirected_to admin_<%= singular_name %>_path(assigns(:<%= singular_name %>))
40
+ end
41
+
42
+ test "should destroy <%= singular_name %>" do
43
+ assert_difference('<%= class_name %>.count', -1) do
44
+ delete :destroy, :id => @<%= singular_name %>.to_param
45
+ end
46
+
47
+ assert_redirected_to admin_<%= plural_name %>_path
48
+ end
49
+ end
50
+
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -1,8 +1,8 @@
1
1
  require 'test_helper'
2
2
 
3
- class Flexi-generatorsTest < ActiveSupport::TestCase
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
4
  # Replace this with your real tests.
5
5
  test "the truth" do
6
6
  assert true
7
7
  end
8
- end
8
+ end
@@ -0,0 +1,11 @@
1
+ <%% if resource.errors.any? %>
2
+ <div class="flash_messages error_explanation">
3
+ <h2>Não foi possível gravar: <%%= pluralize(resource.errors.count, "erro") %></h2>
4
+
5
+ <ul>
6
+ <%% resource.errors.full_messages.each do |msg| %>
7
+ <li><%%= msg %></li>
8
+ <%% end %>
9
+ </ul>
10
+ </div>
11
+ <%% end %>
@@ -0,0 +1,13 @@
1
+ <%%= form_for([:admin, @<%= singular_name %>]) do |f| %>
2
+ <%%= render "shared/error_messages", :resource => @<%= singular_name %> %>
3
+
4
+ <%- for attribute in model_attributes -%>
5
+ <div class="field">
6
+ <%%= f.label :<%= attribute.name %> %><br />
7
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
8
+ </div>
9
+ <%- end -%>
10
+ <div id="control_box">
11
+ <%%= f.submit "Salvar", :class => "button medium save blue" %> | <%%= link_to("Cancelar", admin_<%= plural_name %>_path, :class => "button medium red") %>
12
+ </div>
13
+ <%% end %>
@@ -0,0 +1,3 @@
1
+ <%% title "Editando <%= singular_name.titleize %>" %>
2
+
3
+ <%%= render "form" %>
@@ -0,0 +1,29 @@
1
+ <%% title("<%= plural_name.titleize %>") %>
2
+
3
+ <div id="new_box">
4
+ <%%= link_to 'Adicionar', new_admin_<%= singular_name %>_path, :class => 'button medium green' %>
5
+ </div>
6
+
7
+ <table cellspacing="0" cellpadding="2">
8
+ <tr>
9
+ <%- for attribute in model_attributes -%>
10
+ <th><%= attribute.human_name.titleize %></th>
11
+ <%- end -%>
12
+ <th></th>
13
+ </tr>
14
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
15
+ <tr>
16
+ <%- for attribute in model_attributes -%>
17
+ <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
18
+ <%- end -%>
19
+ <td width="11%">
20
+ <ul class="actions">
21
+ <li><%%= link_to( image_tag("show.png"), [:admin, <%= singular_name %>], :title => "Mostrar" ) %></li>
22
+ <li><%%= link_to( image_tag("edit.png"), edit_admin_<%= singular_name %>_path(<%= singular_name %>), :title => "Editar" ) %></li>
23
+ <li><%%= link_to( image_tag("delete.png"), [:admin, <%= singular_name %>], :confirm => 'Tem certeza que deseja excluir?', :method => :delete, :title => "Excluir" ) %></li>
24
+ </ul>
25
+ </td>
26
+ </tr>
27
+ <%% end %>
28
+ </table>
29
+ <%%= will_paginate @<%= plural_name %>, :previous_label=>'&laquo; Anterior', :next_label=>'Próximo &raquo;' %>
@@ -0,0 +1,3 @@
1
+ <%% title "Novo <%= singular_name.titleize %>" %>
2
+
3
+ <%%= render "form" %>
@@ -0,0 +1,15 @@
1
+ <%% title "<%= singular_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <b><%= attribute.human_name.titleize %>:</b>
6
+ <%%= @<%= singular_name %>.<%= attribute.name %> %>
7
+ </p>
8
+ <%- end -%>
9
+
10
+ <div id="control_box">
11
+ <%%= link_to( image_tag("back.png"), admin_<%= plural_name %>_path, :title => "Voltar" ) %> |
12
+ <%%= link_to( image_tag("edit.png"), edit_admin_<%= singular_name %>_path(@<%= singular_name %>), :title => "Editar" ) %> |
13
+ <%%= link_to( image_tag("delete.png"), [:admin, @<%= singular_name %>], :confirm => 'Tem certeza que deseja excluir?', :method => :delete, :title => "Exlcuir" ) %>
14
+ </div>
15
+
data/template.rb ADDED
@@ -0,0 +1,6 @@
1
+ plugin "rails-footnotes", :git => "git://github.com/josevalim/rails-footnotes.git"
2
+ gem "flexi_generators", "=0.2.0"
3
+ run "bundle install"
4
+ generate :flexi_prepare
5
+ generate :flexi_auth
6
+
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: 27
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 0.1.0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leandro de Oliveira
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-09 00:00:00 -03:00
18
+ date: 2010-10-16 00:00:00 -03:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -32,138 +32,81 @@ files:
32
32
  - Rakefile
33
33
  - VERSION
34
34
  - flexi_generators.gemspec
35
- - flexi_template.rb
36
- - generators/flexi_authentication/USAGE
37
- - generators/flexi_authentication/flexi_authentication_generator.rb
38
- - generators/flexi_authentication/lib/insert_commands.rb
39
- - generators/flexi_authentication/templates/admin_users_controller.rb
40
- - generators/flexi_authentication/templates/authentication.rb
41
- - generators/flexi_authentication/templates/authlogic_session.rb
42
- - generators/flexi_authentication/templates/fixtures.yml
43
- - generators/flexi_authentication/templates/migration.rb
44
- - generators/flexi_authentication/templates/sessions_controller.rb
45
- - generators/flexi_authentication/templates/sessions_helper.rb
46
- - generators/flexi_authentication/templates/tests/rspec/sessions_controller.rb
47
- - generators/flexi_authentication/templates/tests/rspec/user.rb
48
- - generators/flexi_authentication/templates/tests/rspec/users_controller.rb
49
- - generators/flexi_authentication/templates/tests/shoulda/sessions_controller.rb
50
- - generators/flexi_authentication/templates/tests/shoulda/user.rb
51
- - generators/flexi_authentication/templates/tests/shoulda/users_controller.rb
52
- - generators/flexi_authentication/templates/tests/testunit/sessions_controller.rb
53
- - generators/flexi_authentication/templates/tests/testunit/user.rb
54
- - generators/flexi_authentication/templates/tests/testunit/users_controller.rb
55
- - generators/flexi_authentication/templates/user.rb
56
- - generators/flexi_authentication/templates/users_helper.rb
57
- - generators/flexi_authentication/templates/views/erb/admin_user_edit.html.erb
58
- - generators/flexi_authentication/templates/views/erb/admin_user_index.html.erb
59
- - generators/flexi_authentication/templates/views/erb/admin_user_new.html.erb
60
- - generators/flexi_authentication/templates/views/erb/login.html.erb
61
- - generators/flexi_layout/USAGE
62
- - generators/flexi_layout/flexi_layout_generator.rb
63
- - generators/flexi_layout/lib/insert_commands.rb
64
- - generators/flexi_layout/templates/add.png
65
- - generators/flexi_layout/templates/admin_home_controller.rb
66
- - generators/flexi_layout/templates/admin_home_index.html.erb
67
- - generators/flexi_layout/templates/bg.png
68
- - generators/flexi_layout/templates/custom_field_error.rb
69
- - generators/flexi_layout/templates/helper.rb
70
- - generators/flexi_layout/templates/home_controller.rb
71
- - generators/flexi_layout/templates/home_helper.rb
72
- - generators/flexi_layout/templates/home_index.html.erb
73
- - generators/flexi_layout/templates/inflector_portuguese.rb
74
- - generators/flexi_layout/templates/layout.html.erb
75
- - generators/flexi_layout/templates/layout_login.html.erb
76
- - generators/flexi_layout/templates/layout_site.html.erb
77
- - generators/flexi_layout/templates/logo.png
78
- - generators/flexi_layout/templates/pt-BR.yml
79
- - generators/flexi_layout/templates/stylesheet.css
80
- - generators/flexi_layout/templates/stylesheet_login.css
81
- - generators/flexi_layout/templates/stylesheet_site.css
82
- - generators/flexi_layout/templates/users.png
83
- - generators/flexi_resource_scaffold/USAGE
84
- - generators/flexi_resource_scaffold/flexi_resource_scaffold_generator.rb
85
- - generators/flexi_resource_scaffold/templates/controller.rb
86
- - generators/flexi_resource_scaffold/templates/fixtures.yml
87
- - generators/flexi_resource_scaffold/templates/functional_test.rb
88
- - generators/flexi_resource_scaffold/templates/helper.rb
89
- - generators/flexi_resource_scaffold/templates/migration.rb
90
- - generators/flexi_resource_scaffold/templates/model.rb
91
- - generators/flexi_resource_scaffold/templates/old_migration.rb
92
- - generators/flexi_resource_scaffold/templates/rspec/functional_spec.rb
93
- - generators/flexi_resource_scaffold/templates/rspec/helper_spec.rb
94
- - generators/flexi_resource_scaffold/templates/rspec/routing_spec.rb
95
- - generators/flexi_resource_scaffold/templates/rspec/unit_spec.rb
96
- - generators/flexi_resource_scaffold/templates/rspec/views/edit_spec.rb
97
- - generators/flexi_resource_scaffold/templates/rspec/views/index_spec.rb
98
- - generators/flexi_resource_scaffold/templates/rspec/views/new_spec.rb
99
- - generators/flexi_resource_scaffold/templates/rspec/views/show_spec.rb
100
- - generators/flexi_resource_scaffold/templates/shoulda_functional_test.rb
101
- - generators/flexi_resource_scaffold/templates/unit_test.rb
102
- - generators/flexi_resource_scaffold/templates/view__form.erb
103
- - generators/flexi_resource_scaffold/templates/view__form.haml
104
- - generators/flexi_resource_scaffold/templates/view_edit.erb
105
- - generators/flexi_resource_scaffold/templates/view_edit.haml
106
- - generators/flexi_resource_scaffold/templates/view_index.erb
107
- - generators/flexi_resource_scaffold/templates/view_index.haml
108
- - generators/flexi_resource_scaffold/templates/view_new.erb
109
- - generators/flexi_resource_scaffold/templates/view_new.haml
110
- - generators/flexi_resource_scaffold/templates/view_show.erb
111
- - generators/flexi_resource_scaffold/templates/view_show.haml
112
- - generators/flexi_scaffold/USAGE
113
- - generators/flexi_scaffold/flexi_scaffold_generator.rb
114
- - generators/flexi_scaffold/templates/actions/create.rb
115
- - generators/flexi_scaffold/templates/actions/destroy.rb
116
- - generators/flexi_scaffold/templates/actions/edit.rb
117
- - generators/flexi_scaffold/templates/actions/index.rb
118
- - generators/flexi_scaffold/templates/actions/new.rb
119
- - generators/flexi_scaffold/templates/actions/show.rb
120
- - generators/flexi_scaffold/templates/actions/update.rb
121
- - generators/flexi_scaffold/templates/controller.rb
122
- - generators/flexi_scaffold/templates/fixtures.yml
123
- - generators/flexi_scaffold/templates/helper.rb
124
- - generators/flexi_scaffold/templates/migration.rb
125
- - generators/flexi_scaffold/templates/model.rb
126
- - generators/flexi_scaffold/templates/tests/rspec/actions/create.rb
127
- - generators/flexi_scaffold/templates/tests/rspec/actions/destroy.rb
128
- - generators/flexi_scaffold/templates/tests/rspec/actions/edit.rb
129
- - generators/flexi_scaffold/templates/tests/rspec/actions/index.rb
130
- - generators/flexi_scaffold/templates/tests/rspec/actions/new.rb
131
- - generators/flexi_scaffold/templates/tests/rspec/actions/show.rb
132
- - generators/flexi_scaffold/templates/tests/rspec/actions/update.rb
133
- - generators/flexi_scaffold/templates/tests/rspec/controller.rb
134
- - generators/flexi_scaffold/templates/tests/rspec/model.rb
135
- - generators/flexi_scaffold/templates/tests/shoulda/actions/create.rb
136
- - generators/flexi_scaffold/templates/tests/shoulda/actions/destroy.rb
137
- - generators/flexi_scaffold/templates/tests/shoulda/actions/edit.rb
138
- - generators/flexi_scaffold/templates/tests/shoulda/actions/index.rb
139
- - generators/flexi_scaffold/templates/tests/shoulda/actions/new.rb
140
- - generators/flexi_scaffold/templates/tests/shoulda/actions/show.rb
141
- - generators/flexi_scaffold/templates/tests/shoulda/actions/update.rb
142
- - generators/flexi_scaffold/templates/tests/shoulda/controller.rb
143
- - generators/flexi_scaffold/templates/tests/shoulda/model.rb
144
- - generators/flexi_scaffold/templates/tests/testunit/actions/create.rb
145
- - generators/flexi_scaffold/templates/tests/testunit/actions/destroy.rb
146
- - generators/flexi_scaffold/templates/tests/testunit/actions/edit.rb
147
- - generators/flexi_scaffold/templates/tests/testunit/actions/index.rb
148
- - generators/flexi_scaffold/templates/tests/testunit/actions/new.rb
149
- - generators/flexi_scaffold/templates/tests/testunit/actions/show.rb
150
- - generators/flexi_scaffold/templates/tests/testunit/actions/update.rb
151
- - generators/flexi_scaffold/templates/tests/testunit/controller.rb
152
- - generators/flexi_scaffold/templates/tests/testunit/model.rb
153
- - generators/flexi_scaffold/templates/views/erb/_form.html.erb
154
- - generators/flexi_scaffold/templates/views/erb/edit.html.erb
155
- - generators/flexi_scaffold/templates/views/erb/index.html.erb
156
- - generators/flexi_scaffold/templates/views/erb/new.html.erb
157
- - generators/flexi_scaffold/templates/views/erb/show.html.erb
158
- - generators/flexi_scaffold/templates/views/haml/_form.html.haml
159
- - generators/flexi_scaffold/templates/views/haml/edit.html.haml
160
- - generators/flexi_scaffold/templates/views/haml/index.html.haml
161
- - generators/flexi_scaffold/templates/views/haml/new.html.haml
162
- - generators/flexi_scaffold/templates/views/haml/show.html.haml
163
35
  - init.rb
164
36
  - lib/flexi_generators.rb
165
- - test/flexi_generators_test.rb
166
- - test/test_helper.rb
37
+ - lib/generators/flexi_auth/USAGE
38
+ - lib/generators/flexi_auth/flexi_auth_generator.rb
39
+ - lib/generators/flexi_auth/templates/authentication.rb
40
+ - lib/generators/flexi_auth/templates/authlogic_session.rb
41
+ - lib/generators/flexi_auth/templates/fixtures.yml
42
+ - lib/generators/flexi_auth/templates/migration.rb
43
+ - lib/generators/flexi_auth/templates/sessions_controller.rb
44
+ - lib/generators/flexi_auth/templates/sessions_helper.rb
45
+ - lib/generators/flexi_auth/templates/tests/testunit/sessions_controller.rb
46
+ - lib/generators/flexi_auth/templates/tests/testunit/user.rb
47
+ - lib/generators/flexi_auth/templates/tests/testunit/users_controller.rb
48
+ - lib/generators/flexi_auth/templates/user.rb
49
+ - lib/generators/flexi_auth/templates/users_controller.rb
50
+ - lib/generators/flexi_auth/templates/users_helper.rb
51
+ - lib/generators/flexi_auth/templates/views/erb/_error_messages.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/flexi_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.html.erb
64
+ - lib/generators/flexi_prepare/templates/application_helper.rb
65
+ - lib/generators/flexi_prepare/templates/back.png
66
+ - lib/generators/flexi_prepare/templates/bg.png
67
+ - lib/generators/flexi_prepare/templates/bg2.png
68
+ - lib/generators/flexi_prepare/templates/boxheader.gif
69
+ - lib/generators/flexi_prepare/templates/btn-bg-hover.png
70
+ - lib/generators/flexi_prepare/templates/btn-bg.png
71
+ - lib/generators/flexi_prepare/templates/custom_field_error.rb
72
+ - lib/generators/flexi_prepare/templates/delete.png
73
+ - lib/generators/flexi_prepare/templates/edit.png
74
+ - lib/generators/flexi_prepare/templates/inflector_portuguese.rb
75
+ - lib/generators/flexi_prepare/templates/login.css
76
+ - lib/generators/flexi_prepare/templates/login.html.erb
77
+ - lib/generators/flexi_prepare/templates/logo.png
78
+ - lib/generators/flexi_prepare/templates/menu.png
79
+ - lib/generators/flexi_prepare/templates/messages/Thumbs.db
80
+ - lib/generators/flexi_prepare/templates/messages/error.png
81
+ - lib/generators/flexi_prepare/templates/messages/info.png
82
+ - lib/generators/flexi_prepare/templates/messages/success.png
83
+ - lib/generators/flexi_prepare/templates/messages/tip.png
84
+ - lib/generators/flexi_prepare/templates/messages/warning.png
85
+ - lib/generators/flexi_prepare/templates/pt-BR.yml
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
94
+ - lib/generators/flexi_scaffold/flexi_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
167
110
  has_rdoc: true
168
111
  homepage: http://github.com/leandroo/flexi_generators
169
112
  licenses: []
@@ -198,6 +141,5 @@ rubygems_version: 1.3.7
198
141
  signing_key:
199
142
  specification_version: 3
200
143
  summary: My useful Rails generator scripts.
201
- test_files:
202
- - test/flexi_generators_test.rb
203
- - test/test_helper.rb
144
+ test_files: []
145
+
data/flexi_template.rb DELETED
@@ -1,28 +0,0 @@
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'