miracle_generators 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/Manifest +20 -0
- data/README.textile +13 -0
- data/Rakefile +13 -0
- data/lib/miracle_generators.rb +2 -0
- data/miracle_generators.gemspec +30 -0
- data/rails_generators/miracle_scaffold/USAGE +38 -0
- data/rails_generators/miracle_scaffold/miracle_scaffold_generator.rb +96 -0
- data/rails_generators/miracle_scaffold/templates/controller.rb +51 -0
- data/rails_generators/miracle_scaffold/templates/helper.rb +2 -0
- data/rails_generators/miracle_scaffold/templates/migration.rb +14 -0
- data/rails_generators/miracle_scaffold/templates/model.rb +2 -0
- data/rails_generators/miracle_scaffold/templates/test/controller.rb +160 -0
- data/rails_generators/miracle_scaffold/templates/test/model.rb +4 -0
- data/rails_generators/miracle_scaffold/templates/views/_form.html.erb +11 -0
- data/rails_generators/miracle_scaffold/templates/views/edit.html.erb +7 -0
- data/rails_generators/miracle_scaffold/templates/views/index.html.erb +28 -0
- data/rails_generators/miracle_scaffold/templates/views/new.html.erb +7 -0
- data/rails_generators/miracle_scaffold/templates/views/show.html.erb +14 -0
- data/tasks/deployment.rake +2 -0
- metadata +82 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Mark Dodwell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
LICENSE
|
2
|
+
Manifest
|
3
|
+
README.textile
|
4
|
+
Rakefile
|
5
|
+
lib/miracle_generators.rb
|
6
|
+
miracle_generators.gemspec
|
7
|
+
rails_generators/miracle_scaffold/USAGE
|
8
|
+
rails_generators/miracle_scaffold/miracle_scaffold_generator.rb
|
9
|
+
rails_generators/miracle_scaffold/templates/controller.rb
|
10
|
+
rails_generators/miracle_scaffold/templates/helper.rb
|
11
|
+
rails_generators/miracle_scaffold/templates/migration.rb
|
12
|
+
rails_generators/miracle_scaffold/templates/model.rb
|
13
|
+
rails_generators/miracle_scaffold/templates/test/controller.rb
|
14
|
+
rails_generators/miracle_scaffold/templates/test/model.rb
|
15
|
+
rails_generators/miracle_scaffold/templates/views/_form.html.erb
|
16
|
+
rails_generators/miracle_scaffold/templates/views/edit.html.erb
|
17
|
+
rails_generators/miracle_scaffold/templates/views/index.html.erb
|
18
|
+
rails_generators/miracle_scaffold/templates/views/new.html.erb
|
19
|
+
rails_generators/miracle_scaffold/templates/views/show.html.erb
|
20
|
+
tasks/deployment.rake
|
data/README.textile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
h1. Miracle Generators
|
2
|
+
|
3
|
+
A simple Rails scaffold generator.
|
4
|
+
|
5
|
+
NB. Requires formtastic gem, and a helper called 'heading' for capturing the title in the view.
|
6
|
+
|
7
|
+
h2. Install
|
8
|
+
|
9
|
+
gem install miracle_generators
|
10
|
+
|
11
|
+
h2. Usage
|
12
|
+
|
13
|
+
Run `script/generate miracle_scaffold` from your Rails project root for usage instructions.
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('miracle_generators', '0.1.0') do |p|
|
6
|
+
p.description = "Just another RESTful scaffold generator for Rails."
|
7
|
+
p.url = "http://github.com/mkdynamic/miracle_generators"
|
8
|
+
p.author = 'Mark Dodwell'
|
9
|
+
p.email = "apps (at) mkdynamic (dot) co (dot) uk"
|
10
|
+
p.development_dependencies = []
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{miracle_generators}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Mark Dodwell"]
|
9
|
+
s.date = %q{2010-01-17}
|
10
|
+
s.description = %q{Just another RESTful scaffold generator for Rails.}
|
11
|
+
s.email = %q{apps (at) mkdynamic (dot) co (dot) uk}
|
12
|
+
s.extra_rdoc_files = ["LICENSE", "README.textile", "lib/miracle_generators.rb", "tasks/deployment.rake"]
|
13
|
+
s.files = ["LICENSE", "Manifest", "README.textile", "Rakefile", "lib/miracle_generators.rb", "miracle_generators.gemspec", "rails_generators/miracle_scaffold/USAGE", "rails_generators/miracle_scaffold/miracle_scaffold_generator.rb", "rails_generators/miracle_scaffold/templates/controller.rb", "rails_generators/miracle_scaffold/templates/helper.rb", "rails_generators/miracle_scaffold/templates/migration.rb", "rails_generators/miracle_scaffold/templates/model.rb", "rails_generators/miracle_scaffold/templates/test/controller.rb", "rails_generators/miracle_scaffold/templates/test/model.rb", "rails_generators/miracle_scaffold/templates/views/_form.html.erb", "rails_generators/miracle_scaffold/templates/views/edit.html.erb", "rails_generators/miracle_scaffold/templates/views/index.html.erb", "rails_generators/miracle_scaffold/templates/views/new.html.erb", "rails_generators/miracle_scaffold/templates/views/show.html.erb", "tasks/deployment.rake"]
|
14
|
+
s.homepage = %q{http://github.com/mkdynamic/miracle_generators}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Miracle_generators", "--main", "README.textile"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{miracle_generators}
|
18
|
+
s.rubygems_version = %q{1.3.5}
|
19
|
+
s.summary = %q{Just another RESTful scaffold generator for Rails.}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
Description:
|
2
|
+
Scaffolds an entire resource, from model and migration to controller and
|
3
|
+
views. The resource is ready to use as a starting point for your restful,
|
4
|
+
resource-oriented application. Tests are also generated.
|
5
|
+
|
6
|
+
NB. Require formtastic, and generates formtastic code. Also requires a
|
7
|
+
helper method "heading" for capturing/displaying titles for views.
|
8
|
+
|
9
|
+
Usage:
|
10
|
+
Pass the name of the model, either CamelCased or under_scored, as the first
|
11
|
+
argument, and an optional list of attribute pairs.
|
12
|
+
|
13
|
+
IMPORTANT: If no attribute pairs are specified, no model will be generated.
|
14
|
+
It will try to determine the attributes from an existing model.
|
15
|
+
|
16
|
+
Attribute pairs are column_name:sql_type arguments specifying the
|
17
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
18
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
19
|
+
|
20
|
+
For example, `miracle_scaffold post name:string content:text hidden:boolean`
|
21
|
+
gives you a model with those three attributes, a controller that handles
|
22
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
23
|
+
an index that lists them all, as well as a map.resources :posts
|
24
|
+
declaration in config/routes.rb.
|
25
|
+
|
26
|
+
If you pass --skip-tests=true, the tests will be omitted.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
script/generate miracle_scaffold post
|
30
|
+
|
31
|
+
Will create a restful controller called "posts" along with the views.
|
32
|
+
A model will NOT be created, instead it will look for an existing
|
33
|
+
model and use those attributes.
|
34
|
+
|
35
|
+
script/generate miracle_scaffold post name:string content:text
|
36
|
+
|
37
|
+
Will create a Post model and migration file with the name and content
|
38
|
+
attributes. It will also create a restful controller with views.
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class MiracleScaffoldGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
attr_accessor :name, :attributes
|
4
|
+
|
5
|
+
def initialize(runtime_args, runtime_options = {})
|
6
|
+
super
|
7
|
+
usage if @args.empty?
|
8
|
+
|
9
|
+
@name = @args.first
|
10
|
+
|
11
|
+
@attributes = []
|
12
|
+
@args[1..-1].each do |arg|
|
13
|
+
@attributes << Rails::Generator::GeneratedAttribute.new(*arg.split(":"))
|
14
|
+
end
|
15
|
+
@attributes.uniq!
|
16
|
+
|
17
|
+
if @attributes.empty?
|
18
|
+
options[:skip_model] = true
|
19
|
+
if model_exists?
|
20
|
+
model_columns_for_attributes.each do |column|
|
21
|
+
@attributes << Rails::Generator::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
@attributes << Rails::Generator::GeneratedAttribute.new('name', 'string')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def manifest
|
30
|
+
record do |m|
|
31
|
+
# Model
|
32
|
+
unless options[:skip_model]
|
33
|
+
m.directory "app/models"
|
34
|
+
m.template "model.rb", "app/models/#{singular_name}.rb"
|
35
|
+
m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{plural_name}"
|
36
|
+
unless options[:skip_tests]
|
37
|
+
m.directory "test/unit"
|
38
|
+
m.template "test/model.rb", "test/unit/#{singular_name}_test.rb"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Controller
|
43
|
+
m.directory "app/controllers"
|
44
|
+
m.template "controller.rb", "app/controllers/#{plural_name}_controller.rb"
|
45
|
+
unless options[:skip_tests]
|
46
|
+
m.directory "test/functional"
|
47
|
+
m.template "test/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
|
48
|
+
end
|
49
|
+
|
50
|
+
# Helper
|
51
|
+
m.directory "app/helpers"
|
52
|
+
m.template "helper.rb", "app/helpers/#{plural_name}_helper.rb"
|
53
|
+
|
54
|
+
# Views
|
55
|
+
m.directory "app/views/#{plural_name}"
|
56
|
+
m.template "views/index.html.erb", "app/views/#{plural_name}/index.html.erb"
|
57
|
+
m.template "views/show.html.erb", "app/views/#{plural_name}/show.html.erb"
|
58
|
+
m.template "views/new.html.erb", "app/views/#{plural_name}/new.html.erb"
|
59
|
+
m.template "views/edit.html.erb", "app/views/#{plural_name}/edit.html.erb"
|
60
|
+
m.template "views/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
|
61
|
+
|
62
|
+
# Route
|
63
|
+
m.route_resources plural_name
|
64
|
+
|
65
|
+
# Copy migrate to clipboard
|
66
|
+
system "echo 'rake db:migrate && rake db:test:prepare' | pbcopy"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def singular_name
|
71
|
+
name.underscore
|
72
|
+
end
|
73
|
+
|
74
|
+
def plural_name
|
75
|
+
name.underscore.pluralize
|
76
|
+
end
|
77
|
+
|
78
|
+
def class_name
|
79
|
+
name.camelize
|
80
|
+
end
|
81
|
+
|
82
|
+
def plural_class_name
|
83
|
+
plural_name.camelize
|
84
|
+
end
|
85
|
+
|
86
|
+
def model_columns_for_attributes
|
87
|
+
class_name.constantize.columns.reject do |column|
|
88
|
+
column.name.to_s =~ /^(id|created_at|updated_at)$/
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def model_exists?
|
93
|
+
File.exist? destination_path("app/models/#{singular_name}.rb")
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class <%= plural_class_name %>Controller < ApplicationController
|
2
|
+
|
3
|
+
#
|
4
|
+
# RESTful actions
|
5
|
+
#
|
6
|
+
|
7
|
+
def index
|
8
|
+
@<%= plural_name %> = <%= class_name %>.all
|
9
|
+
end
|
10
|
+
|
11
|
+
def show
|
12
|
+
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
13
|
+
end
|
14
|
+
|
15
|
+
def new
|
16
|
+
@<%= singular_name %> = <%= class_name %>.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@<%= singular_name %> = <%= class_name %>.new(params[:<%= singular_name %>])
|
21
|
+
|
22
|
+
if @<%= singular_name %>.save
|
23
|
+
flash[:notice] = "<%= singular_name.titleize %> added successfully."
|
24
|
+
redirect_to <%= plural_name %>_path
|
25
|
+
else
|
26
|
+
render :action => :new
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def edit
|
31
|
+
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
32
|
+
end
|
33
|
+
|
34
|
+
def update
|
35
|
+
@<%= singular_name %> = <%= class_name %>.find(params[:id])
|
36
|
+
|
37
|
+
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
38
|
+
flash[:notice] = "<%= singular_name.titleize %> updated successfully."
|
39
|
+
redirect_to <%= plural_name %>_path
|
40
|
+
else
|
41
|
+
render :action => :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
<%= class_name %>.find(params[:id]).destroy
|
47
|
+
flash[:notice] = "<%= singular_name.titleize %> deleted successfully."
|
48
|
+
redirect_to <%= plural_name %>_path
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Create<%= plural_class_name %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= plural_name %> do |t|
|
4
|
+
<%- for attribute in attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<%- end -%>
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.down
|
12
|
+
drop_table :<%= plural_name %>
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class <%= class_name %>sControllerTest < ActionController::TestCase
|
4
|
+
context "routing" do
|
5
|
+
# index and create
|
6
|
+
should_route :get, "/<%= plural_name %>", :controller => :<%= plural_name %>, :action => :index
|
7
|
+
should_route :post, "/<%= plural_name %>", :controller => :<%= plural_name %>, :action => :create
|
8
|
+
|
9
|
+
# new
|
10
|
+
should_route :get, "/<%= plural_name %>/new", :controller => :<%= plural_name %>, :action => :new
|
11
|
+
|
12
|
+
# edit
|
13
|
+
should_route :get, "/<%= plural_name %>/1/edit", :controller => :<%= plural_name %>, :action => :edit, :id => 1
|
14
|
+
|
15
|
+
# show, update, and delete
|
16
|
+
should_route :get, "/<%= plural_name %>/1", :controller => :<%= plural_name %>, :action => :show, :id => 1
|
17
|
+
should_route :put, "/<%= plural_name %>/1", :controller => :<%= plural_name %>, :action => :update, :id => 1
|
18
|
+
should_route :delete, "/<%= plural_name %>/1", :controller => :<%= plural_name %>, :action => :destroy, :id => 1
|
19
|
+
end
|
20
|
+
|
21
|
+
context "listing" do
|
22
|
+
should "be successful" do
|
23
|
+
get :index
|
24
|
+
assert_response :success
|
25
|
+
end
|
26
|
+
should "assign <%= plural_name %>" do
|
27
|
+
get :index
|
28
|
+
assert_not_nil assigns(:<%= plural_name %>)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "adding" do
|
33
|
+
should "be successful" do
|
34
|
+
get :new
|
35
|
+
assert_response :success
|
36
|
+
end
|
37
|
+
should "assign <%= singular_name %>" do
|
38
|
+
get :new
|
39
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
40
|
+
end
|
41
|
+
should "create new <%= singular_name.titleize.downcase %>" do
|
42
|
+
get :new
|
43
|
+
assert assigns(:<%= singular_name %>).new_record?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "creating" do
|
48
|
+
should "assign <%= singular_name %>" do
|
49
|
+
post :create
|
50
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
51
|
+
end
|
52
|
+
context "when valid" do
|
53
|
+
setup do
|
54
|
+
stub.instance_of(<%= class_name %>).valid? { true }
|
55
|
+
end
|
56
|
+
should "set the flash to success" do
|
57
|
+
post :create
|
58
|
+
assert_match /success/i, flash[:notice]
|
59
|
+
end
|
60
|
+
should "redirect to <%= plural_name.titleize.downcase %> list" do
|
61
|
+
post :create
|
62
|
+
assert_redirected_to <%= plural_name %>_path
|
63
|
+
end
|
64
|
+
end
|
65
|
+
context "when invalid" do
|
66
|
+
setup do
|
67
|
+
stub.instance_of(<%= class_name %>).valid? { false }
|
68
|
+
end
|
69
|
+
should "render new template" do
|
70
|
+
post :create
|
71
|
+
assert_template "new"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "showing" do
|
77
|
+
setup do
|
78
|
+
stub(<%= class_name %>).find { Factory(:<%= singular_name %>) }
|
79
|
+
end
|
80
|
+
should "be successful" do
|
81
|
+
get :show, :id => 1
|
82
|
+
assert_response :success
|
83
|
+
end
|
84
|
+
should "assign <%= singular_name %>" do
|
85
|
+
get :show, :id => 1
|
86
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context "editing" do
|
91
|
+
setup do
|
92
|
+
stub(<%= class_name %>).find { Factory(:<%= singular_name %>) }
|
93
|
+
end
|
94
|
+
should "be successful" do
|
95
|
+
get :edit, :id => 1
|
96
|
+
assert_response :success
|
97
|
+
end
|
98
|
+
should "assign <%= singular_name %>" do
|
99
|
+
get :edit, :id => 1
|
100
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
context "updating" do
|
105
|
+
setup do
|
106
|
+
@<%= singular_name %> = Factory(:<%= singular_name %>)
|
107
|
+
stub(<%= class_name %>).find { @<%= singular_name %> }
|
108
|
+
end
|
109
|
+
should "assign <%= singular_name %>" do
|
110
|
+
put :update, :id => 1
|
111
|
+
assert_not_nil assigns(:<%= singular_name %>)
|
112
|
+
end
|
113
|
+
should "update <%= singular_name.titleize.downcase %>" do
|
114
|
+
mock.proxy(@<%= singular_name %>).update_attributes(anything)
|
115
|
+
put :update, :id => 1
|
116
|
+
end
|
117
|
+
context "when valid" do
|
118
|
+
setup do
|
119
|
+
stub(@<%= singular_name %>).valid? { true }
|
120
|
+
end
|
121
|
+
should "set the flash to success" do
|
122
|
+
put :update, :id => 1
|
123
|
+
assert_match /success/i, flash[:notice]
|
124
|
+
end
|
125
|
+
should "redirect to <%= plural_name.titleize.downcase %> list" do
|
126
|
+
put :update, :id => 1
|
127
|
+
assert_redirected_to <%= plural_name %>_path
|
128
|
+
end
|
129
|
+
end
|
130
|
+
context "when invalid" do
|
131
|
+
setup do
|
132
|
+
stub(@<%= singular_name %>).valid? { false }
|
133
|
+
end
|
134
|
+
should "render new template" do
|
135
|
+
put :update, :id => 1
|
136
|
+
assert_template "edit"
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
context "deleting" do
|
142
|
+
setup do
|
143
|
+
@<%= singular_name %> = Factory(:<%= singular_name %>)
|
144
|
+
stub(<%= class_name %>).find { @<%= singular_name %> }
|
145
|
+
end
|
146
|
+
should "destroy <%= singular_name.titleize.downcase %>" do
|
147
|
+
mock.proxy(@<%= singular_name %>).destroy
|
148
|
+
delete :destroy, :id => 1
|
149
|
+
end
|
150
|
+
should "set flash to success" do
|
151
|
+
delete :destroy, :id => 1
|
152
|
+
assert_match /success/i, flash[:notice]
|
153
|
+
end
|
154
|
+
should "redirect to <%= plural_name.titleize.downcase %> list" do
|
155
|
+
delete :destroy, :id => 1
|
156
|
+
assert_redirected_to <%= plural_name %>_path
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%% semantic_form_for @<%= singular_name %> do |form| %>
|
2
|
+
<%%= form.error_messages %>
|
3
|
+
|
4
|
+
<%% form.inputs do %>
|
5
|
+
<%- for attribute in attributes -%>
|
6
|
+
<%%= form.input :<%= attribute.name %> %>
|
7
|
+
<%- end -%>
|
8
|
+
<%% end %>
|
9
|
+
|
10
|
+
<%%= form.buttons %>
|
11
|
+
<%% end %>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%% heading "<%= plural_name.titleize %>" %>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<%%= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<table class="scaffold">
|
8
|
+
<thead>
|
9
|
+
<tr>
|
10
|
+
<%- for attribute in attributes -%>
|
11
|
+
<th><%= attribute.column.human_name.titleize %></th>
|
12
|
+
<%- end -%>
|
13
|
+
<th colspan="3">Actions</th>
|
14
|
+
</tr>
|
15
|
+
</thead>
|
16
|
+
<tbody id="<%= plural_name %>">
|
17
|
+
<%% for <%= singular_name %> in @<%= plural_name %> %>
|
18
|
+
<tr>
|
19
|
+
<%- for attribute in attributes -%>
|
20
|
+
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
21
|
+
<%- end -%>
|
22
|
+
<td><%%= link_to "Show", <%= singular_name %> %></td>
|
23
|
+
<td><%%= link_to "Edit", edit_<%= singular_name %>_path(<%= singular_name %>) %></td>
|
24
|
+
<td><%%= link_to "Delete", <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
25
|
+
</tr>
|
26
|
+
<%% end %>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<%% heading "Show <%= singular_name.titleize %>" %>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<%%= link_to "← Back", <%= plural_name %>_path %> |
|
5
|
+
<%%= link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>) %> |
|
6
|
+
<%%= link_to "Delete", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %>
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<%- for attribute in attributes -%>
|
10
|
+
<p>
|
11
|
+
<strong><%= attribute.column.human_name.titleize %>:</strong>
|
12
|
+
<%%=h @<%= singular_name %>.<%= attribute.name %> %>
|
13
|
+
</p>
|
14
|
+
<%- end -%>
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: miracle_generators
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mark Dodwell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-01-17 00:00:00 +00:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Just another RESTful scaffold generator for Rails.
|
17
|
+
email: apps (at) mkdynamic (dot) co (dot) uk
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- LICENSE
|
24
|
+
- README.textile
|
25
|
+
- lib/miracle_generators.rb
|
26
|
+
- tasks/deployment.rake
|
27
|
+
files:
|
28
|
+
- LICENSE
|
29
|
+
- Manifest
|
30
|
+
- README.textile
|
31
|
+
- Rakefile
|
32
|
+
- lib/miracle_generators.rb
|
33
|
+
- miracle_generators.gemspec
|
34
|
+
- rails_generators/miracle_scaffold/USAGE
|
35
|
+
- rails_generators/miracle_scaffold/miracle_scaffold_generator.rb
|
36
|
+
- rails_generators/miracle_scaffold/templates/controller.rb
|
37
|
+
- rails_generators/miracle_scaffold/templates/helper.rb
|
38
|
+
- rails_generators/miracle_scaffold/templates/migration.rb
|
39
|
+
- rails_generators/miracle_scaffold/templates/model.rb
|
40
|
+
- rails_generators/miracle_scaffold/templates/test/controller.rb
|
41
|
+
- rails_generators/miracle_scaffold/templates/test/model.rb
|
42
|
+
- rails_generators/miracle_scaffold/templates/views/_form.html.erb
|
43
|
+
- rails_generators/miracle_scaffold/templates/views/edit.html.erb
|
44
|
+
- rails_generators/miracle_scaffold/templates/views/index.html.erb
|
45
|
+
- rails_generators/miracle_scaffold/templates/views/new.html.erb
|
46
|
+
- rails_generators/miracle_scaffold/templates/views/show.html.erb
|
47
|
+
- tasks/deployment.rake
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/mkdynamic/miracle_generators
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --line-numbers
|
55
|
+
- --inline-source
|
56
|
+
- --title
|
57
|
+
- Miracle_generators
|
58
|
+
- --main
|
59
|
+
- README.textile
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: "0"
|
67
|
+
version:
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "1.2"
|
73
|
+
version:
|
74
|
+
requirements: []
|
75
|
+
|
76
|
+
rubyforge_project: miracle_generators
|
77
|
+
rubygems_version: 1.3.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: Just another RESTful scaffold generator for Rails.
|
81
|
+
test_files: []
|
82
|
+
|