jrhicks-static-generators 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
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.3') do |p|
5
+ Echoe.new('static-generators', '0.2.4') 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"
@@ -35,7 +35,11 @@ class GeneratorSpecs < GenSpecFactory
35
35
 
36
36
  def safe_form_groups
37
37
  form_groups.map {|group| {:group_name=>group[:group_name], :attributes=>(group[:attributes]-ascendant_columns-primary_columns)}}
38
- end
38
+ end
39
+
40
+ def safe_table_view_columns
41
+ (table_view_columns - primary_columns - short_name_columns).map {|c| [c,column_specs[c]]}
42
+ end
39
43
 
40
44
  def belongs_to_hash(column_name)
41
45
  belongs_to.select {|bt| bt[:key].to_s==column_name.to_s}.first
@@ -37,7 +37,7 @@ class <%=class_name%>GenSpecs < GeneratorSpecs
37
37
 
38
38
  def short_name_columns
39
39
  # Specify the columns that constitute the "name" for example ["first_name", "last_name"]
40
- <%=guess_short_name.inspect%>
40
+ <%=guess_short_name.map{|c|c.to_sym}.inspect%>
41
41
  end
42
42
 
43
43
  def table_view_columns
@@ -41,7 +41,7 @@ class <%= class_name %> < ActiveRecord::Base
41
41
  end
42
42
 
43
43
  def short_name
44
- name = "<%=gen_spec.short_name_columns.map{|c| "\#{@#{c}}"}.join(" ")%>"
44
+ name = "<%=gen_spec.short_name_columns.map{|c| "\#{#{c}}"}.join(" ")%>"
45
45
  if name==""
46
46
  return "Untitled"
47
47
  else
@@ -2,23 +2,39 @@
2
2
  <h1>Listing <%= gen_spec.plural_title %></h1>
3
3
 
4
4
  <%%=data_table_start <%="#{gen_spec.plural_name}_#{next_count}".inspect%>%>
5
+
5
6
  <tr>
6
7
  <th>&nbsp;</th>
7
- <% for cname in gen_spec.table_view_columns -%>
8
- <% specs = gen_spec.column_specs[cname] -%>
8
+ <% for cname, specs in gen_spec.safe_table_view_columns -%>
9
9
  <th><%= specs[:label]%><%= " (#{specs[:units]})" if specs[:units]%></th>
10
10
  <% end -%>
11
11
  </tr>
12
12
 
13
13
  <%% @<%= gen_spec.plural_name %>.each do |<%= gen_spec.singular_name %>| %>
14
14
  <tr>
15
- <td><%%= link_to <%=gen_spec.singular_name%>.short_name, <%= gen_spec.singular_name %> %> </td>
16
- <% for cname in gen_spec.table_view_columns -%>
17
- <% specs = gen_spec.column_specs[cname] -%>
18
- <td align="<%=specs["align"]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
19
- <% end -%>
15
+ <td><%%= link_to <%=gen_spec.singular_name%>.short_name, <%= gen_spec.singular_name %> %> </td>
16
+ <% for cname, specs in gen_spec.safe_table_view_columns -%>
17
+ <% case specs[:type] -%>
18
+ <% when :file -%>
19
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
20
+ <% when :integer -%>
21
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
22
+ <% when :float -%>
23
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
24
+ <% when :decimal -%>
25
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
26
+ <% when :string -%>
27
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
28
+ <% when :photo -%>
29
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> %></td>
30
+ <% when :foreign_key -%>
31
+ <td align="<%=specs[:align]%>"><%%=(h <%= gen_spec.singular_name %>.<%= gen_spec.belongs_to_name(cname) %>.short_name) if <%= gen_spec.singular_name %>.<%= gen_spec.belongs_to_name(cname) %> -%></td>
32
+ <% when :datetime -%>
33
+ <td align="<%=specs[:align]%>"><%%=h <%= gen_spec.singular_name %>.<%= cname %> -%></td>
34
+ <% end -%><% end -%>
20
35
  </tr>
21
- <%% end %>
36
+ <%% end -%>
37
+
22
38
  <%%=data_table_end <%="#{gen_spec.plural_name}_#{count}".inspect%>%>
23
39
 
24
40
  <br />
@@ -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.3"
5
+ s.version = "0.2.4"
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"]
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.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeffrey Hicks