thesilverspoon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. data/.gitignore +1 -1
  2. data/.gitignore~ +4 -0
  3. data/Gemfile~ +6 -0
  4. data/lib/integratedscaffold.rb +299 -0
  5. data/lib/integratedscaffold.rb~ +299 -0
  6. data/lib/templates/actions/create.rb +8 -0
  7. data/lib/templates/actions/destroy.rb +5 -0
  8. data/lib/templates/actions/edit.rb +4 -0
  9. data/lib/templates/actions/index.rb +5 -0
  10. data/lib/templates/actions/integrated_view.rb +3 -0
  11. data/lib/templates/actions/new.rb +4 -0
  12. data/lib/templates/actions/parse_save_from_excel.rb +45 -0
  13. data/lib/templates/actions/show.rb +5 -0
  14. data/lib/templates/actions/update.rb +8 -0
  15. data/lib/templates/assets/images/background.jpg +0 -0
  16. data/lib/templates/assets/images/download.png +0 -0
  17. data/lib/templates/assets/images/inner_texture.jpeg +0 -0
  18. data/lib/templates/assets/images/logo.png +0 -0
  19. data/lib/templates/assets/images/new.png +0 -0
  20. data/lib/templates/assets/images/upload.png +0 -0
  21. data/lib/templates/assets/images/welcome_icon_1.png +0 -0
  22. data/lib/templates/assets/images/welcome_icon_2.png +0 -0
  23. data/lib/templates/assets/images/welcome_icon_3.png +0 -0
  24. data/lib/templates/assets/images/welcome_icon_4.png +0 -0
  25. data/lib/templates/assets/images/welcome_image.png +0 -0
  26. data/lib/templates/assets/javascripts/exclusions/fiddletabs.js +233 -0
  27. data/lib/templates/assets/javascripts/exclusions/jquery.mousewheel.min.js +12 -0
  28. data/lib/templates/assets/javascripts/exclusions/jquery.pageslide.js +202 -0
  29. data/lib/templates/assets/javascripts/jquery.dataTables.min.js +2475 -0
  30. data/lib/templates/assets/stylesheets/base_classes.css.scss +107 -0
  31. data/lib/templates/assets/stylesheets/exclusions/fiddletabs.css +77 -0
  32. data/lib/templates/assets/stylesheets/exclusions/images/Sorting icons.psd +0 -0
  33. data/lib/templates/assets/stylesheets/exclusions/images/back_disabled.jpg +0 -0
  34. data/lib/templates/assets/stylesheets/exclusions/images/back_enabled.jpg +0 -0
  35. data/lib/templates/assets/stylesheets/exclusions/images/favicon.ico +0 -0
  36. data/lib/templates/assets/stylesheets/exclusions/images/forward_disabled.jpg +0 -0
  37. data/lib/templates/assets/stylesheets/exclusions/images/forward_enabled.jpg +0 -0
  38. data/lib/templates/assets/stylesheets/exclusions/images/sort_asc.png +0 -0
  39. data/lib/templates/assets/stylesheets/exclusions/images/sort_asc_disabled.png +0 -0
  40. data/lib/templates/assets/stylesheets/exclusions/images/sort_both.png +0 -0
  41. data/lib/templates/assets/stylesheets/exclusions/images/sort_desc.png +0 -0
  42. data/lib/templates/assets/stylesheets/exclusions/images/sort_desc_disabled.png +0 -0
  43. data/lib/templates/assets/stylesheets/exclusions/jquery_data_table.css +513 -0
  44. data/lib/templates/assets/stylesheets/images/Sorting icons.psd +0 -0
  45. data/lib/templates/assets/stylesheets/images/back_disabled.jpg +0 -0
  46. data/lib/templates/assets/stylesheets/images/back_enabled.jpg +0 -0
  47. data/lib/templates/assets/stylesheets/images/favicon.ico +0 -0
  48. data/lib/templates/assets/stylesheets/images/forward_disabled.jpg +0 -0
  49. data/lib/templates/assets/stylesheets/images/forward_enabled.jpg +0 -0
  50. data/lib/templates/assets/stylesheets/images/sort_asc.png +0 -0
  51. data/lib/templates/assets/stylesheets/images/sort_asc_disabled.png +0 -0
  52. data/lib/templates/assets/stylesheets/images/sort_both.png +0 -0
  53. data/lib/templates/assets/stylesheets/images/sort_desc.png +0 -0
  54. data/lib/templates/assets/stylesheets/images/sort_desc_disabled.png +0 -0
  55. data/lib/templates/assets/stylesheets/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  56. data/lib/templates/assets/stylesheets/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  57. data/lib/templates/assets/stylesheets/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  58. data/lib/templates/assets/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  59. data/lib/templates/assets/stylesheets/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  60. data/lib/templates/assets/stylesheets/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  61. data/lib/templates/assets/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  62. data/lib/templates/assets/stylesheets/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  63. data/lib/templates/assets/stylesheets/images/ui-icons_222222_256x240.png +0 -0
  64. data/lib/templates/assets/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
  65. data/lib/templates/assets/stylesheets/images/ui-icons_454545_256x240.png +0 -0
  66. data/lib/templates/assets/stylesheets/images/ui-icons_888888_256x240.png +0 -0
  67. data/lib/templates/assets/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
  68. data/lib/templates/assets/stylesheets/information_page.css.scss +3 -0
  69. data/lib/templates/assets/stylesheets/jquery_data_table.css +513 -0
  70. data/lib/templates/controller.rb +4 -0
  71. data/lib/templates/file_uploader.rb +48 -0
  72. data/lib/templates/helper.rb +2 -0
  73. data/lib/templates/layouts/application.html.erb +69 -0
  74. data/lib/templates/layouts/dummy_data.html.erb +80 -0
  75. data/lib/templates/layouts/information_page.html.erb +81 -0
  76. data/lib/templates/layouts/pageslide_form_at.html.erb +2 -0
  77. data/lib/templates/layouts/welcome.html.erb +71 -0
  78. data/lib/templates/migration.rb +18 -0
  79. data/lib/templates/model.rb +20 -0
  80. data/lib/templates/views/erb/_form.html.erb +37 -0
  81. data/lib/templates/views/erb/edit.html.erb +11 -0
  82. data/lib/templates/views/erb/index.html.erb +29 -0
  83. data/lib/templates/views/erb/integrated_view.html.erb +229 -0
  84. data/lib/templates/views/erb/new.html.erb +11 -0
  85. data/lib/templates/views/erb/show.html.erb +20 -0
  86. data/lib/thesilverspoon.rb~ +302 -0
  87. data/lib/thesilverspoon/version.rb +1 -1
  88. data/lib/thesilverspoon/version.rb~ +3 -0
  89. data/thesilverspoon.gemspec~ +33 -0
  90. metadata +102 -15
