ava_scaffold_generator 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Masaki Ozawa
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/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = ava_scaffold_generator
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to ava_scaffold_generator
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Masaki Ozawa. See MIT-LICENSE for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,54 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ava_scaffold_generator"
18
+ gem.homepage = "http://github.com/ozamasa/ava_scaffold_generator"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{scaffold generator for avasys}
21
+ gem.description = %Q{scaffold generator for avasys corp.}
22
+ gem.email = "ozamasa123@gmail.com"
23
+ gem.authors = ["Masaki Ozawa"]
24
+ gem.files = Rake::FileList.new('*.rb', '[L-V]*', 'templates/*')
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test
45
+
46
+ require 'rdoc/task'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "ava_scaffold_generator #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('*.rb')
54
+ end
data/USAGE ADDED
@@ -0,0 +1,29 @@
1
+ Description:
2
+ Scaffolds an entire resource, from model and migration to controller and
3
+ views, along with a full test suite. The resource is ready to use as a
4
+ starting point for your RESTful, resource-oriented application.
5
+
6
+ Pass the name of the model (in singular form), either CamelCased or
7
+ under_scored, as the first argument, and an optional list of attribute
8
+ pairs.
9
+
10
+ Attribute pairs are column_name:sql_type arguments specifying the
11
+ model's attributes. Timestamps are added by default, so you don't have to
12
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
13
+
14
+ You don't have to think up every attribute up front, but it helps to
15
+ sketch out a few so you can start working with the resource immediately.
16
+
17
+ For example, 'ava_scaffold post title:string body:text published:boolean'
18
+ gives you a model with those three attributes, a controller that handles
19
+ the create/show/update/destroy, forms to create and edit your posts, and
20
+ an index that lists them all, as well as a map.resources :posts
21
+ declaration in config/routes.rb.
22
+
23
+ If you want to remove all the generated files, run
24
+ 'script/destroy ava_scaffold ModelName'.
25
+
26
+ Examples:
27
+ `./script/generate ava_scaffold post`
28
+ `./script/generate ava_scaffold post title:string body:text published:boolean`
29
+ `./script/generate ava_scaffold purchase order_id:integer amount:decimal`
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.2
@@ -0,0 +1,144 @@
1
+ #-*- encoding:utf-8 -*-
2
+ class AvaScaffoldGenerator < Rails::Generator::NamedBase
3
+ default_options :skip_timestamps => false, :skip_migration => false, :force_plural => false
4
+
5
+ attr_reader :controller_name,
6
+ :controller_class_path,
7
+ :controller_file_path,
8
+ :controller_class_nesting,
9
+ :controller_class_nesting_depth,
10
+ :controller_class_name,
11
+ :controller_underscore_name,
12
+ :controller_singular_name,
13
+ :controller_plural_name
14
+ alias_method :controller_file_name, :controller_underscore_name
15
+ alias_method :controller_table_name, :controller_plural_name
16
+
17
+ def initialize(runtime_args, runtime_options = {})
18
+ super
19
+
20
+ if @name == @name.pluralize && !options[:force_plural]
21
+ logger.warning "Plural version of the model detected, using singularized version. Override with --force-plural."
22
+ @name = @name.singularize
23
+ assign_names!(@name)
24
+ end
25
+
26
+ @controller_name = @name.pluralize
27
+
28
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
29
+ @controller_class_name_without_nesting, @controller_underscore_name, @controller_plural_name = inflect_names(base_name)
30
+ @controller_singular_name=base_name.singularize
31
+ if @controller_class_nesting.empty?
32
+ @controller_class_name = @controller_class_name_without_nesting
33
+ else
34
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
35
+ end
36
+ end
37
+
38
+ def manifest
39
+ record do |m|
40
+ # Check for class naming collisions.
41
+ m.class_collisions("#{controller_class_name}Controller", "#{controller_class_name}Helper")
42
+ m.class_collisions(class_name)
43
+
44
+ # Controller, helper, views, test and stylesheets directories.
45
+ m.directory('app/models')
46
+ m.directory('app/controllers')
47
+ m.directory('app/helpers')
48
+ m.directory(File.join('app/views', controller_file_name))
49
+ m.directory('app/views/layouts')
50
+ m.directory('test/functional')
51
+ m.directory('test/unit')
52
+ m.directory('test/unit/helpers')
53
+ m.directory('public/stylesheets')
54
+
55
+ # Views.
56
+ for action in scaffold_views
57
+ m.template("view_#{action}.html.erb", File.join('app/views', controller_file_name, "#{action}.html.erb"))
58
+ end
59
+
60
+ # Layout and stylesheet.
61
+ m.template('controller.rb', File.join('app/controllers', "#{controller_file_name}_controller.rb"))
62
+ m.template('functional_test.rb', File.join('test/functional', "#{controller_file_name}_controller_test.rb"))
63
+ m.template('helper_test.rb', File.join('test/unit/helpers', "#{controller_file_name}_helper_test.rb"))
64
+
65
+ # routes.rb
66
+ resource = controller_file_name.to_a.map { |r| r.to_sym.inspect }.join(', ')
67
+ f = open("config/routes.rb")
68
+ c = f.read.include?("map.resources #{resource}")
69
+ f.close
70
+ unless c
71
+ m.route_resources controller_file_name
72
+ sentinel = "map.resources #{resource}"
73
+ m.gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
74
+ "#{match}, :collection => {:check => :post}, :member => {:confirm => :put, :edit => :put}"
75
+ end
76
+ end
77
+
78
+ # translation_ja.yml
79
+ filename = "config/locales/translation_ja.yml"
80
+ f = open(filename)
81
+ c = f.read.include?(" #{name}:")
82
+ f.close
83
+ unless c
84
+ sentinel = " models:\n"
85
+ m.gsub_file filename, /(#{Regexp.escape(sentinel)})/mi do |match|
86
+ s = " models:\n #{name}: \"#{name}\"\n"
87
+ match.gsub(match, s)
88
+ end
89
+
90
+ sentinel = " attributes:"
91
+ m.gsub_file filename, /(#{Regexp.escape(sentinel)})/mi do |match|
92
+ s = <<"EOS"
93
+ attributes:
94
+ #{name}:
95
+ EOS
96
+ s += " id: \"ID\"\n"
97
+ for attribute in attributes
98
+ s += " #{attribute.name}: \"#{attribute.name}\"\n"
99
+ end
100
+ match.gsub(match, s)
101
+ end
102
+ end
103
+
104
+ # application_helper.rb
105
+ f = open("app/helpers/application_helper.rb")
106
+ c = f.read.include?("link_to(:#{name}, :controller => :#{name}s)")
107
+ f.close
108
+ unless c
109
+ sentinel = '# str = str + "<li>#{link_to(:top, :controller => :tops)}</li>\n"'
110
+ m.gsub_file 'app/helpers/application_helper.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
111
+ match.gsub(match, sentinel.gsub("top", name).gsub("# ", " ") + "\n" + sentinel)
112
+ end
113
+ end
114
+
115
+ # Model.
116
+ m.dependency 'model', [name] + @args, :collision => :skip
117
+ end
118
+ end
119
+
120
+ protected
121
+ # Override with your own usage banner.
122
+ def banner
123
+ "Usage: #{$0} ava_scaffold ModelName [field:type, field:type]"
124
+ end
125
+
126
+ def add_options!(opt)
127
+ opt.separator ''
128
+ opt.separator 'Options:'
129
+ opt.on("--skip-timestamps",
130
+ "Don't add timestamps to the migration file for this model") { |v| options[:skip_timestamps] = v }
131
+ opt.on("--skip-migration",
132
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
133
+ opt.on("--force-plural",
134
+ "Forces the generation of a plural ModelName") { |v| options[:force_plural] = v }
135
+ end
136
+
137
+ def scaffold_views
138
+ %w[ index show new edit check confirm ]
139
+ end
140
+
141
+ def model_name
142
+ class_name.demodulize
143
+ end
144
+ end
@@ -0,0 +1,119 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ # GET /<%= table_name %>
3
+ # GET /<%= table_name %>.xml
4
+ def index
5
+ @app_search.default 'id', 'desc'
6
+
7
+ <% conditions_l = "" -%>
8
+ <% conditions_r = "" -%>
9
+ <% for attribute in attributes -%>
10
+ @app_search.sort '<%= attribute.name %>', '<%= plural_name %>.<%= attribute.name %>'
11
+ <% conditions_l += "#{plural_name}.#{attribute.name} like ? or " -%>
12
+ <% conditions_r += '@app_search.keyword, ' -%>
13
+ <% end -%>
14
+ <% conditions_l = conditions_l.slice(0, conditions_l.size - 3) -%>
15
+ <% conditions_r = conditions_r.slice(0, conditions_r.size - 2) -%>
16
+
17
+ alls = <%= class_name %>.all(
18
+ # :include => [],
19
+ :conditions => ["<%= conditions_l %>", <%= conditions_r %>],
20
+ :order => @app_search.orderby
21
+ )
22
+ session_set_ids(alls)
23
+ page = alls.paginate(:page => params[:page], :per_page => PAGINATE_PER_PAGE);
24
+ @<%= plural_name %> = page
25
+
26
+ xmls = alls
27
+
28
+ respond_to do |format|
29
+ format.html # index.html.erb
30
+ format.csv { send_data(xmls.to_csv(<%= class_name %>), :type => "text/csv") }
31
+ # format.xml { send_data(xmls.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
32
+ end
33
+ end
34
+
35
+ # GET /<%= table_name %>/1
36
+ # GET /<%= table_name %>/1.xml
37
+ def show
38
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
39
+
40
+ respond_to do |format|
41
+ format.html # show.html.erb
42
+ format.csv { send_data(@<%= file_name %>.to_a.to_csv, :type => "text/csv") }
43
+ # format.xml { send_data(@<%= file_name %>.to_xml, :type => "text/xml; charset=utf8;", :disposition => "attachement") }
44
+ end
45
+ end
46
+
47
+ # GET /<%= table_name %>/new
48
+ # GET /<%= table_name %>/new.xml
49
+ def new
50
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
51
+ end
52
+
53
+ # GET /<%= table_name %>/1/edit
54
+ def edit
55
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
56
+ @<%= file_name %>.attributes = params[:<%= file_name %>]
57
+ end
58
+
59
+ # POST /<%= table_name %>
60
+ # POST /<%= table_name %>.xml
61
+ def check
62
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
63
+ render :action => :new, :status => 400 and return unless @<%= file_name %>.valid?
64
+ end
65
+
66
+ # POST /<%= table_name %>
67
+ # POST /<%= table_name %>.xml
68
+ def create
69
+ begin
70
+ @<%= file_name %> = <%= class_name %>.new(params[:<%= file_name %>])
71
+
72
+ @<%= file_name %>.save!
73
+
74
+ flash[:notice] = t(:success_created, :id => @<%= file_name %>.id)
75
+ redirect_to(<%= table_name %>_url)
76
+ rescue => e
77
+ flash[:error] = t(:error_default, :message => e.message)
78
+ render :action => :new
79
+ end
80
+ end
81
+
82
+ # PUT /<%= table_name %>/1
83
+ # PUT /<%= table_name %>/1.xml
84
+ def confirm
85
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
86
+ @<%= file_name %>.attributes = params[:<%= file_name %>]
87
+ render :action => :edit, :status => 400 and return unless @<%= file_name %>.valid?
88
+ end
89
+
90
+ # PUT /<%= table_name %>/1
91
+ # PUT /<%= table_name %>/1.xml
92
+ def update
93
+ begin
94
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
95
+ @<%= file_name %>.update_attributes(params[:<%= file_name %>])
96
+
97
+ flash[:notice] = t(:success_updated, :id => @<%= file_name %>.id)
98
+ redirect_to(<%= table_name %>_url)
99
+ rescue => e
100
+ flash[:error] = t(:error_default, :message => e.message)
101
+ render :action => :edit
102
+ end
103
+ end
104
+
105
+ # DELETE /<%= table_name %>/1
106
+ # DELETE /<%= table_name %>/1.xml
107
+ def destroy
108
+ begin
109
+ @<%= file_name %> = <%= class_name %>.find(params[:id])
110
+ @<%= file_name %>.destroy
111
+
112
+ flash[:notice] = t(:success_deleted, :id => @<%= file_name %>.id)
113
+ redirect_to(<%= file_name %>s_url)
114
+ rescue => e
115
+ flash[:error] = t(:error_default, :message => e.message)
116
+ render :action => :show
117
+ end
118
+ end
119
+ end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>ControllerTest < ActionController::TestCase
4
+ test "should get index" do
5
+ get :index
6
+ assert_response :success
7
+ assert_not_nil assigns(:<%= table_name %>)
8
+ end
9
+
10
+ test "should get new" do
11
+ get :new
12
+ assert_response :success
13
+ end
14
+
15
+ test "should create <%= file_name %>" do
16
+ assert_difference('<%= class_name %>.count') do
17
+ post :create, :<%= file_name %> => { }
18
+ end
19
+
20
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
21
+ end
22
+
23
+ test "should show <%= file_name %>" do
24
+ get :show, :id => <%= table_name %>(:one).to_param
25
+ assert_response :success
26
+ end
27
+
28
+ test "should get edit" do
29
+ get :edit, :id => <%= table_name %>(:one).to_param
30
+ assert_response :success
31
+ end
32
+
33
+ test "should update <%= file_name %>" do
34
+ put :update, :id => <%= table_name %>(:one).to_param, :<%= file_name %> => { }
35
+ assert_redirected_to <%= file_name %>_path(assigns(:<%= file_name %>))
36
+ end
37
+
38
+ test "should destroy <%= file_name %>" do
39
+ assert_difference('<%= class_name %>.count', -1) do
40
+ delete :destroy, :id => <%= table_name %>(:one).to_param
41
+ end
42
+
43
+ assert_redirected_to <%= table_name %>_path
44
+ end
45
+ end
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= controller_class_name %>HelperTest < ActionView::TestCase
4
+ end
@@ -0,0 +1,58 @@
1
+ <%% form_for(@<%= singular_name %>) do |f| %>
2
+
3
+ <%%= menu %>
4
+ <div id="contents">
5
+ <%%= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%%= message %>
10
+
11
+ <%%= pagetitle :title => "<%= name %>" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%%= flash_tag %>
16
+
17
+ <%% content_for :button do %>
18
+ <div class="commonBtnArea">
19
+ <div class="centerBox">
20
+ <%%= submit_button_tag(f) %>
21
+ <%%= back_button_tag %>
22
+ <%%= index_button_tag %>
23
+ </div>
24
+ <!--/ commonBtnArea--></div>
25
+ <%% end %>
26
+
27
+ <%%#= yield :button %>
28
+
29
+ <%%= pagesubtitle %>
30
+
31
+ <table class="commonSheet">
32
+ <% for attribute in attributes -%>
33
+ <tr>
34
+ <th><%%= f.label :<%= attribute.name %> %></th>
35
+ <td>
36
+ <% if /_id$/ =~ attribute.name -%>
37
+ <%%= hname @<%= singular_name %>.<%= attribute.name.gsub("_id", "") %> %>
38
+ <% elsif attribute.field_type == :date_select -%>
39
+ <%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
40
+ <% elsif attribute.field_type == :text_area -%>
41
+ <%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
42
+ <% else -%>
43
+ <%%= h @<%= singular_name %>.<%= attribute.name %> %>
44
+ <% end -%>
45
+ <%%= f.hidden_field :<%= attribute.name %> %>
46
+ </td>
47
+ </tr>
48
+ <% end -%>
49
+ </table>
50
+
51
+ </div>
52
+
53
+ <%%= yield :button %>
54
+
55
+ <!--/ #main--></div>
56
+ <!--/ #contents--></div>
57
+
58
+ <%% end %>
@@ -0,0 +1,58 @@
1
+ <%% form_for(@<%= singular_name %>) do |f| %>
2
+
3
+ <%%= menu %>
4
+ <div id="contents">
5
+ <%%= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%%= message %>
10
+
11
+ <%%= pagetitle :title => "<%= name %>" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%%= flash_tag %>
16
+
17
+ <%% content_for :button do %>
18
+ <div class="commonBtnArea">
19
+ <div class="centerBox">
20
+ <%%= submit_button_tag(f) %>
21
+ <%%= back_button_tag %>
22
+ <%%= index_button_tag %>
23
+ </div>
24
+ <!--/ commonBtnArea--></div>
25
+ <%% end %>
26
+
27
+ <%%#= yield :button %>
28
+
29
+ <%%= pagesubtitle %>
30
+
31
+ <table class="commonSheet">
32
+ <% for attribute in attributes -%>
33
+ <tr>
34
+ <th><%%= f.label :<%= attribute.name %> %></th>
35
+ <td>
36
+ <% if /_id$/ =~ attribute.name -%>
37
+ <%%= hname @<%= singular_name %>.<%= attribute.name.gsub("_id", "") %> %>
38
+ <% elsif attribute.field_type == :date_select -%>
39
+ <%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
40
+ <% elsif attribute.field_type == :text_area -%>
41
+ <%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
42
+ <% else -%>
43
+ <%%= h @<%= singular_name %>.<%= attribute.name %> %>
44
+ <% end -%>
45
+ <%%= f.hidden_field :<%= attribute.name %> %>
46
+ </td>
47
+ </tr>
48
+ <% end -%>
49
+ </table>
50
+
51
+ </div>
52
+
53
+ <%%= yield :button %>
54
+
55
+ <!--/ #main--></div>
56
+ <!--/ #contents--></div>
57
+
58
+ <%% end %>
@@ -0,0 +1,61 @@
1
+ <%% form_for(@<%= singular_name %>, :url => { :action => :confirm }) do |f| %>
2
+
3
+ <%%= menu %>
4
+ <div id="contents">
5
+ <%%= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%%= message %>
10
+
11
+ <%%= pagetitle :title => "<%= name %>" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%%= f.error_messages %>
16
+ <%%= flash_tag %>
17
+
18
+ <%% content_for :button do %>
19
+ <div class="commonBtnArea">
20
+ <div class="centerBox">
21
+ <%%= submit_button_tag(f) %>
22
+ <%%= index_button_tag %>
23
+ </div>
24
+ <!--/ commonBtnArea--></div>
25
+ <%% end %>
26
+
27
+ <%%#= yield :button %>
28
+
29
+ <%%= pagesubtitle %>
30
+ <%%= required_notice_tag %>
31
+
32
+ <table class="commonSheet">
33
+ <% for attribute in attributes -%>
34
+ <tr>
35
+ <th><%%= f.label :<%= attribute.name %> %></th>
36
+ <td>
37
+ <% if /_id$/ =~ attribute.name -%>
38
+ <%%= f.collection_select(:<%= attribute.name %>, <%= attribute.name.gsub("_id", "").capitalize %>.find(:all), :id, :name, :include_blank => true) %>
39
+ <% elsif attribute.field_type == :text_area -%>
40
+ <%%= f.text_area :<%= attribute.name %>, :size => "60x5" %>
41
+ <% elsif attribute.field_type == :check_box -%>
42
+ <label><%%= f.check_box :<%= attribute.name %> %><%%= f.label :<%= attribute.name %> %></label>
43
+ <% else -%>
44
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
45
+ <% end -%>
46
+ <% if attribute.field_type == :date_select -%>
47
+ <%%= clear_cal_button_tag %>
48
+ <% end -%>
49
+ </td>
50
+ </tr>
51
+ <% end -%>
52
+ </table>
53
+
54
+ </div>
55
+
56
+ <%%= yield :button %>
57
+
58
+ <!--/ #main--></div>
59
+ <!--/ #contents--></div>
60
+
61
+ <%% end %>
@@ -0,0 +1,55 @@
1
+ <%%= menu %>
2
+
3
+ <div id="contents">
4
+ <%%= submenu %>
5
+
6
+ <div id="main">
7
+
8
+ <%%= message %>
9
+
10
+ <%%= pagetitle :title => "<%= name %>" %>
11
+
12
+ <%%= flash_tag %>
13
+
14
+ <div class="commonBtnArea">
15
+ <div class="leftBox">
16
+ <%%= search_tag %>
17
+ </div>
18
+ <div class="rightBox">
19
+ <%%= csv_button_tag %>
20
+ <%%= new_button_tag %>
21
+ </div>
22
+ <!--/ commonBtnArea--></div>
23
+
24
+ <div class="list">
25
+ <%%= will_paginate @<%= plural_name %> %>
26
+ <%%= counter_tag %>
27
+ <table class="commonList">
28
+ <thead>
29
+ <tr>
30
+ <th><%%=hlabel :<%= singular_name %>, :id %><%%= sort_tag('id') %></th>
31
+ <% for attribute in attributes -%>
32
+ <th><%%=hlabel :<%= singular_name %>, :<%= attribute.name %> %><%%= sort_tag('<%= attribute.name %>')%></th>
33
+ <% end -%>
34
+ </tr>
35
+ </thead>
36
+ <tbody>
37
+ <%% @<%= plural_name %>.each do |<%= singular_name %>| %>
38
+ <tr>
39
+ <td><%%=link_to <%= singular_name %>.id, <%= singular_name %> %></td>
40
+ <% for attribute in attributes -%>
41
+ <td><%%=h <%= singular_name %>.<%= attribute.name %> %></td>
42
+ <% end -%>
43
+ </tr>
44
+ <%% end %>
45
+ </tbody>
46
+ </table>
47
+ <!--/ list--></div>
48
+
49
+ <div class="commonBtnArea">
50
+ <div class="centerBox">
51
+ </div>
52
+ <!--/ commonBtnArea--></div>
53
+
54
+ <!--/ #main--></div>
55
+ <!--/ #contents--></div>
@@ -0,0 +1,61 @@
1
+ <%% form_for(@<%= singular_name %>, :url => { :action => :check }, :html => { :method => :post }) do |f| %>
2
+
3
+ <%%= menu %>
4
+ <div id="contents">
5
+ <%%= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%%= message %>
10
+
11
+ <%%= pagetitle :title => "<%= name %>" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%%= f.error_messages %>
16
+ <%%= flash_tag %>
17
+
18
+ <%% content_for :button do %>
19
+ <div class="commonBtnArea">
20
+ <div class="centerBox">
21
+ <%%= submit_button_tag(f) %>
22
+ <%%= index_button_tag %>
23
+ </div>
24
+ <!--/ commonBtnArea--></div>
25
+ <%% end %>
26
+
27
+ <%%#= yield :button %>
28
+
29
+ <%%= pagesubtitle %>
30
+ <%%= required_notice_tag %>
31
+
32
+ <table class="commonSheet">
33
+ <% for attribute in attributes -%>
34
+ <tr>
35
+ <th><%%= f.label :<%= attribute.name %> %></th>
36
+ <td>
37
+ <% if /_id$/ =~ attribute.name -%>
38
+ <%%= f.collection_select(:<%= attribute.name %>, <%= attribute.name.gsub("_id", "").capitalize %>.find(:all), :id, :name, :include_blank => true) %>
39
+ <% elsif attribute.field_type == :text_area -%>
40
+ <%%= f.text_area :<%= attribute.name %>, :size => "60x5" %>
41
+ <% elsif attribute.field_type == :check_box -%>
42
+ <label><%%= f.check_box :<%= attribute.name %> %><%%= f.label :<%= attribute.name %> %></label>
43
+ <% else -%>
44
+ <%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
45
+ <% end -%>
46
+ <% if attribute.field_type == :date_select -%>
47
+ <%%= clear_cal_button_tag %>
48
+ <% end -%>
49
+ </td>
50
+ </tr>
51
+ <% end -%>
52
+ </table>
53
+
54
+ </div>
55
+
56
+ <%%= yield :button %>
57
+
58
+ <!--/ #main--></div>
59
+ <!--/ #contents--></div>
60
+
61
+ <%% end %>
@@ -0,0 +1,62 @@
1
+ <%% form_for(@<%= singular_name %>) do |f| %>
2
+
3
+ <%%= menu %>
4
+ <div id="contents">
5
+ <%%= submenu %>
6
+
7
+ <div id="main">
8
+
9
+ <%%= message %>
10
+
11
+ <%%= pagetitle :title => "<%= name %>" %>
12
+
13
+ <div class="sheet">
14
+
15
+ <%%= flash_tag %>
16
+
17
+ <%% content_for :button do %>
18
+ <div class="commonBtnArea">
19
+ <%%#= prevnext_tag %>
20
+ <div class="centerBox">
21
+ <%%= delete_button_tag(@<%= singular_name %>) %>
22
+ <%%#= copy_button_tag %>
23
+ <%%= edit_button_tag %>
24
+ <%%= index_button_tag %>
25
+ </div>
26
+ <!--/ commonBtnArea--></div>
27
+ <%% end %>
28
+
29
+ <%%#= yield :button %>
30
+ <div class="commonBtnArea">
31
+ <%%= prevnext_tag %>
32
+ </div>
33
+ <!--/ commonBtnArea--></div>
34
+
35
+ <%%= pagesubtitle %>
36
+
37
+ <table class="commonSheet">
38
+ <% for attribute in attributes -%>
39
+ <tr>
40
+ <th><%%= f.label :<%= attribute.name %> %></th>
41
+ <td>
42
+ <% if attribute.field_type == :date_select -%>
43
+ <%%= hdate @<%= singular_name %>.<%= attribute.name %> %>
44
+ <% elsif attribute.field_type == :text_area -%>
45
+ <%%= hbr @<%= singular_name %>.<%= attribute.name %> %>
46
+ <% else -%>
47
+ <%%= h @<%= singular_name %>.<%= attribute.name %> %>
48
+ <% end -%>
49
+ <%%= f.hidden_field :<%= attribute.name %> %>
50
+ </td>
51
+ </tr>
52
+ <% end -%>
53
+ </table>
54
+
55
+ </div>
56
+
57
+ <%%= yield :button %>
58
+
59
+ <!--/ #main--></div>
60
+ <!--/ #contents--></div>
61
+
62
+ <%% end %>
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ava_scaffold_generator
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - Masaki Ozawa
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-04 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ type: :development
33
+ name: shoulda
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 31
43
+ segments:
44
+ - 3
45
+ - 12
46
+ version: "3.12"
47
+ type: :development
48
+ name: rdoc
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">"
56
+ - !ruby/object:Gem::Version
57
+ hash: 23
58
+ segments:
59
+ - 1
60
+ - 0
61
+ - 0
62
+ version: 1.0.0
63
+ type: :development
64
+ name: bundler
65
+ version_requirements: *id003
66
+ - !ruby/object:Gem::Dependency
67
+ prerelease: false
68
+ requirement: &id004 !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ~>
72
+ - !ruby/object:Gem::Version
73
+ hash: 49
74
+ segments:
75
+ - 1
76
+ - 8
77
+ - 3
78
+ version: 1.8.3
79
+ type: :development
80
+ name: jeweler
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
85
+ none: false
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ hash: 3
90
+ segments:
91
+ - 0
92
+ version: "0"
93
+ type: :development
94
+ name: rcov
95
+ version_requirements: *id005
96
+ description: scaffold generator for avasys corp.
97
+ email: ozamasa123@gmail.com
98
+ executables: []
99
+
100
+ extensions: []
101
+
102
+ extra_rdoc_files:
103
+ - README.rdoc
104
+ files:
105
+ - MIT-LICENSE
106
+ - README.rdoc
107
+ - Rakefile
108
+ - USAGE
109
+ - VERSION
110
+ - ava_scaffold_generator.rb
111
+ - templates/controller.rb
112
+ - templates/functional_test.rb
113
+ - templates/helper_test.rb
114
+ - templates/view_check.html.erb
115
+ - templates/view_confirm.html.erb
116
+ - templates/view_edit.html.erb
117
+ - templates/view_index.html.erb
118
+ - templates/view_new.html.erb
119
+ - templates/view_show.html.erb
120
+ has_rdoc: true
121
+ homepage: http://github.com/ozamasa/ava_scaffold_generator
122
+ licenses:
123
+ - MIT
124
+ post_install_message:
125
+ rdoc_options: []
126
+
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ hash: 3
135
+ segments:
136
+ - 0
137
+ version: "0"
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ hash: 3
144
+ segments:
145
+ - 0
146
+ version: "0"
147
+ requirements: []
148
+
149
+ rubyforge_project:
150
+ rubygems_version: 1.4.2
151
+ signing_key:
152
+ specification_version: 3
153
+ summary: scaffold generator for avasys
154
+ test_files: []
155
+