jrhicks-static-generators 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -34,7 +34,6 @@ rails_generators/static_scaffold/templates/view_show.html.erb
34
34
  rails_generators/static_scaffold/USAGE
35
35
  Rakefile
36
36
  README.md
37
- static-generators.gemspec
38
37
  tasks/deployment.rake
39
38
  TODO
40
39
  USAGE
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('static-generators', '0.2.2') do |p|
5
+ Echoe.new('static-generators', '0.2.3') do |p|
6
6
  p.project = "staticgenerators"
7
7
  p.description = "Generate attractive interfaces that are easy to edit."
8
8
  p.url = "http://github.com/jrhicks/static-scaffolds"
@@ -29,6 +29,26 @@ class GeneratorSpecs < GenSpecFactory
29
29
  end
30
30
  end
31
31
 
32
+ def file_columns
33
+ column_specs.select {|k,v| v[:type]==:file or v[:type]==:photo}
34
+ end
35
+
36
+ def safe_form_groups
37
+ form_groups.map {|group| {:group_name=>group[:group_name], :attributes=>(group[:attributes]-ascendant_columns-primary_columns)}}
38
+ end
39
+
40
+ def belongs_to_hash(column_name)
41
+ belongs_to.select {|bt| bt[:key].to_s==column_name.to_s}.first
42
+ end
43
+
44
+ def belongs_to_name(column_name)
45
+ belongs_to_hash(column_name)[:name]
46
+ end
47
+
48
+ def belongs_to_model(column_name)
49
+ belongs_to_hash(column_name)[:model]
50
+ end
51
+
32
52
  def primary_columns
33
53
  column_specs.keys.select {|k| column_specs[k][:type]==:primary_key }
34
54
  end
@@ -64,8 +84,4 @@ class GeneratorSpecs < GenSpecFactory
64
84
  # <%=model_name.underscore.inspect%>
65
85
  model_name.pluralize.underscore
66
86
  end
67
-
68
-
69
- end
70
-
71
-
87
+ end
@@ -88,14 +88,6 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
88
88
  <%end -%>
89
89
  }
90
90
  end
91
-
92
- def file_columns
93
- column_specs.select {|k,v| v[:type]==:file or v[:type]==:photo}
94
- end
95
-
96
- def safe_form_groups
97
- form_groups.map {|group| {:group_name=>group[:group_name], :attributes=>(group[:attributes]-ascendant_columns-primary_columns)}}
98
- end
99
91
 
100
92
  def belongs_to
101
93
  [
@@ -2,7 +2,13 @@ class <%= controller_class_name %>Controller < ApplicationController
2
2
  # GET /<%= table_name %>
3
3
  # GET /<%= table_name %>.xml
4
4
  def index
5
- @<%= table_name %> = <%= class_name %>.all
5
+ <% if gen_spec.ascendant -%>
6
+ @<%=gen_spec.ascendant[:name]%> = <%=gen_spec.ascendant[:model]%>.find(params["<%=gen_spec.ascendant[:name]%>"])
7
+ @<%=gen_spec.plural_name %> = @<%=gen_spec.ascendant[:name]%>.<%= gen_spec.plural_name %>
8
+ <%else -%>
9
+ @<%=gen_spec.plural_name %> = <%= gen_spec.model_name %>.all
10
+ <%end -%>
11
+
6
12
 
7
13
  respond_to do |format|
8
14
  format.html # index.html.erb
@@ -26,6 +32,13 @@ class <%= controller_class_name %>Controller < ApplicationController
26
32
  def new
27
33
  @<%= file_name %> = <%= class_name %>.new
28
34
 
35
+ <% if gen_spec.belongs_to.length>0 -%>
36
+ # Form drop downs
37
+ <% for bt in gen_spec.belongs_to -%>
38
+ @<%=bt[:name].pluralize%> = <%=bt[:model]%>.all
39
+ <% end -%>
40
+
41
+ <%end -%>
29
42
  respond_to do |format|
30
43
  format.html # new.html.erb
31
44
  format.xml { render :xml => @<%= file_name %> }
@@ -1,6 +1,6 @@
1
1
  class <%= class_name %> < ActiveRecord::Base
2
2
 
3
- <%if gen_spec.file_columns.length>0 -%>
3
+ <%if gen_spec.file_columns and gen_spec.file_columns.length>0 -%>
4
4
  <%for column,options in gen_spec.file_columns -%>
5
5
  <%if options[:access]==:private -%>
6
6
  has_attached_file <%=column.inspect%>,
@@ -21,13 +21,13 @@ class <%= class_name %> < ActiveRecord::Base
21
21
 
22
22
  <%end -%>
23
23
  <%if gen_spec.belongs_to.length>0 -%>
24
- <%for bt in gen_spec.belongs_to.sort {|a,b|a["name"]<=>b["name"]} -%>
24
+ <%for bt in gen_spec.belongs_to -%>
25
25
  belongs_to <%=bt[:name].inspect%>, :class_name=><%=bt[:model].inspect%>, :foreign_key=><%=bt[:key].inspect%>
26
26
  <%end -%>
27
27
 
28
28
  <%end -%>
29
29
  <%if gen_spec.has_many.length>0 -%>
30
- <%for hm in gen_spec.has_many.sort {|a,b|a["name"]<=>b["name"]} -%>
30
+ <%for hm in gen_spec.has_many -%>
31
31
  has_many <%=hm[:name].inspect%>, :class_name=><%=hm[:model].inspect%>, :foreign_key=><%=hm[:key].inspect%>
32
32
  <%end -%>
33
33
 
@@ -21,7 +21,7 @@
21
21
  <% when :string -%>
22
22
  <%%= f.text_field :<%= attribute %> %>
23
23
  <% when :foreign_key -%>
24
- <%%= f.text_field :<%= attribute %> %>
24
+ <%%= collection_select(:<%=gen_spec.singular_name%>, :<%= attribute %>, @<%=gen_spec.belongs_to_name(attribute).pluralize%>, :id, :short_name, options = {:prompt => "- Select a <%=gen_spec.belongs_to_name(attribute).titleize.downcase%>"}, html_options = {}) %>
25
25
  <% when :photo -%>
26
26
  <%%= f.file_field :<%= attribute %> %>
27
27
  <% when :datetime -%>
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{static-generators}
5
- s.version = "0.2.2"
5
+ s.version = "0.2.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeffrey Hicks"]
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.description = %q{Generate attractive interfaces that are easy to edit.}
11
11
  s.email = %q{jrhicks (at) gmail (dot) com}
