kube-rails 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,7 +6,7 @@ module Kube
6
6
  initializer 'kube-rails.setup',
7
7
  :after => 'less-rails.after.load_config_initializers',
8
8
  :group => :all do |app|
9
- app.config.less.paths << File.join(config.root, 'vendor', 'kube')
9
+ app.config.less.paths << File.join(config.root, 'vendor')
10
10
  end
11
11
  end
12
12
  end
@@ -1,5 +1,5 @@
1
1
  module Kube
2
2
  module Rails
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -101,22 +101,6 @@ files:
101
101
  - lib/generators/kube/install/install_generator.rb
102
102
  - lib/generators/kube/install/templates/application.css
103
103
  - lib/generators/kube/install/templates/kube.less
104
- - lib/generators/kube/themed/templates/_form.html.erb
105
- - lib/generators/kube/themed/templates/_form.html.haml
106
- - lib/generators/kube/themed/templates/_form.html.slim
107
- - lib/generators/kube/themed/templates/edit.html.erb
108
- - lib/generators/kube/themed/templates/edit.html.haml
109
- - lib/generators/kube/themed/templates/edit.html.slim
110
- - lib/generators/kube/themed/templates/index.html.erb
111
- - lib/generators/kube/themed/templates/index.html.haml
112
- - lib/generators/kube/themed/templates/index.html.slim
113
- - lib/generators/kube/themed/templates/new.html.erb
114
- - lib/generators/kube/themed/templates/new.html.haml
115
- - lib/generators/kube/themed/templates/new.html.slim
116
- - lib/generators/kube/themed/templates/show.html.erb
117
- - lib/generators/kube/themed/templates/show.html.haml
118
- - lib/generators/kube/themed/templates/show.html.slim
119
- - lib/generators/kube/themed/themed_generator.rb
120
104
  - lib/kube/rails/engine.rb
121
105
  - lib/kube/rails/kube.rb
122
106
  - lib/kube/rails/version.rb
@@ -155,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
139
  version: '0'
156
140
  requirements: []
157
141
  rubyforge_project: kube-rails
158
- rubygems_version: 1.8.23
142
+ rubygems_version: 1.8.24
159
143
  signing_key:
160
144
  specification_version: 3
161
145
  summary: Kube for Rails 3.1 Asset Pipeline
