stage 0.3.2 → 0.4.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/History.txt +4 -1
- data/Manifest.txt +0 -1
- data/config/hoe.rb +1 -1
- data/lib/stage/version.rb +2 -2
- data/rails_generators/stage/stage_generator.rb +18 -22
- data/rails_generators/stage/templates/controller.rb +20 -20
- data/rails_generators/stage/templates/migration.rb +4 -4
- data/rails_generators/stage/templates/view_edit.html.erb +2 -2
- data/rails_generators/stage/templates/view_index.html.erb +4 -4
- data/rails_generators/stage/templates/view_new.html.erb +1 -1
- data/rails_generators/stage/templates/view_show.html.erb +2 -2
- data/website/index.html +1 -1
- data/website/merb.html +1 -1
- data/website/rails.html +1 -1
- metadata +4 -5
- data/rails_generators/stage/templates/layout.html.erb +0 -17
data/History.txt
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
== 0.4.0 2008-05-25
|
2
|
+
*Fixed: Support for namespacing in Rails.
|
3
|
+
|
1
4
|
== 0.3.2 2008-04-27
|
2
|
-
* Added route to config/router.rb when generating resource
|
5
|
+
* Merb: Added route to config/router.rb when generating resource
|
3
6
|
|
4
7
|
== 0.3.1 2008-04-26
|
5
8
|
* Removed unnecessary local paramater usage in show.
|
data/Manifest.txt
CHANGED
@@ -25,7 +25,6 @@ rails_generators/stage/templates/controller.rb
|
|
25
25
|
rails_generators/stage/templates/data_partial.html.erb
|
26
26
|
rails_generators/stage/templates/form_partial.html.erb
|
27
27
|
rails_generators/stage/templates/helper.rb
|
28
|
-
rails_generators/stage/templates/layout.html.erb
|
29
28
|
rails_generators/stage/templates/migration.rb
|
30
29
|
rails_generators/stage/templates/model.rb
|
31
30
|
rails_generators/stage/templates/view_edit.html.erb
|
data/config/hoe.rb
CHANGED
@@ -2,7 +2,7 @@ require 'stage/version'
|
|
2
2
|
|
3
3
|
AUTHOR = 'Andrew Stone' # can also be an array of Authors
|
4
4
|
EMAIL = "andy@stonean.com"
|
5
|
-
DESCRIPTION = "Code template generator that utilizes helpers as presenters"
|
5
|
+
DESCRIPTION = "Code template generator for Rails and Merb that DRYs up view code with partials and utilizes helpers as presenters to reduce ruby code in your view."
|
6
6
|
GEM_NAME = 'stage' # what ppl will type to install your gem
|
7
7
|
RUBYFORGE_PROJECT = 'stage' # The unix name for your project
|
8
8
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
data/lib/stage/version.rb
CHANGED
@@ -1,36 +1,33 @@
|
|
1
1
|
class StageGenerator < Rails::Generator::NamedBase
|
2
2
|
default_options :skip_timestamps => false, :skip_migration => false, :skip_fixture => true
|
3
3
|
|
4
|
-
attr_reader
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
:singular_title_name,
|
14
|
-
:plural_title_name
|
4
|
+
attr_reader :controller_class_path,
|
5
|
+
:controller_class_name,
|
6
|
+
:controller_underscore_name,
|
7
|
+
:controller_plural_name,
|
8
|
+
:singular_title_name,
|
9
|
+
:plural_title_name,
|
10
|
+
:singular_route_method,
|
11
|
+
:plural_route_method
|
12
|
+
|
15
13
|
alias_method :controller_file_name, :controller_underscore_name
|
16
14
|
alias_method :controller_table_name, :controller_plural_name
|
17
15
|
|
18
16
|
def initialize(runtime_args, runtime_options = {})
|
19
17
|
super
|
20
|
-
|
21
|
-
@
|
22
|
-
|
23
|
-
|
24
|
-
@controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
|
25
|
-
@controller_singular_name= base_name.singularize
|
26
|
-
if @controller_class_nesting.empty?
|
18
|
+
base_name, @controller_class_path, controller_file_path, controller_class_nesting, controller_class_nesting_depth = extract_modules(@name.pluralize)
|
19
|
+
@controller_class_name_without_nesting, @controller_underscore_name, controller_plural_name = inflect_names(base_name)
|
20
|
+
controller_singular_name= base_name.singularize
|
21
|
+
if controller_class_nesting.empty?
|
27
22
|
@controller_class_name = @controller_class_name_without_nesting
|
28
23
|
else
|
29
|
-
@controller_class_name = "#{
|
24
|
+
@controller_class_name = "#{controller_class_nesting}::#{@controller_class_name_without_nesting}"
|
30
25
|
end
|
31
26
|
|
32
|
-
@singular_title_name =
|
33
|
-
@plural_title_name =
|
27
|
+
@singular_title_name = controller_singular_name.humanize
|
28
|
+
@plural_title_name = controller_plural_name.humanize
|
29
|
+
@singular_route_method = "#{@name.gsub("::", "_")}_path"
|
30
|
+
@plural_route_method = "#{@name.gsub("::", "_").pluralize}_path"
|
34
31
|
end
|
35
32
|
|
36
33
|
def manifest
|
@@ -44,7 +41,6 @@ class StageGenerator < Rails::Generator::NamedBase
|
|
44
41
|
m.directory(File.join("app","controllers", controller_class_path))
|
45
42
|
m.directory(File.join("app","helpers", controller_class_path))
|
46
43
|
m.directory(File.join("app","views", controller_class_path, controller_file_name))
|
47
|
-
m.directory(File.join("app","views","layouts", controller_class_path))
|
48
44
|
|
49
45
|
for action in stage_views
|
50
46
|
m.template(
|
@@ -2,54 +2,54 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
2
2
|
# GET /<%= table_name %>
|
3
3
|
# GET /<%= table_name %>.xml
|
4
4
|
def index
|
5
|
-
@<%=
|
5
|
+
@<%= plural_name %> = <%= singular_title_name %>.find(:all)
|
6
6
|
|
7
7
|
respond_to do |format|
|
8
8
|
format.html # index.html.erb
|
9
|
-
format.xml { render :xml => @<%=
|
9
|
+
format.xml { render :xml => @<%= plural_name %> }
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
# GET /<%= table_name %>/1
|
14
14
|
# GET /<%= table_name %>/1.xml
|
15
15
|
def show
|
16
|
-
@<%=
|
16
|
+
@<%= singular_name %> = <%= singular_title_name %>.find(params[:id])
|
17
17
|
|
18
18
|
respond_to do |format|
|
19
19
|
format.html # show.html.erb
|
20
|
-
format.xml { render :xml => @<%=
|
20
|
+
format.xml { render :xml => @<%= singular_name %> }
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
24
|
# GET /<%= table_name %>/new
|
25
25
|
# GET /<%= table_name %>/new.xml
|
26
26
|
def new
|
27
|
-
@<%=
|
27
|
+
@<%= singular_name %> = <%= singular_title_name %>.new
|
28
28
|
|
29
29
|
respond_to do |format|
|
30
30
|
format.html # new.html.erb
|
31
|
-
format.xml { render :xml => @<%=
|
31
|
+
format.xml { render :xml => @<%= singular_name %> }
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
35
|
# GET /<%= table_name %>/1/edit
|
36
36
|
def edit
|
37
|
-
@<%=
|
37
|
+
@<%= singular_name %> = <%= singular_title_name %>.find(params[:id])
|
38
38
|
end
|
39
39
|
|
40
40
|
# POST /<%= table_name %>
|
41
41
|
# POST /<%= table_name %>.xml
|
42
42
|
def create
|
43
|
-
@<%=
|
43
|
+
@<%= singular_name %> = <%= singular_title_name %>.new(params[:<%= singular_name %>])
|
44
44
|
|
45
45
|
respond_to do |format|
|
46
|
-
if @<%=
|
47
|
-
flash[:notice] = '<%=
|
48
|
-
format.html { redirect_to(@<%=
|
49
|
-
format.xml { render :xml => @<%=
|
46
|
+
if @<%= singular_name %>.save
|
47
|
+
flash[:notice] = '<%= singular_title_name %> was successfully created.'
|
48
|
+
format.html { redirect_to(@<%= singular_name %>) }
|
49
|
+
format.xml { render :xml => @<%= singular_name %>, :status => :created, :location => @<%= singular_name %> }
|
50
50
|
else
|
51
51
|
format.html { render :action => "new" }
|
52
|
-
format.xml { render :xml => @<%=
|
52
|
+
format.xml { render :xml => @<%= singular_name %>.errors, :status => :unprocessable_entity }
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -57,16 +57,16 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
57
57
|
# PUT /<%= table_name %>/1
|
58
58
|
# PUT /<%= table_name %>/1.xml
|
59
59
|
def update
|
60
|
-
@<%=
|
60
|
+
@<%= singular_name %> = <%= singular_title_name %>.find(params[:id])
|
61
61
|
|
62
62
|
respond_to do |format|
|
63
|
-
if @<%=
|
64
|
-
flash[:notice] = '<%=
|
65
|
-
format.html { redirect_to(@<%=
|
63
|
+
if @<%= singular_name %>.update_attributes(params[:<%= singular_name %>])
|
64
|
+
flash[:notice] = '<%= singular_title_name %> was successfully updated.'
|
65
|
+
format.html { redirect_to(@<%= singular_name %>) }
|
66
66
|
format.xml { head :ok }
|
67
67
|
else
|
68
68
|
format.html { render :action => "edit" }
|
69
|
-
format.xml { render :xml => @<%=
|
69
|
+
format.xml { render :xml => @<%= singular_name %>.errors, :status => :unprocessable_entity }
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -74,8 +74,8 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
74
74
|
# DELETE /<%= table_name %>/1
|
75
75
|
# DELETE /<%= table_name %>/1.xml
|
76
76
|
def destroy
|
77
|
-
@<%=
|
78
|
-
@<%=
|
77
|
+
@<%= singular_name %> = <%= singular_title_name %>.find(params[:id])
|
78
|
+
@<%= singular_name %>.destroy
|
79
79
|
|
80
80
|
respond_to do |format|
|
81
81
|
format.html { redirect_to(<%= table_name %>_url) }
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class <%= migration_name %> < ActiveRecord::Migration
|
2
2
|
def self.up
|
3
3
|
create_table :<%= table_name %> do |t|
|
4
|
-
|
4
|
+
<% for attribute in attributes -%>
|
5
5
|
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
-
|
7
|
-
|
6
|
+
<% end -%>
|
7
|
+
<% unless options[:skip_timestamps] %>
|
8
8
|
t.timestamps
|
9
|
-
|
9
|
+
<% end -%>
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -2,5 +2,5 @@
|
|
2
2
|
|
3
3
|
<%%= render :partial => "form" %>
|
4
4
|
|
5
|
-
<%%= link_to 'Show',
|
6
|
-
<%%= link_to 'Back', <%=
|
5
|
+
<%%= link_to 'Show', <%= "#{singular_route_method}(@#{singular_name})" %> %> |
|
6
|
+
<%%= link_to 'Back', <%= plural_route_method %> %>
|
@@ -12,13 +12,13 @@
|
|
12
12
|
<% for attribute in attributes -%>
|
13
13
|
<td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
|
14
14
|
<% end -%>
|
15
|
-
<td><%%= link_to 'Show', <%= singular_name %> %></td>
|
16
|
-
<td><%%= link_to 'Edit',
|
17
|
-
<td><%%= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
15
|
+
<td><%%= link_to 'Show', <%= "#{singular_route_method}(#{singular_name})" %> %></td>
|
16
|
+
<td><%%= link_to 'Edit', <%= "edit_#{singular_route_method}(#{singular_name})" %> %></td>
|
17
|
+
<td><%%= link_to 'Destroy', <%= "#{singular_route_method}(#{singular_name})" %>, :confirm => 'Are you sure?', :method => :delete %></td>
|
18
18
|
</tr>
|
19
19
|
<%% end %>
|
20
20
|
</table>
|
21
21
|
|
22
22
|
<br />
|
23
23
|
|
24
|
-
<%%= link_to 'New <%= singular_title_name %>', new_<%=
|
24
|
+
<%%= link_to 'New <%= singular_title_name %>', new_<%= singular_route_method %> %>
|
@@ -1,4 +1,4 @@
|
|
1
1
|
<%%= render :partial => "data" %>
|
2
2
|
|
3
|
-
<%%= link_to 'Edit',
|
4
|
-
<%%= link_to 'Back', <%=
|
3
|
+
<%%= link_to 'Edit', <%= "edit_#{singular_route_method}(@#{singular_name})" %> %> |
|
4
|
+
<%%= link_to 'Back', <%= plural_route_method %> %>
|
data/website/index.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>stage</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/stage"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/stage" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/stage" class="numbers">0.4.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘stage’</h1>
|
39
39
|
|
data/website/merb.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>stage</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/stage"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/stage" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/stage" class="numbers">0.4.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘stage’</h1>
|
39
39
|
|
data/website/rails.html
CHANGED
@@ -33,7 +33,7 @@
|
|
33
33
|
<h1>stage</h1>
|
34
34
|
<div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/stage"; return false'>
|
35
35
|
<p>Get Version</p>
|
36
|
-
<a href="http://rubyforge.org/projects/stage" class="numbers">0.
|
36
|
+
<a href="http://rubyforge.org/projects/stage" class="numbers">0.4.0</a>
|
37
37
|
</div>
|
38
38
|
<h1>→ ‘stage’</h1>
|
39
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Stone
|
@@ -9,11 +9,11 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-05-25 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
16
|
-
description: Code template generator that utilizes helpers as presenters
|
16
|
+
description: Code template generator for Rails and Merb that DRYs up view code with partials and utilizes helpers as presenters to reduce ruby code in your view.
|
17
17
|
email:
|
18
18
|
- andy@stonean.com
|
19
19
|
executables: []
|
@@ -56,7 +56,6 @@ files:
|
|
56
56
|
- rails_generators/stage/templates/data_partial.html.erb
|
57
57
|
- rails_generators/stage/templates/form_partial.html.erb
|
58
58
|
- rails_generators/stage/templates/helper.rb
|
59
|
-
- rails_generators/stage/templates/layout.html.erb
|
60
59
|
- rails_generators/stage/templates/migration.rb
|
61
60
|
- rails_generators/stage/templates/model.rb
|
62
61
|
- rails_generators/stage/templates/view_edit.html.erb
|
@@ -110,7 +109,7 @@ rubyforge_project: stage
|
|
110
109
|
rubygems_version: 1.1.1
|
111
110
|
signing_key:
|
112
111
|
specification_version: 2
|
113
|
-
summary: Code template generator that utilizes helpers as presenters
|
112
|
+
summary: Code template generator for Rails and Merb that DRYs up view code with partials and utilizes helpers as presenters to reduce ruby code in your view.
|
114
113
|
test_files:
|
115
114
|
- test/test_generator_helper.rb
|
116
115
|
- test/test_helper.rb
|
@@ -1,17 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
-
|
4
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
-
<head>
|
6
|
-
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
|
7
|
-
<title><%= controller_class_name %>: <%%= controller.action_name %></title>
|
8
|
-
<%%= stylesheet_link_tag 'scaffold' %>
|
9
|
-
</head>
|
10
|
-
<body>
|
11
|
-
|
12
|
-
<p style="color: green"><%%= flash[:notice] %></p>
|
13
|
-
|
14
|
-
<%%= yield %>
|
15
|
-
|
16
|
-
</body>
|
17
|
-
</html>
|