@@ -0,0 +1,11 @@
1
+ <br/>
2
+ <br/>
3
+ <br/>
4
+ <div class="pageslide_header">
5
+ <h1 style="color:white;">Edit<br/> <%= singular_name.titleize %></h1>
6
+ </div>
7
+ <br/>
8
+ <br/>
9
+ <div style="text-align: center;">
10
+ <%%= render 'form' %>
11
+ </div>
@@ -0,0 +1,29 @@
1
+ <%% title "<%= plural_name.titleize %>" %>
2
+
3
+ <table>
4
+ <tr>
5
+ <%- for attribute in model_attributes -%>
6
+ <th><%= attribute.human_name.titleize %></th>
7
+ <%- end -%>
8
+ </tr>
9
+ <%% for <%= instance_name %> in @<%= instances_name %> %>
10
+ <tr>
11
+ <%- for attribute in model_attributes -%>
12
+ <td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
13
+ <%- end -%>
14
+ <%- if action? :show -%>
15
+ <td><%%= link_to "Show", <%= item_path %> %></td>
16
+ <%- end -%>
17
+ <%- if action? :edit -%>
18
+ <td><%%= link_to "Edit", <%= item_path :action => :edit %> %></td>
19
+ <%- end -%>
20
+ <%- if action? :destroy -%>
21
+ <td><%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %></td>
22
+ <%- end -%>
23
+ </tr>
24
+ <%% end %>
25
+ </table>
26
+
27
+ <%- if action? :new -%>
28
+ <p><%%= link_to "New <%= singular_name.titleize %>", <%= item_path :action => :new %> %></p>
29
+ <%- end -%>
@@ -0,0 +1,229 @@
1
+ <%%= content_for :head do %>
2
+ <%%= stylesheet_link_tag "/assets/exclusions/jquery_data_table" %>
3
+
4
+ <%# TODO: Move Script and CSS to unobtrusive files %>
5
+ <script type="text/javascript">
6
+ $(function() {
7
+ $('#example').dataTable({
8
+ "bJQueryUI": true,
9
+ "sPaginationType": "full_numbers"
10
+ });
11
+
12
+
13
+ })
14
+ </script>
15
+ <style>
16
+
17
+ tr.odd {
18
+ background-color: #e3f5ac;
19
+ }
20
+
21
+ tr.odd td.sorting_1 {
22
+ background-color: #d7e99f;
23
+ }
24
+
25
+ tr.even {
26
+ background-color: #ffffff;
27
+ }
28
+
29
+ tr.even td.sorting_1 {
30
+ background-color: #f2f2f2;
31
+ }
32
+
33
+ td.options {
34
+ width: 100px;
35
+ background: olive;
36
+ }
37
+
38
+ td.options a {
39
+ color: white;
40
+ }
41
+
42
+ </style>
43
+ <%% end %>
44
+
45
+ <%%= content_for :page_header do %>
46
+ <div class="pull-left" style="border: none;"><%%= image_tag('logo.png') %></div>
47
+ <%% end %>
48
+
49
+ <div class="row">
50
+
51
+ <div class="span4" style="text-align: center">
52
+ <div class="pageslide_header">
53
+ <h1 style="color:white">"<%= plural_name.titleize %>"</h1>
54
+ </div>
55
+ <br/>
56
+ <br/>
57
+ <table>
58
+ <tr>
59
+ <td>
60
+ <a href="#" data-controls-modal="new_form" data-backdrop="static">
61
+ <%%= image_tag('new.png', :size=>"32x32") %>
62
+ </a>
63
+ </td>
64
+ <td>
65
+ <a href="#" data-controls-modal="new_form" data-backdrop="static">
66
+ <h2>Create New</h2>
67
+ </a>
68
+
69
+ <div id="new_form" class="modal hide fade">
70
+ <div class="modal-header">
71
+ <a href="#" class="close"> &times; </a>
72
+
73
+ <h3>Create new record</h3>
74
+ </div>
75
+
76
+ <%%= form_for @<%= instance_name %> do |f| %>
77
+
78
+
79
+ <%% if @<%= instance_name %>.errors.any? %>
80
+ <div id="error_explanation">
81
+ <h2><%%= pluralize(@<%=instance_name %>.errors.count, "error") %> prohibited this <%= instance_name %> from being
82
+ saved:</h2>
83
+
84
+ <ul>
85
+ <%% <%= instance_name %>.errors.full_messages.each do |msg| %>
86
+ <li><%%= msg %></li>
87
+ <%% end %>
88
+ </ul>
89
+ </div>
90
+ <%% end %>
91
+ <table class="condensed-table">
92
+ <%- for attribute in model_attributes -%>
93
+ <tr>
94
+ <td><%%= f.label :<%= attribute.name %> %></td>
95
+
96
+ <%- if attribute.name.match('_id') %>
97
+ <%% if ActiveRecord::Base.connection.table_exists? '<%=attribute.name.split('_')[0].pluralize %>' %>
98
+ <td><%%= f.select :<%= attribute.name %>,<%= attribute.name.split('_')[0].capitalize %>.all.collect{|var|[var.name,var.id]} %></td>
99
+ <%% else %>
100
+ <td><%%= f.select :<%= attribute.name %>,[1,2,3,4,5] %></td>
101
+ <%%end %>
102
+
103
+
104
+ <%else %>
105
+ <td><%%= f.<%= attribute.field_type %> :<%= attribute.name %> %></td>
106
+ <% end %>
107
+
108
+
109
+ </tr>
110
+
111
+ <%- end -%>
112
+ </table>
113
+ <br>
114
+ <br>
115
+
116
+
117
+ <div class="modal-footer">
118
+ <%%= f.submit "Submit", :style=>"margin:auto", :class=>"btn primary large" %>
119
+ </div>
120
+ </div>
121
+
122
+ <%% end %>
123
+ </td>
124
+ </tr>
125
+ <tr>
126
+ <td>
127
+ <a href="#" data-controls-modal="upload_form" data-backdrop="static">
128
+ <%%= image_tag('upload.png', :size=>"32x32") %>
129
+ </a>
130
+ </td>
131
+ <td>
132
+ <a href="#" data-controls-modal="upload_form" data-backdrop="static">
133
+ <h2>Upload</h2>
134
+ </a>
135
+
136
+ <div id="upload_form" class="modal hide fade">
137
+ <div class="modal-header">
138
+ <a href="#" class="close"> &times; </a>
139
+
140
+ <h3>Upload Excel File</h3>
141
+ </div>
142
+ <%%= form_tag('/<%= instance_name %>/parse_save_from_excel', :multipart => true) do |f| %>
143
+ <div class="modal-body">
144
+ Select an Excel File :
145
+ <%%= file_field_tag :excel_file %>
146
+ </div>
147
+
148
+ <div class="modal-footer">
149
+ <%%= submit_tag 'Submit', :class=>"large btn primary pull-left" %>
150
+ </div>
151
+ <%% end -%>
152
+
153
+ </div>
154
+
155
+
156
+ </td>
157
+ </tr>
158
+ <tr>
159
+ <td>
160
+ <a href="<%%=<%= item_path :action => :new %> %>" class="add_new span3">
161
+ <%%= image_tag('download.png', :size=>"32x32") %>
162
+ </a>
163
+ </td>
164
+ <td>
165
+ <a href=" <%%=<%= item_path :action => :new %> %>" class="add_new span3">
166
+ <h2>Download</h2>
167
+ </a>
168
+ </td>
169
+ </tr>
170
+
171
+ </table>
172
+
173
+ </div>
174
+
175
+ <div class="span12">
176
+ <table class="jqueried_table display" cellpadding="0" cellspacing="0" border="0" id="example">
177
+ <thead>
178
+ <tr>
179
+ <%- for attribute in @model_attributes -%>
180
+ <th><%= attribute.human_name.titleize %></th>
181
+ <%- end -%>
182
+ <th>Manage</th>
183
+ </tr>
184
+ </thead>
185
+ <tbody>
186
+ <%% @<%= instances_name %>.each do |<%= instance_name %>| %>
187
+ <tr>
188
+ <%- for attribute in @model_attributes -%>
189
+ <td style="border-right: 1px solid #d3d3d3">
190
+ <a href="#" data-controls-modal="show_details" data-backdrop="static"><%%= <%= instance_name %>
191
+ .<%= attribute.name %> %></a>
192
+ </td>
193
+ <%- end %>
194
+
195
+ <td class="options">
196
+ <%%= link_to "Edit", <%= item_path :action => :edit %> %> |
197
+ <%%= link_to "Destroy", <%= item_path %>, :confirm => 'Are you sure?', :method => :delete %>
198
+ </td>
199
+ </tr>
200
+
201
+
202
+ <div id="show_details" class="modal hide fade">
203
+ <div class="modal-header">
204
+ <a href="#" class="close"> &times; </a>
205
+
206
+ <h3><%%= "<%= singular_name.titleize %>" %></h3>
207
+ </div>
208
+ <div class="modal-body">
209
+ <%- for attribute in model_attributes -%>
210
+ <p>
211
+ <strong><%= attribute.human_name.titleize %>:</strong>
212
+ <%%= <%= instance_name %>.<%= attribute.name %> %>
213
+ </p>
214
+
215
+ <%- end -%>
216
+ </div>
217
+
218
+ <div class="modal-footer">
219
+ <a href="#" class="close"> Back </a>
220
+ </div>
221
+ </div>
222
+ <%%- end -%>
223
+ </tbody>
224
+ </table>
225
+
226
+ </div>
227
+
228
+ </div>
229
+ <br/>
@@ -0,0 +1,11 @@
1
+ <br/>
2
+ <br/>
3
+ <br/>
4
+ <div class="pageslide_header">
5
+ <h1 style="color:white;">Create a new <br/> <%= singular_name.titleize %></h1>
6
+ </div>
7
+ <br/>
8
+ <br/>
9
+ <div style="text-align: center;">
10
+ <%%= render 'form' %>
11
+ </div>
@@ -0,0 +1,20 @@
1
+ <%% title "<%= singular_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <strong><%= attribute.human_name.titleize %>:</strong>
6
+ <%%= @<%= instance_name %>.<%= attribute.name %> %>
7
+ </p>
8
+ <%- end -%>
9
+
10
+ <p>
11
+ <%- if action? :edit -%>
12
+ <%%= link_to "Edit", <%= item_path :action => :edit, :instance_variable => true %> %> |
13
+ <%- end -%>
14
+ <%- if action? :destroy -%>
15
+ <%%= link_to "Destroy", <%= item_path :instance_variable => true %>, :confirm => 'Are you sure?', :method => :delete %> |
16
+ <%- end -%>
17
+ <%- if action? :index -%>
18
+ <%%= link_to "View All", <%= items_path %> %>
19
+ <%- end -%>
20
+ </p>
@@ -0,0 +1,302 @@
1
+ require "thesilverspoon/version"
2
+ # Require the RAILS generators to be able to extend Rails:Generators::NamedBase
3
+ require 'rails/generators'
4
+
5
+ module Everything
6
+ # If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
7
+ class Scaffold < Rails::Generators::NamedBase
8
+
9
+ # Method in the 'thor' library which gives you access to the accessor methods
10
+ no_tasks { attr_accessor :model_attributes, :controller_actions }
11
+
12
+ # This captures the arguments that the generator can take after "rails g integratedscaffold name"
13
+ argument :g_parameters, :type => :array, :default => [], :banner => "field:type field:type"
14
+
15
+ # this sets the path where the code looks for templates within the gem
16
+ def self.source_root
17
+ File.expand_path("../templates", __FILE__)
18
+ end
19
+
20
+ def initialize(*args, &block)
21
+
22
+ # This is a standard initializer
23
+
24
+ super # Call parent class
25
+ @model_attributes = [] # Initialize empty array for 'thor' attributes
26
+
27
+ # This method splits the name:type arguments in the parameters list
28
+ g_parameters.each do |arg|
29
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
30
+ end
31
+
32
+ # Creates a list of all the standard actions in the controller
33
+ @controller_actions=all_actions
34
+
35
+ end
36
+
37
+
38
+ def create_model
39
+
40
+ # creates the model using the 'model.rb' template and puts it into the rails app
41
+ template 'model.rb', "app/models/#{model_path}.rb"
42
+
43
+ end
44
+
45
+ def create_controller
46
+
47
+ # creates the controller using the 'controller.rb' template and puts it into the rails app
48
+ template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
49
+ end
50
+
51
+ def create_migration
52
+
53
+ # creates the migration file using the 'migration.rb' template and puts it into the rails app with a time stamp
54
+ template 'migration.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_#{model_path.pluralize.gsub('/', '_')}.rb"
55
+
56
+ end
57
+
58
+ def create_helper
59
+
60
+ # creates the helper using the 'helper.rb' template and puts it into the rails app
61
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
62
+ end
63
+
64
+ def create_routes
65
+
66
+ # adds the routes for the gem into the routes file
67
+ namespaces = plural_name.split('/')
68
+ resource = namespaces.pop
69
+ route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
70
+ "namespace(:#{namespace}){ #{acc} }"
71
+ }
72
+ end
73
+
74
+
75
+ def create_views
76
+
77
+ # creates the standard views using the '[action].html.erb' templates and puts it into the rails app
78
+ controller_actions.each do |action|
79
+ if action!="create" and action!="update" and action!="destroy" and action!="parse_save_from_excel"
80
+ template "views/erb/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
81
+ end
82
+ end
83
+ if form_partial?
84
+ template "views/erb/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
85
+ end
86
+ end
87
+
88
+ private
89
+
90
+ def class_name
91
+ name.camelize
92
+ end
93
+
94
+
95
+ def model_path
96
+ name.underscore
97
+ end
98
+
99
+ def controller_methods(dir_name)
100
+ controller_actions.map do |action|
101
+ read_template("#{dir_name}/#{action}.rb")
102
+ end.join("\n").strip
103
+ end
104
+
105
+ def read_template(relative_path)
106
+ ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
107
+ end
108
+
109
+ def instance_name
110
+ if @namespace_model
111
+ singular_name.gsub('/', '_')
112
+ else
113
+ singular_name.split('/').last
114
+ end
115
+ end
116
+
117
+ def instances_name
118
+ instance_name.pluralize
119
+ end
120
+
121
+ def all_actions
122
+ %w[index show new create edit update destroy]
123
+ end
124
+
125
+ def item_resource
126
+ name.underscore.gsub('/', '_')
127
+ end
128
+
129
+ def items_path
130
+ if action? :index
131
+ "#{item_resource.pluralize}_path"
132
+ else
133
+ "root_path"
134
+ end
135
+ end
136
+
137
+ def item_path(options = {})
138
+ name = options[:instance_variable] ? "@#{instance_name}" : instance_name
139
+ suffix = options[:full_url] ? "url" : "path"
140
+ if options[:action].to_s == "new"
141
+ "new_#{item_resource}_#{suffix}"
142
+ elsif options[:action].to_s == "edit"
143
+ "edit_#{item_resource}_#{suffix}(#{name})"
144
+ else
145
+ if name.include?('::') && !@namespace_model
146
+ namespace = singular_name.split('/')[0..-2]
147
+ "[:#{namespace.join(', :')}, #{name}]"
148
+ else
149
+ name
150
+ end
151
+ end
152
+ end
153
+
154
+ def item_url
155
+ if action? :show
156
+ item_path(:full_url => true, :instance_variable => true)
157
+ else
158
+ items_url
159
+ end
160
+ end
161
+
162
+ def items_url
163
+ if action? :index
164
+ item_resource.pluralize + '_url'
165
+ else
166
+ "root_url"
167
+ end
168
+ end
169
+
170
+
171
+ def plural_name
172
+ name.underscore.pluralize
173
+ end
174
+
175
+ def form_partial?
176
+ actions? :new, :edit
177
+ end
178
+
179
+ def all_actions
180
+ %w[index show new create edit update destroy parse_save_from_excel integrated_view]
181
+ end
182
+
183
+ def action?(name)
184
+ controller_actions.include? name.to_s
185
+ end
186
+
187
+ def actions?(*names)
188
+ names.all? { |name| action? name }
189
+ end
190
+
191
+ def add_gem(name, options = {})
192
+ gemfile_content = File.read(destination_path("Gemfile"))
193
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
194
+ gem name, options unless gemfile_content.include? name
195
+ end
196
+
197
+ def destination_path(path)
198
+ File.join(destination_root, path)
199
+ end
200
+
201
+
202
+ # If you use the NamedBase inheritance, a 'name' parameter has to follow the 'rails g integratedscaffold'. Won't work otherwise. If you don't want this, use ::Base
203
+
204
+
205
+ end
206
+ #endd of class
207
+
208
+ end
209
+ module The_silver_spoon
210
+ class Install < Rails::Generators::Base
211
+
212
+ def self.source_root
213
+ File.expand_path("../templates", __FILE__)
214
+ end
215
+
216
+
217
+ def initialize(*args, &block)
218
+ super
219
+ #now we invokde generators off twitter boootstrap and gritter
220
+ Rails::Generators.invoke('bootstrap:install')
221
+ Rails::Generators.invoke('gritter:locale')
222
+ Rails::Generators.invoke('devise:install')
223
+ Rails::Generators.invoke('devise', ["user"])
224
+ Rails::Generators.invoke('devise:views')
225
+ Rails::Generators.invoke('cancan:ability')
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+
234
+ end
235
+
236
+ def create_uploader
237
+ #creates the uploader ruby file using carrierwave
238
+ template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
239
+ end
240
+
241
+ def create_images
242
+
243
+ # copies the standard images into the assets/images folder
244
+ @images=Array.new
245
+ @images= Dir.entries("#{Install.source_root}/assets/images")
246
+ @images.each do |image|
247
+
248
+ if image!=".." and image !="."
249
+ copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
250
+ end
251
+ end
252
+
253
+
254
+ end
255
+
256
+ def create_javascripts
257
+
258
+ # copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
259
+ # TODO : Remove the hardcoding for the javascripts inclusion
260
+
261
+ copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"
262
+
263
+ end
264
+
265
+ def create_stylesheets_exclusions
266
+
267
+ # copies the sequenced css into the assets/stylesheets/exclusions folder
268
+ directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
269
+ end
270
+
271
+ def create_javascript_exclusions
272
+
273
+ # copies the sequenced javascript into the assets/javascripts/exclusions folder
274
+ directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
275
+ end
276
+
277
+ def create_stylesheet_images
278
+
279
+ # copies the dependent css images into the assets/stylesheets/images folder
280
+ directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"
281
+
282
+ end
283
+
284
+
285
+ def create_layouts
286
+ =begin
287
+ #remove hardcoding and make a loop for including all files in this folder
288
+ =end
289
+ remove_file "app/views/layouts/application.html.erb"
290
+ template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
291
+ template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
292
+ template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
293
+ template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
294
+ template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"
295
+
296
+ end
297
+
298
+
299
+ end
300
+
301
+
302
+ end