tripper 0.0.3d

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +1 -0
  7. data/TODO +26 -0
  8. data/lib/generators/USAGE +8 -0
  9. data/lib/generators/tripper.rb +51 -0
  10. data/lib/generators/tripper/commonalities/commonalities.rb +226 -0
  11. data/lib/generators/tripper/detect_changes/detect_changes_generator.rb +173 -0
  12. data/lib/generators/tripper/detect_changes/model.rb +226 -0
  13. data/lib/generators/tripper/detect_changes/templates/migration.rb +7 -0
  14. data/lib/generators/tripper/detect_changes/templates/model/belongs_to.rb +1 -0
  15. data/lib/generators/tripper/detect_changes/templates/model/has_one.rb +1 -0
  16. data/lib/generators/tripper/detect_changes/templates/model/validates.rb +2 -0
  17. data/lib/generators/tripper/from_community/from_community_generator.rb +95 -0
  18. data/lib/generators/tripper/from_community/templates/actions/create.rb +8 -0
  19. data/lib/generators/tripper/from_community/templates/actions/destroy.rb +5 -0
  20. data/lib/generators/tripper/from_community/templates/actions/edit.rb +3 -0
  21. data/lib/generators/tripper/from_community/templates/actions/index.rb +3 -0
  22. data/lib/generators/tripper/from_community/templates/actions/new.rb +3 -0
  23. data/lib/generators/tripper/from_community/templates/actions/show.rb +3 -0
  24. data/lib/generators/tripper/from_community/templates/actions/update.rb +8 -0
  25. data/lib/generators/tripper/from_community/templates/controller.rb +3 -0
  26. data/lib/generators/tripper/from_community/templates/fixtures.yml +9 -0
  27. data/lib/generators/tripper/from_community/templates/helper.rb +2 -0
  28. data/lib/generators/tripper/from_community/templates/migration.rb +30 -0
  29. data/lib/generators/tripper/from_community/templates/model.rb +54 -0
  30. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/create.rb +11 -0
  31. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/destroy.rb +6 -0
  32. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/edit.rb +4 -0
  33. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/index.rb +4 -0
  34. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/new.rb +4 -0
  35. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/show.rb +4 -0
  36. data/lib/generators/tripper/from_community/templates/tests/rspec/actions/update.rb +11 -0
  37. data/lib/generators/tripper/from_community/templates/tests/rspec/controller.rb +8 -0
  38. data/lib/generators/tripper/from_community/templates/tests/rspec/model.rb +7 -0
  39. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/create.rb +13 -0
  40. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/destroy.rb +8 -0
  41. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/edit.rb +6 -0
  42. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/index.rb +6 -0
  43. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/new.rb +6 -0
  44. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/show.rb +6 -0
  45. data/lib/generators/tripper/from_community/templates/tests/shoulda/actions/update.rb +13 -0
  46. data/lib/generators/tripper/from_community/templates/tests/shoulda/controller.rb +5 -0
  47. data/lib/generators/tripper/from_community/templates/tests/shoulda/model.rb +7 -0
  48. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/create.rb +11 -0
  49. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/destroy.rb +6 -0
  50. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/edit.rb +4 -0
  51. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/index.rb +4 -0
  52. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/new.rb +4 -0
  53. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/show.rb +4 -0
  54. data/lib/generators/tripper/from_community/templates/tests/testunit/actions/update.rb +11 -0
  55. data/lib/generators/tripper/from_community/templates/tests/testunit/controller.rb +5 -0
  56. data/lib/generators/tripper/from_community/templates/tests/testunit/model.rb +7 -0
  57. data/lib/generators/tripper/from_community/templates/views/erb/_form.html.erb +16 -0
  58. data/lib/generators/tripper/from_community/templates/views/erb/edit.html.erb +14 -0
  59. data/lib/generators/tripper/from_community/templates/views/erb/index.html.erb +29 -0
  60. data/lib/generators/tripper/from_community/templates/views/erb/new.html.erb +7 -0
  61. data/lib/generators/tripper/from_community/templates/views/erb/show.html.erb +25 -0
  62. data/lib/generators/tripper/from_community/templates/views/haml/_form.html.haml +9 -0
  63. data/lib/generators/tripper/from_community/templates/views/haml/edit.html.haml +14 -0
  64. data/lib/generators/tripper/from_community/templates/views/haml/index.html.haml +25 -0
  65. data/lib/generators/tripper/from_community/templates/views/haml/new.html.haml +7 -0
  66. data/lib/generators/tripper/from_community/templates/views/haml/show.html.haml +20 -0
  67. data/lib/generators/tripper/layout/USAGE +18 -0
  68. data/lib/generators/tripper/layout/layout_generator.rb +29 -0
  69. data/lib/generators/tripper/layout/templates/error_messages_helper.rb +23 -0
  70. data/lib/generators/tripper/layout/templates/layout.html.erb +19 -0
  71. data/lib/generators/tripper/layout/templates/layout.html.haml +21 -0
  72. data/lib/generators/tripper/layout/templates/layout_helper.rb +22 -0
  73. data/lib/generators/tripper/layout/templates/stylesheet.css +83 -0
  74. data/lib/generators/tripper/layout/templates/stylesheet.sass +73 -0
  75. data/lib/generators/tripper/obj_constraint.rb +23 -0
  76. data/lib/generators/tripper/predicate.rb +12 -0
  77. data/lib/generators/tripper/sync_with_community/model.rb +260 -0
  78. data/lib/generators/tripper/sync_with_community/sync_with_community_generator.rb +310 -0
  79. data/lib/generators/tripper/sync_with_community/templates/migration.rb +7 -0
  80. data/lib/generators/tripper/sync_with_community/templates/model/belongs_to.rb +1 -0
  81. data/lib/generators/tripper/sync_with_community/templates/model/has_one.rb +1 -0
  82. data/lib/generators/tripper/sync_with_community/templates/model/validates.rb +2 -0
  83. data/lib/generators/tripper/templates/actions/create.rb +8 -0
  84. data/lib/generators/tripper/templates/actions/destroy.rb +5 -0
  85. data/lib/generators/tripper/templates/actions/edit.rb +3 -0
  86. data/lib/generators/tripper/templates/actions/index.rb +3 -0
  87. data/lib/generators/tripper/templates/actions/new.rb +3 -0
  88. data/lib/generators/tripper/templates/actions/show.rb +3 -0
  89. data/lib/generators/tripper/templates/actions/update.rb +8 -0
  90. data/lib/generators/tripper/templates/controller.rb +3 -0
  91. data/lib/generators/tripper/templates/fixtures.yml +9 -0
  92. data/lib/generators/tripper/templates/helper.rb +2 -0
  93. data/lib/generators/tripper/templates/migration.rb +30 -0
  94. data/lib/generators/tripper/templates/model.rb +54 -0
  95. data/lib/generators/tripper/templates/tests/rspec/actions/create.rb +11 -0
  96. data/lib/generators/tripper/templates/tests/rspec/actions/destroy.rb +6 -0
  97. data/lib/generators/tripper/templates/tests/rspec/actions/edit.rb +4 -0
  98. data/lib/generators/tripper/templates/tests/rspec/actions/index.rb +4 -0
  99. data/lib/generators/tripper/templates/tests/rspec/actions/new.rb +4 -0
  100. data/lib/generators/tripper/templates/tests/rspec/actions/show.rb +4 -0
  101. data/lib/generators/tripper/templates/tests/rspec/actions/update.rb +11 -0
  102. data/lib/generators/tripper/templates/tests/rspec/controller.rb +8 -0
  103. data/lib/generators/tripper/templates/tests/rspec/model.rb +7 -0
  104. data/lib/generators/tripper/templates/tests/shoulda/actions/create.rb +13 -0
  105. data/lib/generators/tripper/templates/tests/shoulda/actions/destroy.rb +8 -0
  106. data/lib/generators/tripper/templates/tests/shoulda/actions/edit.rb +6 -0
  107. data/lib/generators/tripper/templates/tests/shoulda/actions/index.rb +6 -0
  108. data/lib/generators/tripper/templates/tests/shoulda/actions/new.rb +6 -0
  109. data/lib/generators/tripper/templates/tests/shoulda/actions/show.rb +6 -0
  110. data/lib/generators/tripper/templates/tests/shoulda/actions/update.rb +13 -0
  111. data/lib/generators/tripper/templates/tests/shoulda/controller.rb +5 -0
  112. data/lib/generators/tripper/templates/tests/shoulda/model.rb +7 -0
  113. data/lib/generators/tripper/templates/tests/testunit/actions/create.rb +11 -0
  114. data/lib/generators/tripper/templates/tests/testunit/actions/destroy.rb +6 -0
  115. data/lib/generators/tripper/templates/tests/testunit/actions/edit.rb +4 -0
  116. data/lib/generators/tripper/templates/tests/testunit/actions/index.rb +4 -0
  117. data/lib/generators/tripper/templates/tests/testunit/actions/new.rb +4 -0
  118. data/lib/generators/tripper/templates/tests/testunit/actions/show.rb +4 -0
  119. data/lib/generators/tripper/templates/tests/testunit/actions/update.rb +11 -0
  120. data/lib/generators/tripper/templates/tests/testunit/controller.rb +5 -0
  121. data/lib/generators/tripper/templates/tests/testunit/model.rb +7 -0
  122. data/lib/generators/tripper/templates/views/erb/_form.html.erb +16 -0
  123. data/lib/generators/tripper/templates/views/erb/edit.html.erb +14 -0
  124. data/lib/generators/tripper/templates/views/erb/index.html.erb +29 -0
  125. data/lib/generators/tripper/templates/views/erb/new.html.erb +7 -0
  126. data/lib/generators/tripper/templates/views/erb/show.html.erb +25 -0
  127. data/lib/generators/tripper/templates/views/haml/_form.html.haml +9 -0
  128. data/lib/generators/tripper/templates/views/haml/edit.html.haml +14 -0
  129. data/lib/generators/tripper/templates/views/haml/index.html.haml +25 -0
  130. data/lib/generators/tripper/templates/views/haml/new.html.haml +7 -0
  131. data/lib/generators/tripper/templates/views/haml/show.html.haml +20 -0
  132. data/lib/tripper.rb +1 -0
  133. data/lib/tripper/GOSPLDB/config/database.yml +6 -0
  134. data/lib/tripper/GOSPLDB/config_db.rb +9 -0
  135. data/lib/tripper/GOSPLDB/console +2 -0
  136. data/lib/tripper/GOSPLDB/gospl_db_classes.rb +343 -0
  137. data/lib/tripper/GOSPLDB/play_around.rb +4 -0
  138. data/lib/tripper/GOSPLDB/rakefile.rb +88 -0
  139. data/lib/tripper/GOSPLDBToORMDB/gospl_db_to_orm_db.rb +88 -0
  140. data/lib/tripper/ORMDB/config/database.yml +6 -0
  141. data/lib/tripper/ORMDB/config_db.rb +9 -0
  142. data/lib/tripper/ORMDB/console +2 -0
  143. data/lib/tripper/ORMDB/db/migrations/0_create_orm_object_table.rb +17 -0
  144. data/lib/tripper/ORMDB/db/migrations/10_create_no_lot_constraint_table.rb +17 -0
  145. data/lib/tripper/ORMDB/db/migrations/11_create_value_constraint_table.rb +14 -0
  146. data/lib/tripper/ORMDB/db/migrations/12_create_value_constraint_value_table.rb +16 -0
  147. data/lib/tripper/ORMDB/db/migrations/13_create_value_range_table.rb +15 -0
  148. data/lib/tripper/ORMDB/db/migrations/14_create_frequency_constraint_table.rb +16 -0
  149. data/lib/tripper/ORMDB/db/migrations/15_create_value_table.rb +15 -0
  150. data/lib/tripper/ORMDB/db/migrations/16_create_ring_constraint_table.rb +14 -0
  151. data/lib/tripper/ORMDB/db/migrations/17_create_orm_schema_table.rb +21 -0
  152. data/lib/tripper/ORMDB/db/migrations/18_create_uniqueness_constraint_table.rb +15 -0
  153. data/lib/tripper/ORMDB/db/migrations/1_create_no_lot_table.rb +18 -0
  154. data/lib/tripper/ORMDB/db/migrations/2_create_lot_table.rb +18 -0
  155. data/lib/tripper/ORMDB/db/migrations/3_create_object_role_table.rb +18 -0
  156. data/lib/tripper/ORMDB/db/migrations/4_create_reference_table.rb +17 -0
  157. data/lib/tripper/ORMDB/db/migrations/5_create_predicate_table.rb +18 -0
  158. data/lib/tripper/ORMDB/db/migrations/6_create_object_role_constraint_table.rb +18 -0
  159. data/lib/tripper/ORMDB/db/migrations/7_create_subtype_table.rb +17 -0
  160. data/lib/tripper/ORMDB/db/migrations/8_create_mandatory_constraint_table.rb +15 -0
  161. data/lib/tripper/ORMDB/db/migrations/9_create_constraint_table.rb +15 -0
  162. data/lib/tripper/ORMDB/db/orm_ml.sqlite3 +0 -0
  163. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.backup +0 -0
  164. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.juli28-2013 +0 -0
  165. data/lib/tripper/ORMDB/db/orm_ml.sqlite3.old +0 -0
  166. data/lib/tripper/ORMDB/db/schema.rb +58 -0
  167. data/lib/tripper/ORMDB/erd.pdf +0 -0
  168. data/lib/tripper/ORMDB/migrate_db.rb +21 -0
  169. data/lib/tripper/ORMDB/orm_db_classes.rb +423 -0
  170. data/lib/tripper/ORMDB/populate.rb +4 -0
  171. data/lib/tripper/ORMDB/rakefile.rb +88 -0
  172. data/lib/tripper/model_parsers/attribute_parser/AttributeParser.g +50 -0
  173. data/lib/tripper/model_parsers/attribute_parser/AttributeParser.tokens +13 -0
  174. data/lib/tripper/model_parsers/attribute_parser/AttributeParserLexer.rb +538 -0
  175. data/lib/tripper/model_parsers/attribute_parser/AttributeParserParser.rb +412 -0
  176. data/lib/tripper/model_parsers/attribute_parser/playing_around.rb +14 -0
  177. data/lib/tripper/model_parsers/belongs_to/BelongsToParser.g +63 -0
  178. data/lib/tripper/model_parsers/belongs_to/BelongsToParser.tokens +21 -0
  179. data/lib/tripper/model_parsers/belongs_to/BelongsToParserLexer.rb +667 -0
  180. data/lib/tripper/model_parsers/belongs_to/BelongsToParserParser.rb +552 -0
  181. data/lib/tripper/model_parsers/belongs_to/playing_around.rb +9 -0
  182. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParser.g +47 -0
  183. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParser.tokens +14 -0
  184. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParserLexer.rb +513 -0
  185. data/lib/tripper/model_parsers/database_fields_parser/DatabaseFieldsParserParser.rb +279 -0
  186. data/lib/tripper/model_parsers/database_fields_parser/playing_around.rb +14 -0
  187. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParser.g +92 -0
  188. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParser.tokens +25 -0
  189. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParserLexer.rb +787 -0
  190. data/lib/tripper/model_parsers/has_and_belongs_to_many/HasAndBelongsToManyParserParser.rb +1024 -0
  191. data/lib/tripper/model_parsers/has_and_belongs_to_many/playing_around.rb +9 -0
  192. data/lib/tripper/model_parsers/has_many/HasManyParser.g +77 -0
  193. data/lib/tripper/model_parsers/has_many/HasManyParser.tokens +23 -0
  194. data/lib/tripper/model_parsers/has_many/HasManyParserLexer.rb +710 -0
  195. data/lib/tripper/model_parsers/has_many/HasManyParserParser.rb +788 -0
  196. data/lib/tripper/model_parsers/has_many/playing_around.rb +9 -0
  197. data/lib/tripper/model_parsers/has_one/HasOneParser.g +63 -0
  198. data/lib/tripper/model_parsers/has_one/HasOneParser.tokens +21 -0
  199. data/lib/tripper/model_parsers/has_one/HasOneParserLexer.rb +664 -0
  200. data/lib/tripper/model_parsers/has_one/HasOneParserParser.rb +552 -0
  201. data/lib/tripper/model_parsers/has_one/playing_around.rb +9 -0
  202. data/lib/tripper/model_parsers/validates/ValidatesParser.g +68 -0
  203. data/lib/tripper/model_parsers/validates/ValidatesParser.tokens +35 -0
  204. data/lib/tripper/model_parsers/validates/ValidatesParserLexer.rb +899 -0
  205. data/lib/tripper/model_parsers/validates/ValidatesParserParser.rb +869 -0
  206. data/lib/tripper/model_parsers/validates/playing_around.rb +9 -0
  207. data/lib/tripper/rails.rb +8 -0
  208. data/lib/tripper/version.rb +3 -0
  209. data/tripper.gemspec +33 -0
  210. metadata +408 -0
