nice_scaffold 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +0 -0
- data/Manifest +14 -0
- data/README.rdoc +0 -0
- data/Rakefile +14 -0
- data/generators/nice_scaffold/nice_scaffold_generator.rb +74 -0
- data/generators/nice_scaffold/templates/controller.rb +39 -0
- data/generators/nice_scaffold/templates/model.rb +2 -0
- data/generators/nice_scaffold/templates/views/_form.html.haml.rb +0 -0
- data/generators/nice_scaffold/templates/views/edit.html.haml.rb +4 -0
- data/generators/nice_scaffold/templates/views/index.html.haml.rb +13 -0
- data/generators/nice_scaffold/templates/views/new.html.haml.rb +4 -0
- data/generators/nice_scaffold/templates/views/show.html.haml.rb +0 -0
- data/init.rb +1 -0
- data/lib/nice_scaffold.rb +2 -0
- data/nice_scaffold.gemspec +30 -0
- metadata +89 -0
data/CHANGELOG
ADDED
File without changes
|
data/Manifest
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
CHANGELOG
|
2
|
+
Manifest
|
3
|
+
README.rdoc
|
4
|
+
Rakefile
|
5
|
+
generators/nice_scaffold/nice_scaffold_generator.rb
|
6
|
+
generators/nice_scaffold/templates/controller.rb
|
7
|
+
generators/nice_scaffold/templates/model.rb
|
8
|
+
generators/nice_scaffold/templates/views/_form.html.haml.rb
|
9
|
+
generators/nice_scaffold/templates/views/edit.html.haml.rb
|
10
|
+
generators/nice_scaffold/templates/views/index.html.haml.rb
|
11
|
+
generators/nice_scaffold/templates/views/new.html.haml.rb
|
12
|
+
generators/nice_scaffold/templates/views/show.html.haml.rb
|
13
|
+
init.rb
|
14
|
+
lib/nice_scaffold.rb
|
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('nice_scaffold', '0.0.2') do |p|
|
6
|
+
p.description = "Rails scaffold."
|
7
|
+
p.url = "http://github.com/seeweer/nice_scaffold"
|
8
|
+
p.author = "Artur Małecki"
|
9
|
+
p.email = "seeweer@gmail.com"
|
10
|
+
p.development_dependencies = []
|
11
|
+
end
|
12
|
+
|
13
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
14
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
class NiceScaffoldGenerator < Rails::Generator::NamedBase
|
2
|
+
attr_accessor(
|
3
|
+
:model_class_name,
|
4
|
+
:controller_class_name,
|
5
|
+
:model_name,
|
6
|
+
:controller_name,
|
7
|
+
:namespace
|
8
|
+
)
|
9
|
+
|
10
|
+
def namespace
|
11
|
+
@namespace || []
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(runtime_args, runtime_options = {})
|
15
|
+
super
|
16
|
+
self.model_class_name = class_name
|
17
|
+
self.model_name = file_path
|
18
|
+
self.controller_class_name = class_name.pluralize
|
19
|
+
self.controller_name = plural_name
|
20
|
+
end
|
21
|
+
|
22
|
+
def manifest
|
23
|
+
record do |m|
|
24
|
+
# Controller, helper, views, and test directories.
|
25
|
+
m.directory("app/models")
|
26
|
+
m.directory(File.join("app/controllers", namespace))
|
27
|
+
m.directory(File.join("app/helpers", namespace))
|
28
|
+
m.directory(File.join("app/views", namespace, plural_name))
|
29
|
+
|
30
|
+
# Controller
|
31
|
+
if(has_controller?)
|
32
|
+
m.template("controller.rb", File.join("app/controllers/", namespace, "#{controller_name}_controller.rb"))
|
33
|
+
end
|
34
|
+
|
35
|
+
# Model
|
36
|
+
if(has_model?)
|
37
|
+
m.template("model.rb", "app/models/#{model_name}.rb")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Views
|
41
|
+
if(has_controller?)
|
42
|
+
%w(index show new edit _form).each do |view|
|
43
|
+
m.template(File.join("views", "#{view}.html.haml.rb"), File.join("app/views", namespace, plural_name, "#{view}.html.haml"))
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def has_model?
|
51
|
+
!options[:skip_model]
|
52
|
+
end
|
53
|
+
|
54
|
+
def has_controller?
|
55
|
+
!options[:skip_controller]
|
56
|
+
end
|
57
|
+
|
58
|
+
def has_namespace?
|
59
|
+
!namespace.blank?
|
60
|
+
end
|
61
|
+
|
62
|
+
protected
|
63
|
+
def banner
|
64
|
+
"Usage: #{$0} nice_scaffold ModelName"
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_options!(opt)
|
68
|
+
opt.separator("")
|
69
|
+
opt.separator("Options:")
|
70
|
+
opt.on("--skip-model", "Skip generating model"){ |v| options[:skip_model] = true }
|
71
|
+
opt.on("--skip-controller", "Skip generatint controller"){ |v| options[:skip_controller] = true }
|
72
|
+
opt.on("--admin-namespace", "Specify namespace to Admin"){ |v| self.namespace = ["admin"] }
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
2
|
+
def index
|
3
|
+
@<%= controller_name %> = <%= model_class_name %>.all
|
4
|
+
end
|
5
|
+
|
6
|
+
def show
|
7
|
+
@<%= model_name %> = <%= model_class_name %>.find(params[:id])
|
8
|
+
end
|
9
|
+
|
10
|
+
def new
|
11
|
+
@<%= model_name %> = <%= model_class_name %>.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def create
|
15
|
+
@<%= model_name %> = <%= model_class_name %>.new(params[:<%= model_name %>])
|
16
|
+
@<%= model_name %>.save!
|
17
|
+
redirect_to(<%= controller_name %>_path)
|
18
|
+
rescue ActiveRecord::RecordInvalid
|
19
|
+
render(:action => :new)
|
20
|
+
end
|
21
|
+
|
22
|
+
def edit
|
23
|
+
@<%= model_name %> = <%= model_class_name %>.find(params[:id])
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
@<%= model_name %> = <%= model_class_name %>.find(params[:id])
|
28
|
+
@<%= model_name %>.update_attributes(params[:<%= model_name %>])
|
29
|
+
redirect_to(<%= controller_name %>_path)
|
30
|
+
rescue ActiveRecord::RecordInvalid
|
31
|
+
render(:action => :edit)
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
@<%= model_name %> = <%= model_class_name %>.find(params[:id])
|
36
|
+
@<%= model_name %>.destroy
|
37
|
+
redirect_to(<%= controller_name %>_path)
|
38
|
+
end
|
39
|
+
end
|
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h3 <%= controller_class_name %>
|
2
|
+
|
3
|
+
= link_to("Add <%= model_class_name %>", <%= ["new", namespace, model_name, "path"].flatten.join("_") %>)
|
4
|
+
|
5
|
+
%table
|
6
|
+
%tr
|
7
|
+
%td Options
|
8
|
+
- @<%= controller_name %>.each do |<%= model_name %>|
|
9
|
+
%tr
|
10
|
+
%td
|
11
|
+
= link_to("Edit", <%= ["edit", namespace, model_name, "path(#{model_name})"].flatten.join("_") %>)
|
12
|
+
|
|
13
|
+
= link_to("Destroy", <%= [namespace, model_name, "path(#{model_name})"].flatten.join("_") %>, :method => :delete, :confirm => "Are you sure?")
|
File without changes
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "nice_scaffold"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{nice_scaffold}
|
5
|
+
s.version = "0.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Artur Ma\305\202ecki"]
|
9
|
+
s.date = %q{2010-06-23}
|
10
|
+
s.description = %q{Rails scaffold.}
|
11
|
+
s.email = %q{seeweer@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/nice_scaffold.rb"]
|
13
|
+
s.files = ["CHANGELOG", "Manifest", "README.rdoc", "Rakefile", "generators/nice_scaffold/nice_scaffold_generator.rb", "generators/nice_scaffold/templates/controller.rb", "generators/nice_scaffold/templates/model.rb", "generators/nice_scaffold/templates/views/_form.html.haml.rb", "generators/nice_scaffold/templates/views/edit.html.haml.rb", "generators/nice_scaffold/templates/views/index.html.haml.rb", "generators/nice_scaffold/templates/views/new.html.haml.rb", "generators/nice_scaffold/templates/views/show.html.haml.rb", "init.rb", "lib/nice_scaffold.rb", "nice_scaffold.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/seeweer/nice_scaffold}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Nice_scaffold", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{nice_scaffold}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Rails scaffold.}
|
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::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nice_scaffold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Artur Ma\xC5\x82ecki"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-06-23 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Rails scaffold.
|
23
|
+
email: seeweer@gmail.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- CHANGELOG
|
30
|
+
- README.rdoc
|
31
|
+
- lib/nice_scaffold.rb
|
32
|
+
files:
|
33
|
+
- CHANGELOG
|
34
|
+
- Manifest
|
35
|
+
- README.rdoc
|
36
|
+
- Rakefile
|
37
|
+
- generators/nice_scaffold/nice_scaffold_generator.rb
|
38
|
+
- generators/nice_scaffold/templates/controller.rb
|
39
|
+
- generators/nice_scaffold/templates/model.rb
|
40
|
+
- generators/nice_scaffold/templates/views/_form.html.haml.rb
|
41
|
+
- generators/nice_scaffold/templates/views/edit.html.haml.rb
|
42
|
+
- generators/nice_scaffold/templates/views/index.html.haml.rb
|
43
|
+
- generators/nice_scaffold/templates/views/new.html.haml.rb
|
44
|
+
- generators/nice_scaffold/templates/views/show.html.haml.rb
|
45
|
+
- init.rb
|
46
|
+
- lib/nice_scaffold.rb
|
47
|
+
- nice_scaffold.gemspec
|
48
|
+
has_rdoc: true
|
49
|
+
homepage: http://github.com/seeweer/nice_scaffold
|
50
|
+
licenses: []
|
51
|
+
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options:
|
54
|
+
- --line-numbers
|
55
|
+
- --inline-source
|
56
|
+
- --title
|
57
|
+
- Nice_scaffold
|
58
|
+
- --main
|
59
|
+
- README.rdoc
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 11
|
77
|
+
segments:
|
78
|
+
- 1
|
79
|
+
- 2
|
80
|
+
version: "1.2"
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: nice_scaffold
|
84
|
+
rubygems_version: 1.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Rails scaffold.
|
88
|
+
test_files: []
|
89
|
+
|