cruddler 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/Gemfile +29 -0
- data/Gemfile.lock +141 -0
- data/MIT-LICENSE +20 -0
- data/README.textile +173 -0
- data/Rakefile +40 -0
- data/cruddler.gemspec +23 -0
- data/lib/cruddler.rb +33 -0
- data/lib/cruddler/controller.rb +186 -0
- data/lib/cruddler/crud_actions.rb +118 -0
- data/lib/cruddler/engine.rb +28 -0
- data/lib/cruddler/path_helpers.rb +100 -0
- data/lib/cruddler/version.rb +26 -0
- data/lib/generators/cruddler/install/USAGE +8 -0
- data/lib/generators/cruddler/install/install_generator.rb +40 -0
- data/lib/generators/cruddler/install/templates/application/edit.html.erb +18 -0
- data/lib/generators/cruddler/install/templates/application/index.html.erb +13 -0
- data/lib/generators/cruddler/install/templates/application/new.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/application/show.html.erb +17 -0
- data/lib/generators/cruddler/install/templates/cruddler.yml +21 -0
- data/lib/tasks/cruddler_tasks.rake +4 -0
- data/script/rails +8 -0
- data/test/cruddler_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/cats.js +2 -0
- data/test/dummy/app/assets/javascripts/dogs.js +2 -0
- data/test/dummy/app/assets/javascripts/houses.js +2 -0
- data/test/dummy/app/assets/javascripts/parasites.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/cats.css +4 -0
- data/test/dummy/app/assets/stylesheets/dogs.css +4 -0
- data/test/dummy/app/assets/stylesheets/houses.css +4 -0
- data/test/dummy/app/assets/stylesheets/parasites.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/cats_controller.rb +7 -0
- data/test/dummy/app/controllers/dogs_controller.rb +11 -0
- data/test/dummy/app/controllers/houses_controller.rb +6 -0
- data/test/dummy/app/controllers/parasites_controller.rb +8 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/cats_helper.rb +2 -0
- data/test/dummy/app/helpers/dogs_helper.rb +2 -0
- data/test/dummy/app/helpers/houses_helper.rb +2 -0
- data/test/dummy/app/helpers/parasites_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/models/cat.rb +4 -0
- data/test/dummy/app/models/dog.rb +3 -0
- data/test/dummy/app/models/house.rb +5 -0
- data/test/dummy/app/models/parasite.rb +3 -0
- data/test/dummy/app/views/application/edit.html.erb +18 -0
- data/test/dummy/app/views/application/index.html.erb +13 -0
- data/test/dummy/app/views/application/new.html.erb +17 -0
- data/test/dummy/app/views/application/show.html.erb +17 -0
- data/test/dummy/app/views/cats/_form.html.erb +15 -0
- data/test/dummy/app/views/cats/_listing.html.erb +23 -0
- data/test/dummy/app/views/cats/_show_cat.html.erb +10 -0
- data/test/dummy/app/views/dogs/_form.html.erb +21 -0
- data/test/dummy/app/views/dogs/_listing.html.erb +23 -0
- data/test/dummy/app/views/dogs/_show_dog.html.erb +10 -0
- data/test/dummy/app/views/houses/_form.html.erb +25 -0
- data/test/dummy/app/views/houses/_listing.html.erb +23 -0
- data/test/dummy/app/views/houses/_show_house.html.erb +11 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/parasites/_form.html.erb +25 -0
- data/test/dummy/app/views/parasites/_listing.html.erb +27 -0
- data/test/dummy/app/views/parasites/_show_parasite.html.erb +19 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +12 -0
- data/test/dummy/db/migrate/20120606105838_create_houses.rb +10 -0
- data/test/dummy/db/migrate/20120606110003_create_cats.rb +11 -0
- data/test/dummy/db/migrate/20120606110348_create_dogs.rb +13 -0
- data/test/dummy/db/migrate/20120606175547_create_parasites.rb +12 -0
- data/test/dummy/db/schema.rb +53 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/cruddler_integration_test.rb +253 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/support/capybara.rb +29 -0
- data/test/test_helper.rb +15 -0
- metadata +253 -0
data/test/dummy/Rakefile
ADDED
@@ -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,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,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,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
|
File without changes
|
File without changes
|
@@ -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,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,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 %>
|