@@ -0,0 +1,11 @@
1
+ it "create action should render new template when model is invalid" do
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ post :create
4
+ response.should render_template(:new)
5
+ end
6
+
7
+ it "create action should redirect when model is valid" do
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ post :create
10
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
11
+ end
@@ -0,0 +1,6 @@
1
+ it "destroy action should destroy model and redirect to index action" do
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ response.should redirect_to(<%= items_url %>)
5
+ <%= class_name %>.exists?(<%= instance_name %>.id).should be_false
6
+ end
@@ -0,0 +1,4 @@
1
+ it "edit action should render edit template" do
2
+ get :edit, :id => <%= class_name %>.first
3
+ response.should render_template(:edit)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "index action should render index template" do
2
+ get :index
3
+ response.should render_template(:index)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "new action should render new template" do
2
+ get :new
3
+ response.should render_template(:new)
4
+ end
@@ -0,0 +1,4 @@
1
+ it "show action should render show template" do
2
+ get :show, :id => <%= class_name %>.first
3
+ response.should render_template(:show)
4
+ end
@@ -0,0 +1,11 @@
1
+ it "update action should render edit template when model is invalid" do
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ put :update, :id => <%= class_name %>.first
4
+ response.should render_template(:edit)
5
+ end
6
+
7
+ it "update action should redirect when model is valid" do
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ put :update, :id => <%= class_name %>.first
10
+ response.should redirect_to(<%= item_path_for_spec('url') %>)
11
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe <%= plural_class_name %>Controller do
4
+ fixtures :all
5
+ render_views
6
+
7
+ <%= controller_methods 'tests/rspec/actions' %>
8
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe <%= class_name %> do
4
+ it "should be valid" do
5
+ <%= class_name %>.new.should be_valid
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ context "create action" do
2
+ should "render new template when model is invalid" do
3
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
4
+ post :create
5
+ assert_template 'new'
6
+ end
7
+
8
+ should "redirect when model is valid" do
9
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
10
+ post :create
11
+ assert_redirected_to <%= item_path_for_test('url') %>
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ context "destroy action" do
2
+ should "destroy model and redirect to index action" do
3
+ <%= instance_name %> = <%= class_name %>.first
4
+ delete :destroy, :id => <%= instance_name %>
5
+ assert_redirected_to <%= items_url %>
6
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ context "edit action" do
2
+ should "render edit template" do
3
+ get :edit, :id => <%= class_name %>.first
4
+ assert_template 'edit'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "index action" do
2
+ should "render index template" do
3
+ get :index
4
+ assert_template 'index'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "new action" do
2
+ should "render new template" do
3
+ get :new
4
+ assert_template 'new'
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ context "show action" do
2
+ should "render show template" do
3
+ get :show, :id => <%= class_name %>.first
4
+ assert_template 'show'
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ context "update action" do
2
+ should "render edit template when model is invalid" do
3
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
4
+ put :update, :id => <%= class_name %>.first
5
+ assert_template 'edit'
6
+ end
7
+
8
+ should "redirect when model is valid" do
9
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
10
+ put :update, :id => <%= class_name %>.first
11
+ assert_redirected_to <%= item_path_for_test('url') %>
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/shoulda/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ should "be valid" do
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ def test_create_invalid
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ post :create
4
+ assert_template 'new'
5
+ end
6
+
7
+ def test_create_valid
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ post :create
10
+ assert_redirected_to <%= item_path_for_test('url') %>
11
+ end
@@ -0,0 +1,6 @@
1
+ def test_destroy
2
+ <%= instance_name %> = <%= class_name %>.first
3
+ delete :destroy, :id => <%= instance_name %>
4
+ assert_redirected_to <%= items_url %>
5
+ assert !<%= class_name %>.exists?(<%= instance_name %>.id)
6
+ end
@@ -0,0 +1,4 @@
1
+ def test_edit
2
+ get :edit, :id => <%= class_name %>.first
3
+ assert_template 'edit'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_index
2
+ get :index
3
+ assert_template 'index'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_new
2
+ get :new
3
+ assert_template 'new'
4
+ end
@@ -0,0 +1,4 @@
1
+ def test_show
2
+ get :show, :id => <%= class_name %>.first
3
+ assert_template 'show'
4
+ end
@@ -0,0 +1,11 @@
1
+ def test_update_invalid
2
+ <%= class_name %>.any_instance.stubs(:valid?).returns(false)
3
+ put :update, :id => <%= class_name %>.first
4
+ assert_template 'edit'
5
+ end
6
+
7
+ def test_update_valid
8
+ <%= class_name %>.any_instance.stubs(:valid?).returns(true)
9
+ put :update, :id => <%= class_name %>.first
10
+ assert_redirected_to <%= item_path_for_test('url') %>
11
+ end
@@ -0,0 +1,5 @@
1
+ require 'test_helper'
2
+
3
+ class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
+ <%= controller_methods 'tests/testunit/actions' %>
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= class_name %>Test < ActiveSupport::TestCase
4
+ def test_should_be_valid
5
+ assert <%= class_name %>.new.valid?
6
+ end
7
+ end
@@ -0,0 +1,16 @@
1
+ <%%= form_for <%= item_path :instance_variable => true %> do |f| %>
2
+ <%%= f.error_messages %>
3
+ <%- for attribute in model_attributes -%>
4
+ <div class="field">
5
+ <%%= f.label :<%= attribute.name %> %>
6
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
7
+ </div>
8
+ <%- end -%>
9
+ <%- for nolot in @nolot.identifying_constraint_objects.no_lots -%>
10
+ <div class="field">
11
+ <%%= f.label :<%= attribute_nameify get_class_name(nolot) %> %>
12
+ <%%= f.select("<%= attribute_nameify get_class_name(nolot) %>_id", <%= get_class_name(nolot) %>.all.collect {|p| [ p.textualize, p.id ] }, { :include_blank => true }) %>
13
+ </div>
14
+ <%- end -%>
15
+ <div class="actions"><%%= f.submit %></div>
16
+ <%% end %>
@@ -0,0 +1,14 @@
1
+ <%% title "Edit <%= singular_name.titleize %>" %>
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if actions? :show, :index -%>
6
+ <p>
7
+ <%- if action? :show -%>
8
+ <%%= link_to "Show", <%= item_path :instance_variable => true %> %> |
9
+ <%- end -%>
10
+ <%- if action? :index -%>
11
+ <%%= link_to "View All", <%= items_path %> %>
12
+ <%- end -%>
13
+ </p>
14
+ <%- end -%>
@@ -0,0 +1,29 @@
1
+ <%% title "<%= plural_name.titleize %>" %>
2
+
3
+ <table>
4
+ <tr>
5
+ <%- for attribute in model_attributes -%>
6
+ <th><%= attribute.human_name.titleize %></th>
7
+ <%- end -%>
8
+ </tr>
9
+ <%% for <%= instance_name %> in @<%= instances_name %> %>
10
+ <tr>
11
+ <%- for attribute in model_attributes -%>
12
+ <td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
13
+ <%- end -%>
14
+ <%- if action? :show -%>
15
+ <td><%%= link_to "Show", <%= item_path %> %></td>
16
+ <%- end -%>
17
+ <%- if action? :edit -%>
18
+ <td><%%= link_to "Edit", <%= item_path :action => :edit %> %></td>
19
+ <%- end -%>
20
+ <%- if action? :destroy -%>
21
+ <td><%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %></td>
22
+ <%- end -%>
23
+ </tr>
24
+ <%% end %>
25
+ </table>
26
+
27
+ <%- if action? :new -%>
28
+ <p><%%= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %> %></p>
29
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ <%% title "New <%= singular_name.titleize %>" %>
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if action? :index -%>
6
+ <p><%%= link_to "Back to List", <%= items_path %> %></p>
7
+ <%- end -%>
@@ -0,0 +1,25 @@
1
+ <%% title "<%= singular_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <strong><%= attribute.human_name.titleize %>:</strong>
6
+ <%%= @<%= instance_name %>.<%= attribute.name %> %>
7
+ </p>
8
+ <%- end -%>
9
+ <%- for nolot in @nolot.identifying_constraint_objects.no_lots -%>
10
+ <p>
11
+ <strong><%= attribute_nameify get_class_name(nolot) %>:</strong>
12
+ <%%= @<%= instance_name %>.<%= attribute_nameify get_class_name(nolot) %>.textualize %>
13
+ </p>
14
+ <%- end -%>
15
+ <p>
16
+ <%- if action? :edit -%>
17
+ <%%= link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %> %> |
18
+ <%- end -%>
19
+ <%- if action? :destroy -%>
20
+ <%%= link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete %> |
21
+ <%- end -%>
22
+ <%- if action? :index -%>
23
+ <%%= link_to "View All", <%= items_path %> %>
24
+ <%- end -%>
25
+ </p>
@@ -0,0 +1,9 @@
1
+ = form_for <%= item_path :instance_variable => true %> do |f|
2
+ = f.error_messages
3
+ <%- for attribute in model_attributes -%>
4
+ .field
5
+ = f.label :<%= attribute.name %>
6
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
7
+ <%- end -%>
8
+ .actions
9
+ = f.submit
@@ -0,0 +1,14 @@
1
+ - title "Edit <%= singular_name.titleize %>"
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if actions? :show, :index -%>
6
+ %p
7
+ <%- if action? :show -%>
8
+ = link_to "Show", <%= item_path :instance_variable => true %>
9
+ |
10
+ <%- end -%>
11
+ <%- if action? :index -%>
12
+ = link_to "View All", <%= items_path %>
13
+ <%- end -%>
14
+ <%- end -%>
@@ -0,0 +1,25 @@
1
+ - title "<%= plural_name.titleize %>"
2
+
3
+ %table
4
+ %tr
5
+ <%- for attribute in model_attributes -%>
6
+ %th <%= attribute.human_name %>
7
+ <%- end -%>
8
+ - for <%= instance_name %> in @<%= instances_name %>
9
+ %tr
10
+ <%- for attribute in model_attributes -%>
11
+ %td= <%= instance_name %>.<%= attribute.name %>
12
+ <%- end -%>
13
+ <%- if action? :show -%>
14
+ %td= link_to 'Show', <%= item_path %>
15
+ <%- end -%>
16
+ <%- if action? :edit -%>
17
+ %td= link_to 'Edit', <%= item_path :action => :edit %>
18
+ <%- end -%>
19
+ <%- if action? :destroy -%>
20
+ %td= link_to 'Destroy', <%= item_path %>, :confirm => 'Are you sure?', :method => :delete
21
+ <%- end -%>
22
+
23
+ <%- if actions? :new -%>
24
+ %p= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %>
25
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ - title "New <%= singular_name.titleize %>"
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if action? :index -%>
6
+ %p= link_to "Back to List", <%= items_path %>
7
+ <%- end -%>
@@ -0,0 +1,20 @@
1
+ - title "<%= singular_name.titleize %>"
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ %p
5
+ %strong <%= attribute.human_name.titleize %>:
6
+ = @<%= instance_name %>.<%= attribute.name %>
7
+ <%- end -%>
8
+
9
+ %p
10
+ <%- if action? :edit -%>
11
+ = link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %>
12
+ |
13
+ <%- end -%>
14
+ <%- if action? :destroy -%>
15
+ = link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete
16
+ |
17
+ <%- end -%>
18
+ <%- if action? :index -%>
19
+ = link_to "View All", <%= items_path %>
20
+ <%- end -%>
@@ -0,0 +1,18 @@
1
+ Description:
2
+ The nifty_layout generator creates a basic layout, stylesheet and
3
+ helper which will give some structure to a starting Rails app.
4
+
5
+ The generator takes one argument which will be the name of the
6
+ layout and stylesheet files. If no argument is passed then it defaults
7
+ to "application".
8
+
9
+ The helper module includes some methods which can be called in any
10
+ template or partial to set variables to be used in the layout, such as
11
+ page title and javascript/stylesheet includes.
12
+
13
+ Examples:
14
+ rails generate tripper:layout
15
+
16
+ Layout: app/views/layouts/application.html.erb
17
+ Stylesheet: public/stylesheets/application.css
18
+ Helper: app/helpers/layout_helper.rb
@@ -0,0 +1,29 @@
1
+ require 'generators/tripper'
2
+
3
+ module Tripper
4
+ module Generators
5
+ class LayoutGenerator < Base
6
+ argument :layout_name, :type => :string, :default => 'application', :banner => 'layout_name'
7
+
8
+ class_option :haml, :desc => 'Generate HAML for view, and SASS for stylesheet.', :type => :boolean
9
+
10
+ def create_layout
11
+ if options.haml?
12
+ template 'layout.html.haml', "app/views/layouts/#{file_name}.html.haml"
13
+ copy_file 'stylesheet.sass', "public/stylesheets/sass/#{file_name}.sass"
14
+ else
15
+ template 'layout.html.erb', "app/views/layouts/#{file_name}.html.erb"
16
+ copy_file 'stylesheet.css', "public/stylesheets/#{file_name}.css"
17
+ end
18
+ copy_file 'layout_helper.rb', 'app/helpers/layout_helper.rb'
19
+ copy_file 'error_messages_helper.rb', 'app/helpers/error_messages_helper.rb'
20
+ end
21
+
22
+ private
23
+
24
+ def file_name
25
+ layout_name.underscore
26
+ end
27
+ end
28
+ end
29
+ end