@@ -1,16 +0,0 @@
1
- <%%= form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
2
- <%- columns.each do |column| -%>
3
- <div class="control-group">
4
- <%%= f.label :<%= column.name %>, :class => 'control-label' %>
5
- <div class="controls">
6
- <%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
7
- </div>
8
- </div>
9
- <%- end -%>
10
-
11
- <div class="form-actions">
12
- <%%= f.submit nil, :class => 'btn btn-primary' %>
13
- <%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
14
- <%= controller_routing_path %>_path, :class => 'btn' %>
15
- </div>
16
- <%% end %>
@@ -1,10 +0,0 @@
1
- = form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
2
- <%- columns.each do |column| -%>
3
- .control-group
4
- = f.label :<%= column.name %>, :class => 'control-label'
5
- .controls
6
- = f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
7
- <%- end -%>
8
- .form-actions
9
- = f.submit nil, :class => 'btn btn-primary'
10
- = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
@@ -1,11 +0,0 @@
1
- = form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
2
- <%- columns.each do |column| -%>
3
- .control-group
4
- = f.label :<%= column.name %>, :class => 'control-label'
5
- .controls
6
- = f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>'
7
- <%- end -%>
8
- .form-actions
9
- = f.submit nil, :class => 'btn btn-primary'
10
- '
11
- = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
@@ -1,6 +0,0 @@
1
- <%%- model_class = <%= resource_name.classify %> -%>
2
- <div class="page-header">
3
- <h1><%%=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human,
4
- :default => "Edit #{model_class.model_name.human}") %></h1>
5
- </div>
6
- <%%= render :partial => 'form' %>
@@ -1,4 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- .page-header
3
- %h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
4
- = render :partial => "form"
@@ -1,4 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- div class="page-header"
3
- h1=t '.title', :default => t('helpers.titles.edit', :model => model_class.model_name.human, :default => "Edit #{model_class.model_name.human}")
4
- = render :partial => "form"
@@ -1,40 +0,0 @@
1
- <%%- model_class = <%= resource_name.classify %> -%>
2
- <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
4
- </div>
5
- <table class="table table-striped">
6
- <thead>
7
- <tr>
8
- <th><%%= model_class.human_attribute_name(:id) %></th>
9
- <%- columns.each do |column| -%>
10
- <th><%%= model_class.human_attribute_name(:<%= column.name %>) %></th>
11
- <%- end -%>
12
- <th><%%= model_class.human_attribute_name(:created_at) %></th>
13
- <th><%%=t '.actions', :default => t("helpers.actions") %></th>
14
- </tr>
15
- </thead>
16
- <tbody>
17
- <%% @<%= plural_resource_name %>.each do |<%= resource_name %>| %>
18
- <tr>
19
- <td><%%= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>) %></td>
20
- <%- columns.each do |column| -%>
21
- <td><%%= <%= resource_name %>.<%= column.name %> %></td>
22
- <%- end -%>
23
- <td><%%=l <%= resource_name %>.created_at %></td>
24
- <td>
25
- <%%= link_to t('.edit', :default => t("helpers.links.edit")),
26
- edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini' %>
27
- <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
28
- <%= singular_controller_routing_path %>_path(<%= resource_name %>),
29
- :method => :delete,
30
- :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
31
- :class => 'btn btn-mini btn-danger' %>
32
- </td>
33
- </tr>
34
- <%% end %>
35
- </tbody>
36
- </table>
37
-
38
- <%%= link_to t('.new', :default => t("helpers.links.new")),
39
- new_<%= singular_controller_routing_path %>_path,
40
- :class => 'btn btn-primary' %>
@@ -1,25 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- .page-header
3
- %h1=t '.title', :default => model_class.model_name.human.pluralize
4
- %table.table.table-striped
5
- %thead
6
- %tr
7
- %th= model_class.human_attribute_name(:id)
8
- <%- columns.each do |column| -%>
9
- %th= model_class.human_attribute_name(:<%= column.name %>)
10
- <%- end -%>
11
- %th= model_class.human_attribute_name(:created_at)
12
- %th=t '.actions', :default => t("helpers.actions")
13
- %tbody
14
- - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
- %tr
16
- %td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
- <%- columns.each do |column| -%>
18
- %td= <%= resource_name %>.<%= column.name %>
19
- <%- end -%>
20
- %td=l <%= resource_name %>.created_at
21
- %td
22
- = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini'
23
- = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-mini btn-danger'
24
-
25
- = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
@@ -1,27 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human.pluralize
4
- table class="table table-striped"
5
- thead
6
- tr
7
- th= model_class.human_attribute_name(:id)
8
- <%- columns.each do |column| -%>
9
- th= model_class.human_attribute_name(:<%= column.name %>)
10
- <%- end -%>
11
- th= model_class.human_attribute_name(:created_at)
12
- th=t '.actions', :default => t("helpers.actions")
13
- tbody
14
- - @<%= plural_resource_name %>.each do |<%= resource_name %>|
15
- tr
16
- td= link_to <%= resource_name %>.id, <%= singular_controller_routing_path %>_path(<%= resource_name %>)
17
- <%- columns.each do |column| -%>
18
- td= <%= resource_name %>.<%= column.name %>
19
- <%- end -%>
20
- td=l <%= resource_name %>.created_at
21
- td
22
- = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(<%= resource_name %>), :class => 'btn btn-mini'
23
- '
24
- = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(<%= resource_name %>), :method => :delete, :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-mini btn-danger'
25
-
26
- = link_to t('.new', :default => t("helpers.links.new")), new_<%= singular_controller_routing_path %>_path, :class => 'btn btn-primary'
27
-
@@ -1,6 +0,0 @@
1
- <%%- model_class = <%= resource_name.classify %> -%>
2
- <div class="page-header">
3
- <h1><%%=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human,
4
- :default => "New #{model_class.model_name.human}") %></h1>
5
- </div>
6
- <%%= render :partial => 'form' %>
@@ -1,4 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- .page-header
3
- %h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
4
- = render :partial => "form"
@@ -1,4 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- div class="page-header"
3
- h1=t '.title', :default => t('helpers.titles.new', :model => model_class.model_name.human, :default => "New #{model_class.model_name.human}")
4
- = render :partial => "form"
@@ -1,23 +0,0 @@
1
- <%%- model_class = <%= resource_name.classify %> -%>
2
- <div class="page-header">
3
- <h1><%%=t '.title', :default => model_class.model_name.human %></h1>
4
- </div>
5
-
6
- <dl class="dl-horizontal">
7
- <%- columns.each do |column| -%>
8
- <dt><strong><%%= model_class.human_attribute_name(:<%= column.name %>) %>:</strong></dt>
9
- <dd><%%= @<%= resource_name %>.<%= column.name %> %></dd>
10
- <%- end -%>
11
- </dl>
12
-
13
- <div class="form-actions">
14
- <%%= link_to t('.back', :default => t("helpers.links.back")),
15
- <%= controller_routing_path %>_path, :class => 'btn' %>
16
- <%%= link_to t('.edit', :default => t("helpers.links.edit")),
17
- edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn' %>
18
- <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
19
- <%= singular_controller_routing_path %>_path(@<%= resource_name %>),
20
- :method => 'delete',
21
- :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
22
- :class => 'btn btn-danger' %>
23
- </div>
@@ -1,15 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- .page-header
3
- %h1=t '.title', :default => model_class.model_name.human
4
-
5
- <%- columns.each do |column| -%>
6
- %p
7
- %strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
- %br
9
- = @<%= resource_name %>.<%= column.name %>
10
- <%- end -%>
11
-
12
- .form-actions
13
- = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
14
- = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
15
- = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -1,17 +0,0 @@
1
- - model_class = <%= resource_name.classify %>
2
- div class="page-header"
3
- h1=t '.title', :default => model_class.model_name.human
4
-
5
- <%- columns.each do |column| -%>
6
- p
7
- strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
- br
9
- = @<%= resource_name %>.<%= column.name %>
10
- <%- end -%>
11
-
12
- .form-actions
13
- = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
14
- '
15
- = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
16
- '
17
- = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -1,100 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/generated_attribute'
3
-
4
- module Kube
5
- module Generators
6
- class ThemedGenerator < ::Rails::Generators::Base
7
- source_root File.expand_path('../templates', __FILE__)
8
- argument :controller_path, :type => :string
9
- argument :model_name, :type => :string, :required => false
10
- argument :layout, :type => :string, :default => "application",
11
- :banner => "Specify application layout"
12
-
13
- def initialize(args, *options)
14
- super(args, *options)
15
- initialize_views_variables
16
- end
17
-
18
- def copy_views
19
- generate_views
20
- end
21
-
22
- protected
23
-
24
- def initialize_views_variables
25
- @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
26
- @controller_routing_path = @controller_file_path.gsub(/\//, '_')
27
- @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
28
- @model_name = @model_name.camelize
29
- end
30
-
31
- def controller_routing_path
32
- @controller_routing_path
33
- end
34
-
35
- def singular_controller_routing_path
36
- @controller_routing_path.singularize
37
- end
38
-
39
- def model_name
40
- @model_name
41
- end
42
-
43
- def plural_model_name
44
- @model_name.pluralize
45
- end
46
-
47
- def resource_name
48
- @model_name.demodulize.underscore
49
- end
50
-
51
- def plural_resource_name
52
- resource_name.pluralize
53
- end
54
-
55
- def columns
56
- begin
57
- excluded_column_names = %w[id created_at updated_at]
58
- begin
59
- @model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
60
- rescue ActiveRecord::StatementInvalid => e
61
- say e.message, :red
62
- exit
63
- end
64
- rescue NoMethodError
65
- @model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
66
- end
67
- end
68
-
69
- def extract_modules(name)
70
- modules = name.include?('/') ? name.split('/') : name.split('::')
71
- name = modules.pop
72
- path = modules.map { |m| m.underscore }
73
- file_path = (path + [name.underscore]).join('/')
74
- nesting = modules.map { |m| m.camelize }.join('::')
75
- [name, path, file_path, nesting, modules.size]
76
- end
77
-
78
- def generate_views
79
- views = {
80
- "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
81
- "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
82
- "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
83
- "_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
84
- "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")}
85
- selected_views = views
86
- options.engine == generate_erb(selected_views)
87
- end
88
-
89
- def generate_erb(views)
90
- views.each do |template_name, output_path|
91
- template template_name, output_path
92
- end
93
- end
94
-
95
- def ext
96
- ::Rails.application.config.generators.options[:rails][:template_engine] || :erb
97
- end
98
- end
99
- end
100
- end