12
12
  s.extra_rdoc_files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "README.md", "tasks/deployment.rake", "TODO"]
13
- s.files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "rails_generators/static_app/static_app_generator.rb", "rails_generators/static_app/templates/application_helper.rb", "rails_generators/static_app/templates/jquery.js", "rails_generators/static_app/templates/layout.html.erb", "rails_generators/static_app/templates/layout_helper.rb", "rails_generators/static_app/templates/sorttable.js", "rails_generators/static_app/templates/static_style.css", "rails_generators/static_app/templates/uni-form-generic.css", "rails_generators/static_app/templates/uni-form.css", "rails_generators/static_app/templates/uni-form.jquery.js", "rails_generators/static_app/USAGE", "rails_generators/static_authorization/static_authorization_generator.rb", "rails_generators/static_authorization/templates/migration.rb", "rails_generators/static_authorization/USAGE", "rails_generators/static_gen_specs/static_gen_specs_generator.rb", "rails_generators/static_gen_specs/templates/generator_specs.rb", "rails_generators/static_gen_specs/templates/model_gen_specs.rb", "rails_generators/static_gen_specs/USAGE", "rails_generators/static_scaffold/static_scaffold_generator.rb", "rails_generators/static_scaffold/templates/controller.rb", "rails_generators/static_scaffold/templates/functional_test.rb", "rails_generators/static_scaffold/templates/helper.rb", "rails_generators/static_scaffold/templates/helper_test.rb", "rails_generators/static_scaffold/templates/layout.html.erb", "rails_generators/static_scaffold/templates/model.rb", "rails_generators/static_scaffold/templates/paperclip_tokens.rb", "rails_generators/static_scaffold/templates/view_edit.html.erb", "rails_generators/static_scaffold/templates/view_index.html.erb", "rails_generators/static_scaffold/templates/view_new.html.erb", "rails_generators/static_scaffold/templates/view_show.html.erb", "rails_generators/static_scaffold/USAGE", "Rakefile", "README.md", "static-generators.gemspec", "tasks/deployment.rake", "TODO", "USAGE", "Manifest"]
13
+ s.files = ["CHANGELOG", "lib/static_generators.rb", "LICENSE", "rails_generators/static_app/static_app_generator.rb", "rails_generators/static_app/templates/application_helper.rb", "rails_generators/static_app/templates/jquery.js", "rails_generators/static_app/templates/layout.html.erb", "rails_generators/static_app/templates/layout_helper.rb", "rails_generators/static_app/templates/sorttable.js", "rails_generators/static_app/templates/static_style.css", "rails_generators/static_app/templates/uni-form-generic.css", "rails_generators/static_app/templates/uni-form.css", "rails_generators/static_app/templates/uni-form.jquery.js", "rails_generators/static_app/USAGE", "rails_generators/static_authorization/static_authorization_generator.rb", "rails_generators/static_authorization/templates/migration.rb", "rails_generators/static_authorization/USAGE", "rails_generators/static_gen_specs/static_gen_specs_generator.rb", "rails_generators/static_gen_specs/templates/generator_specs.rb", "rails_generators/static_gen_specs/templates/model_gen_specs.rb", "rails_generators/static_gen_specs/USAGE", "rails_generators/static_scaffold/static_scaffold_generator.rb", "rails_generators/static_scaffold/templates/controller.rb", "rails_generators/static_scaffold/templates/functional_test.rb", "rails_generators/static_scaffold/templates/helper.rb", "rails_generators/static_scaffold/templates/helper_test.rb", "rails_generators/static_scaffold/templates/layout.html.erb", "rails_generators/static_scaffold/templates/model.rb", "rails_generators/static_scaffold/templates/paperclip_tokens.rb", "rails_generators/static_scaffold/templates/view_edit.html.erb", "rails_generators/static_scaffold/templates/view_index.html.erb", "rails_generators/static_scaffold/templates/view_new.html.erb", "rails_generators/static_scaffold/templates/view_show.html.erb", "rails_generators/static_scaffold/USAGE", "Rakefile", "README.md", "tasks/deployment.rake", "TODO", "USAGE", "Manifest", "static-generators.gemspec"]
14
14
  s.has_rdoc = true
15
15
  s.homepage = %q{http://github.com/jrhicks/static-scaffolds}
16
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Static-generators", "--main", "README.md"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrhicks-static-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Hicks
@@ -63,11 +63,11 @@ files:
63
63
  - rails_generators/static_scaffold/USAGE
64
64
  - Rakefile
65
65
  - README.md
66
- - static-generators.gemspec
67
66
  - tasks/deployment.rake
68
67
  - TODO
69
68
  - USAGE
70
69
  - Manifest
70
+ - static-generators.gemspec
71
71
  has_rdoc: true
72
72
  homepage: http://github.com/jrhicks/static-scaffolds
73
73
  post_install_message: