cruddler 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/Gemfile +29 -0
  4. data/Gemfile.lock +141 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.textile +173 -0
  7. data/Rakefile +40 -0
  8. data/cruddler.gemspec +23 -0
  9. data/lib/cruddler.rb +33 -0
  10. data/lib/cruddler/controller.rb +186 -0
  11. data/lib/cruddler/crud_actions.rb +118 -0
  12. data/lib/cruddler/engine.rb +28 -0
  13. data/lib/cruddler/path_helpers.rb +100 -0
  14. data/lib/cruddler/version.rb +26 -0
  15. data/lib/generators/cruddler/install/USAGE +8 -0
  16. data/lib/generators/cruddler/install/install_generator.rb +40 -0
  17. data/lib/generators/cruddler/install/templates/application/edit.html.erb +18 -0
  18. data/lib/generators/cruddler/install/templates/application/index.html.erb +13 -0
  19. data/lib/generators/cruddler/install/templates/application/new.html.erb +17 -0
  20. data/lib/generators/cruddler/install/templates/application/show.html.erb +17 -0
  21. data/lib/generators/cruddler/install/templates/cruddler.yml +21 -0
  22. data/lib/tasks/cruddler_tasks.rake +4 -0
  23. data/script/rails +8 -0
  24. data/test/cruddler_test.rb +7 -0
  25. data/test/dummy/README.rdoc +261 -0
  26. data/test/dummy/Rakefile +7 -0
  27. data/test/dummy/app/assets/javascripts/application.js +15 -0
  28. data/test/dummy/app/assets/javascripts/cats.js +2 -0
  29. data/test/dummy/app/assets/javascripts/dogs.js +2 -0
  30. data/test/dummy/app/assets/javascripts/houses.js +2 -0
  31. data/test/dummy/app/assets/javascripts/parasites.js +2 -0
  32. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  33. data/test/dummy/app/assets/stylesheets/cats.css +4 -0
  34. data/test/dummy/app/assets/stylesheets/dogs.css +4 -0
  35. data/test/dummy/app/assets/stylesheets/houses.css +4 -0
  36. data/test/dummy/app/assets/stylesheets/parasites.css +4 -0
  37. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  38. data/test/dummy/app/controllers/application_controller.rb +3 -0
  39. data/test/dummy/app/controllers/cats_controller.rb +7 -0
  40. data/test/dummy/app/controllers/dogs_controller.rb +11 -0
  41. data/test/dummy/app/controllers/houses_controller.rb +6 -0
  42. data/test/dummy/app/controllers/parasites_controller.rb +8 -0
  43. data/test/dummy/app/helpers/application_helper.rb +2 -0
  44. data/test/dummy/app/helpers/cats_helper.rb +2 -0
  45. data/test/dummy/app/helpers/dogs_helper.rb +2 -0
  46. data/test/dummy/app/helpers/houses_helper.rb +2 -0
  47. data/test/dummy/app/helpers/parasites_helper.rb +2 -0
  48. data/test/dummy/app/mailers/.gitkeep +0 -0
  49. data/test/dummy/app/models/.gitkeep +0 -0
  50. data/test/dummy/app/models/cat.rb +4 -0
  51. data/test/dummy/app/models/dog.rb +3 -0
  52. data/test/dummy/app/models/house.rb +5 -0
  53. data/test/dummy/app/models/parasite.rb +3 -0
  54. data/test/dummy/app/views/application/edit.html.erb +18 -0
  55. data/test/dummy/app/views/application/index.html.erb +13 -0
  56. data/test/dummy/app/views/application/new.html.erb +17 -0
  57. data/test/dummy/app/views/application/show.html.erb +17 -0
  58. data/test/dummy/app/views/cats/_form.html.erb +15 -0
  59. data/test/dummy/app/views/cats/_listing.html.erb +23 -0
  60. data/test/dummy/app/views/cats/_show_cat.html.erb +10 -0
  61. data/test/dummy/app/views/dogs/_form.html.erb +21 -0
  62. data/test/dummy/app/views/dogs/_listing.html.erb +23 -0
  63. data/test/dummy/app/views/dogs/_show_dog.html.erb +10 -0
  64. data/test/dummy/app/views/houses/_form.html.erb +25 -0
  65. data/test/dummy/app/views/houses/_listing.html.erb +23 -0
  66. data/test/dummy/app/views/houses/_show_house.html.erb +11 -0
  67. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  68. data/test/dummy/app/views/parasites/_form.html.erb +25 -0
  69. data/test/dummy/app/views/parasites/_listing.html.erb +27 -0
  70. data/test/dummy/app/views/parasites/_show_parasite.html.erb +19 -0
  71. data/test/dummy/bin/bundle +3 -0
  72. data/test/dummy/bin/rails +4 -0
  73. data/test/dummy/bin/rake +4 -0
  74. data/test/dummy/config.ru +4 -0
  75. data/test/dummy/config/application.rb +23 -0
  76. data/test/dummy/config/boot.rb +4 -0
  77. data/test/dummy/config/database.yml +25 -0
  78. data/test/dummy/config/environment.rb +5 -0
  79. data/test/dummy/config/environments/development.rb +29 -0
  80. data/test/dummy/config/environments/production.rb +80 -0
  81. data/test/dummy/config/environments/test.rb +36 -0
  82. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  83. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  84. data/test/dummy/config/initializers/inflections.rb +16 -0
  85. data/test/dummy/config/initializers/mime_types.rb +5 -0
  86. data/test/dummy/config/initializers/secret_token.rb +12 -0
  87. data/test/dummy/config/initializers/session_store.rb +3 -0
  88. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  89. data/test/dummy/config/locales/en.yml +23 -0
  90. data/test/dummy/config/routes.rb +12 -0
  91. data/test/dummy/db/migrate/20120606105838_create_houses.rb +10 -0
  92. data/test/dummy/db/migrate/20120606110003_create_cats.rb +11 -0
  93. data/test/dummy/db/migrate/20120606110348_create_dogs.rb +13 -0
  94. data/test/dummy/db/migrate/20120606175547_create_parasites.rb +12 -0
  95. data/test/dummy/db/schema.rb +53 -0
  96. data/test/dummy/lib/assets/.gitkeep +0 -0
  97. data/test/dummy/log/.gitkeep +0 -0
  98. data/test/dummy/public/404.html +26 -0
  99. data/test/dummy/public/422.html +26 -0
  100. data/test/dummy/public/500.html +25 -0
  101. data/test/dummy/public/favicon.ico +0 -0
  102. data/test/dummy/script/rails +6 -0
  103. data/test/integration/cruddler_integration_test.rb +253 -0
  104. data/test/integration/navigation_test.rb +10 -0
  105. data/test/support/capybara.rb +29 -0
  106. data/test/test_helper.rb +15 -0
  107. metadata +253 -0
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,15 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,7 @@
1
+
2
+ class CatsController < ApplicationController
3
+ cruddler :all,
4
+ nested: 'house',
5
+ index_path: ->(){ house_cats_path(@house) },
6
+ permit_params: [:name]
7
+ end
@@ -0,0 +1,11 @@
1
+
2
+ class DogsController < ApplicationController
3
+ cruddler :all,
4
+ nested: 'house',
5
+ nested_as: 'ref',
6
+ after_create_path: ->(){ house_dogs_path(@house) },
7
+ after_update_path: ->(){ house_dogs_path(@house) },
8
+ after_destroy_path: ->(){ house_dogs_path(@house) },
9
+ permit_params: ->(){ @house.id == 2 ? :name : [] }
10
+
11
+ end
@@ -0,0 +1,6 @@
1
+
2
+ class HousesController < ApplicationController
3
+ cruddler :all do
4
+ params.required(:house).permit(:name, :number)
5
+ end
6
+ end
@@ -0,0 +1,8 @@
1
+
2
+ class ParasitesController < ApplicationController
3
+ cruddler :all,
4
+ nested: ['house', 'cat'],
5
+ index_path: ->(){ house_cat_parasites_path(@house, @cat) },
6
+ permit_params: :all
7
+
8
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CatsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module DogsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module HousesHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ParasitesHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ class Cat < ActiveRecord::Base
2
+ belongs_to :house
3
+ has_many :parasites
4
+ end
@@ -0,0 +1,3 @@
1
+ class Dog < ActiveRecord::Base
2
+ belongs_to :ref, polymorphic: true
3
+ end
@@ -0,0 +1,5 @@
1
+ class House < ActiveRecord::Base
2
+
3
+ has_many :dogs, as: 'ref'
4
+ has_many :cats
5
+ end
@@ -0,0 +1,3 @@
1
+ class Parasite < ActiveRecord::Base
2
+ belongs_to :cat
3
+ end
@@ -0,0 +1,18 @@
1
+ <h1 class="page_title"><%= t(locale_key('edit'), :name => name_for(instance_variable_get("@#{resource_name}"))) %></h1>
2
+
3
+ <%#= render(:partial => "#{resource_name}") %>
4
+ <% begin %>
5
+ <%= render(:partial => "edit_#{resource_name}") %>
6
+ <% rescue ActionView::MissingTemplate => e %>
7
+ <% begin %>
8
+ <%= render(:partial => "form") %>
9
+ <% rescue ActionView::MissingTemplate => e %>
10
+ <% begin %>
11
+ <%= render(:partial => "#{resource_name}") %>
12
+ <% rescue ActionView::MissingTemplate => e %>
13
+ <%= "** No template found, create either 'edit_#{resource_name}', '#{resource_name}', or 'form' partial. **" %>
14
+ <% end %>
15
+ <% end %>
16
+ <% end %>
17
+
18
+ <%= link_to t("cruddler.abort"), current_index_path, :class => 'button' %>
@@ -0,0 +1,13 @@
1
+ <h1 class="page_title"><%= t(locale_key(:index)) %></h1>
2
+
3
+ <% begin %>
4
+ <%= render(:partial => "#{resources_name}") %>
5
+ <% rescue ActionView::MissingTemplate => e %>
6
+ <% begin %>
7
+ <%= render(:partial => "listing") %>
8
+ <% rescue ActionView::MissingTemplate => e %>
9
+ <%= "** No template found, create either 'list_#{resources_name}', '#{resources_name}', or 'listing' partial. **" %>
10
+ <% end %>
11
+ <% end %>
12
+
13
+ <%= link_to t(locale_key(:create)), current_new_path(), :class => 'button' %>
@@ -0,0 +1,17 @@
1
+ <h1 class="page_title"><%= t(locale_key(:new)) %></h1>
2
+
3
+ <% begin %>
4
+ <%= render(:partial => "new_#{resource_name}") %>
5
+ <% rescue ActionView::MissingTemplate => e %>
6
+ <% begin %>
7
+ <%= render(:partial => "form") %>
8
+ <% rescue ActionView::MissingTemplate => e %>
9
+ <% begin %>
10
+ <%= render(:partial => "#{resource_name}") %>
11
+ <% rescue ActionView::MissingTemplate => e %>
12
+ <%= "** No template found, create either 'new_#{resource_name}', '#{resource_name}', or 'form' partial. **" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <%= link_to t("cruddler.abort"), current_index_path, :class => 'button' %>
@@ -0,0 +1,17 @@
1
+ <h1 class="page_title"><%= t("cruddler.show_#{resource_name}") %></h1>
2
+
3
+ <% begin %>
4
+ <%= render(:partial => "show_#{resource_name}") %>
5
+ <% rescue ActionView::MissingTemplate => e %>
6
+ <% begin %>
7
+ <%= render(:partial => "form") %>
8
+ <% rescue ActionView::MissingTemplate => e %>
9
+ <% begin %>
10
+ <%= render(:partial => "#{resource_name}") %>
11
+ <% rescue ActionView::MissingTemplate => e %>
12
+ <%= "** No template found, create either 'show_#{resource_name}', '#{resource_name}', or 'form' partial. **" %>
13
+ <% end %>
14
+ <% end %>
15
+ <% end %>
16
+
17
+ <%= link_to t("cruddler.abort"), current_index_path, :class => 'button' %>
@@ -0,0 +1,15 @@
1
+ <%= simple_form_for [@house, @cat] do |f| %>
2
+ <% if @cat.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@cat.errors.count, "error") %> prohibited this cat from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @cat.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+ <%= f.input :name %>
14
+ <%= f.submit %>
15
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <% if @cats.present? %>
2
+ <table>
3
+ <tr>
4
+ <th>Name</th>
5
+ <th>House</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @cats.each do |cat| %>
12
+ <tr>
13
+ <td><%= cat.name %></td>
14
+ <td><%= cat.house.name %></td>
15
+ <td><%= link_to 'Show', [@house, cat] %></td>
16
+ <td><%= link_to 'Edit', edit_house_cat_path(@house, cat) %></td>
17
+ <td><%= link_to 'Destroy', [@house, cat], confirm: 'Are you sure?', method: :delete %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+ <% else %>
22
+ <p>No Cats</p>
23
+ <% end -%>
@@ -0,0 +1,10 @@
1
+
2
+ <p>
3
+ <b>Name:</b>
4
+ <%= @cat.name %>
5
+ </p>
6
+
7
+ <p>
8
+ <b>House:</b>
9
+ <%= @cat.house.name %>
10
+ </p>
@@ -0,0 +1,21 @@
1
+ <%= form_for([@house, @dog]) do |f| %>
2
+ <% if @dog.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@dog.errors.count, "error") %> prohibited this dog from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @dog.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="actions">
19
+ <%= f.submit %>
20
+ </div>
21
+ <% end %>
@@ -0,0 +1,23 @@
1
+ <% if @dogs.present? %>
2
+ <table>
3
+ <tr>
4
+ <th>Name</th>
5
+ <th>Ref</th>
6
+ <th></th>
7
+ <th></th>
8
+ <th></th>
9
+ </tr>
10
+
11
+ <% @dogs.each do |dog| %>
12
+ <tr>
13
+ <td><%= dog.name %></td>
14
+ <td><%= dog.ref.name %></td>
15
+ <td><%= link_to 'Show', [@house, dog] %></td>
16
+ <td><%= link_to 'Edit', edit_house_dog_path(@house, dog) %></td>
17
+ <td><%= link_to 'Destroy', [@house, dog], confirm: 'Are you sure?', method: :delete %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+ <% else %>
22
+ <p>No Dogs</p>
23
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <p>
2
+ <b>Name:</b>
3
+ <%= @dog.name %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Ref:</b>
8
+ <%= @dog.ref.name %>
9
+ </p>
10
+
@@ -0,0 +1,25 @@
1
+ <%= form_for(@house) do |f| %>
2
+ <% if @house.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@house.errors.count, "error") %> prohibited this house from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @house.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br />
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :number %><br />
20
+ <%= f.number_field :number %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>