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
data/.gitignore CHANGED
@@ -1,4 +1,4 @@
1
1
  *.gem
2
2
  .bundle
3
3
  Gemfile.lock
4
- pkg/*
4
+
data/.gitignore~ ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile~ ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in thesilverspoon.gemspec
4
+ gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
5
+ gemspec
6
+
@@ -0,0 +1,299 @@
1
+ # Require the RAILS generators to be able to extend Rails:Generators::NamedBase
2
+ require 'rails/generators'
3
+
4
+ module Everything
5
+ # 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
6
+ class Scaffold < Rails::Generators::NamedBase
7
+
8
+ # Method in the 'thor' library which gives you access to the accessor methods
9
+ no_tasks { attr_accessor :model_attributes, :controller_actions }
10
+
11
+ # This captures the arguments that the generator can take after "rails g integratedscaffold name"
12
+ argument :g_parameters, :type => :array, :default => [], :banner => "field:type field:type"
13
+
14
+ # this sets the path where the code looks for templates within the gem
15
+ def self.source_root
16
+ File.expand_path("../templates", __FILE__)
17
+ end
18
+
19
+ def initialize(*args, &block)
20
+
21
+ # This is a standard initializer
22
+
23
+ super # Call parent class
24
+ @model_attributes = [] # Initialize empty array for 'thor' attributes
25
+
26
+ # This method splits the name:type arguments in the parameters list
27
+ g_parameters.each do |arg|
28
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
29
+ end
30
+
31
+ # Creates a list of all the standard actions in the controller
32
+ @controller_actions=all_actions
33
+
34
+ end
35
+
36
+
37
+ def create_model
38
+
39
+ # creates the model using the 'model.rb' template and puts it into the rails app
40
+ template 'model.rb', "app/models/#{model_path}.rb"
41
+
42
+ end
43
+
44
+ def create_controller
45
+
46
+ # creates the controller using the 'controller.rb' template and puts it into the rails app
47
+ template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
48
+ end
49
+
50
+ def create_migration
51
+
52
+ # creates the migration file using the 'migration.rb' template and puts it into the rails app with a time stamp
53
+ template 'migration.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_#{model_path.pluralize.gsub('/', '_')}.rb"
54
+
55
+ end
56
+
57
+ def create_helper
58
+
59
+ # creates the helper using the 'helper.rb' template and puts it into the rails app
60
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
61
+ end
62
+
63
+ def create_routes
64
+
65
+ # adds the routes for the gem into the routes file
66
+ namespaces = plural_name.split('/')
67
+ resource = namespaces.pop
68
+ route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
69
+ "namespace(:#{namespace}){ #{acc} }"
70
+ }
71
+ end
72
+
73
+
74
+ def create_views
75
+
76
+ # creates the standard views using the '[action].html.erb' templates and puts it into the rails app
77
+ controller_actions.each do |action|
78
+ if action!="create" and action!="update" and action!="destroy" and action!="parse_save_from_excel"
79
+ template "views/erb/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
80
+ end
81
+ end
82
+ if form_partial?
83
+ template "views/erb/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ def class_name
90
+ name.camelize
91
+ end
92
+
93
+
94
+ def model_path
95
+ name.underscore
96
+ end
97
+
98
+ def controller_methods(dir_name)
99
+ controller_actions.map do |action|
100
+ read_template("#{dir_name}/#{action}.rb")
101
+ end.join("\n").strip
102
+ end
103
+
104
+ def read_template(relative_path)
105
+ ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
106
+ end
107
+
108
+ def instance_name
109
+ if @namespace_model
110
+ singular_name.gsub('/', '_')
111
+ else
112
+ singular_name.split('/').last
113
+ end
114
+ end
115
+
116
+ def instances_name
117
+ instance_name.pluralize
118
+ end
119
+
120
+ def all_actions
121
+ %w[index show new create edit update destroy]
122
+ end
123
+
124
+ def item_resource
125
+ name.underscore.gsub('/', '_')
126
+ end
127
+
128
+ def items_path
129
+ if action? :index
130
+ "#{item_resource.pluralize}_path"
131
+ else
132
+ "root_path"
133
+ end
134
+ end
135
+
136
+ def item_path(options = {})
137
+ name = options[:instance_variable] ? "@#{instance_name}" : instance_name
138
+ suffix = options[:full_url] ? "url" : "path"
139
+ if options[:action].to_s == "new"
140
+ "new_#{item_resource}_#{suffix}"
141
+ elsif options[:action].to_s == "edit"
142
+ "edit_#{item_resource}_#{suffix}(#{name})"
143
+ else
144
+ if name.include?('::') && !@namespace_model
145
+ namespace = singular_name.split('/')[0..-2]
146
+ "[:#{namespace.join(', :')}, #{name}]"
147
+ else
148
+ name
149
+ end
150
+ end
151
+ end
152
+
153
+ def item_url
154
+ if action? :show
155
+ item_path(:full_url => true, :instance_variable => true)
156
+ else
157
+ items_url
158
+ end
159
+ end
160
+
161
+ def items_url
162
+ if action? :index
163
+ item_resource.pluralize + '_url'
164
+ else
165
+ "root_url"
166
+ end
167
+ end
168
+
169
+
170
+ def plural_name
171
+ name.underscore.pluralize
172
+ end
173
+
174
+ def form_partial?
175
+ actions? :new, :edit
176
+ end
177
+
178
+ def all_actions
179
+ %w[index show new create edit update destroy parse_save_from_excel integrated_view]
180
+ end
181
+
182
+ def action?(name)
183
+ controller_actions.include? name.to_s
184
+ end
185
+
186
+ def actions?(*names)
187
+ names.all? { |name| action? name }
188
+ end
189
+
190
+ def add_gem(name, options = {})
191
+ gemfile_content = File.read(destination_path("Gemfile"))
192
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
193
+ gem name, options unless gemfile_content.include? name
194
+ end
195
+
196
+ def destination_path(path)
197
+ File.join(destination_root, path)
198
+ end
199
+
200
+
201
+ # 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
202
+
203
+
204
+ end
205
+ #endd of class
206
+
207
+ end
208
+ module The_silver_spoon
209
+ class Install < Rails::Generators::Base
210
+
211
+ def self.source_root
212
+ File.expand_path("../templates", __FILE__)
213
+ end
214
+
215
+
216
+ def initialize(*args, &block)
217
+ super
218
+ #now we invokde generators off twitter boootstrap and gritter
219
+ Rails::Generators.invoke('bootstrap:install')
220
+ Rails::Generators.invoke('gritter:locale')
221
+ Rails::Generators.invoke('devise:install')
222
+ Rails::Generators.invoke('devise', ["user"])
223
+ Rails::Generators.invoke('devise:views')
224
+ Rails::Generators.invoke('cancan:ability')
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+ end
234
+
235
+ def create_uploader
236
+ #creates the uploader ruby file using carrierwave
237
+ template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
238
+ end
239
+
240
+ def create_images
241
+
242
+ # copies the standard images into the assets/images folder
243
+ @images=Array.new
244
+ @images= Dir.entries("#{Install.source_root}/assets/images")
245
+ @images.each do |image|
246
+
247
+ if image!=".." and image !="."
248
+ copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
249
+ end
250
+ end
251
+
252
+
253
+ end
254
+
255
+ def create_javascripts
256
+
257
+ # copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
258
+ # Remove the hardcoding for the javascripts inclusion
259
+
260
+ copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"
261
+
262
+ end
263
+
264
+ def create_stylesheets_exclusions
265
+
266
+ # copies the sequenced css into the assets/stylesheets/exclusions folder
267
+ directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
268
+ end
269
+
270
+ def create_javascript_exclusions
271
+
272
+ # copies the sequenced javascript into the assets/javascripts/exclusions folder
273
+ directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
274
+ end
275
+
276
+ def create_stylesheet_images
277
+
278
+ # copies the dependent css images into the assets/stylesheets/images folder
279
+ directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"
280
+
281
+ end
282
+
283
+
284
+ def create_layouts
285
+ #remove hardcoding and make a loop for including all files in this folder
286
+ remove_file "app/views/layouts/application.html.erb"
287
+ template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
288
+ template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
289
+ template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
290
+ template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
291
+ template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"
292
+
293
+ end
294
+
295
+
296
+ end
297
+
298
+
299
+ end
@@ -0,0 +1,299 @@
1
+ # Require the RAILS generators to be able to extend Rails:Generators::NamedBase
2
+ require 'rails/generators'
3
+
4
+ module Everything
5
+ # 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
6
+ class Scaffold < Rails::Generators::NamedBase
7
+
8
+ # Method in the 'thor' library which gives you access to the accessor methods
9
+ no_tasks { attr_accessor :model_attributes, :controller_actions }
10
+
11
+ # This captures the arguments that the generator can take after "rails g integratedscaffold name"
12
+ argument :g_parameters, :type => :array, :default => [], :banner => "field:type field:type"
13
+
14
+ # this sets the path where the code looks for templates within the gem
15
+ def self.source_root
16
+ File.expand_path("../templates", __FILE__)
17
+ end
18
+
19
+ def initialize(*args, &block)
20
+
21
+ # This is a standard initializer
22
+
23
+ super # Call parent class
24
+ @model_attributes = [] # Initialize empty array for 'thor' attributes
25
+
26
+ # This method splits the name:type arguments in the parameters list
27
+ g_parameters.each do |arg|
28
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
29
+ end
30
+
31
+ # Creates a list of all the standard actions in the controller
32
+ @controller_actions=all_actions
33
+
34
+ end
35
+
36
+
37
+ def create_model
38
+
39
+ # creates the model using the 'model.rb' template and puts it into the rails app
40
+ template 'model.rb', "app/models/#{model_path}.rb"
41
+
42
+ end
43
+
44
+ def create_controller
45
+
46
+ # creates the controller using the 'controller.rb' template and puts it into the rails app
47
+ template 'controller.rb', "app/controllers/#{plural_name}_controller.rb"
48
+ end
49
+
50
+ def create_migration
51
+
52
+ # creates the migration file using the 'migration.rb' template and puts it into the rails app with a time stamp
53
+ template 'migration.rb', "db/migrate/#{Time.now.utc.strftime("%Y%m%d%H%M%S")}_create_#{model_path.pluralize.gsub('/', '_')}.rb"
54
+
55
+ end
56
+
57
+ def create_helper
58
+
59
+ # creates the helper using the 'helper.rb' template and puts it into the rails app
60
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
61
+ end
62
+
63
+ def create_routes
64
+
65
+ # adds the routes for the gem into the routes file
66
+ namespaces = plural_name.split('/')
67
+ resource = namespaces.pop
68
+ route namespaces.reverse.inject("resources :#{resource}") { |acc, namespace|
69
+ "namespace(:#{namespace}){ #{acc} }"
70
+ }
71
+ end
72
+
73
+
74
+ def create_views
75
+
76
+ # creates the standard views using the '[action].html.erb' templates and puts it into the rails app
77
+ controller_actions.each do |action|
78
+ if action!="create" and action!="update" and action!="destroy" and action!="parse_save_from_excel"
79
+ template "views/erb/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
80
+ end
81
+ end
82
+ if form_partial?
83
+ template "views/erb/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
84
+ end
85
+ end
86
+
87
+ private
88
+
89
+ def class_name
90
+ name.camelize
91
+ end
92
+
93
+
94
+ def model_path
95
+ name.underscore
96
+ end
97
+
98
+ def controller_methods(dir_name)
99
+ controller_actions.map do |action|
100
+ read_template("#{dir_name}/#{action}.rb")
101
+ end.join("\n").strip
102
+ end
103
+
104
+ def read_template(relative_path)
105
+ ERB.new(File.read(find_in_source_paths(relative_path)), nil, '-').result(binding)
106
+ end
107
+
108
+ def instance_name
109
+ if @namespace_model
110
+ singular_name.gsub('/', '_')
111
+ else
112
+ singular_name.split('/').last
113
+ end
114
+ end
115
+
116
+ def instances_name
117
+ instance_name.pluralize
118
+ end
119
+
120
+ def all_actions
121
+ %w[index show new create edit update destroy]
122
+ end
123
+
124
+ def item_resource
125
+ name.underscore.gsub('/', '_')
126
+ end
127
+
128
+ def items_path
129
+ if action? :index
130
+ "#{item_resource.pluralize}_path"
131
+ else
132
+ "root_path"
133
+ end
134
+ end
135
+
136
+ def item_path(options = {})
137
+ name = options[:instance_variable] ? "@#{instance_name}" : instance_name
138
+ suffix = options[:full_url] ? "url" : "path"
139
+ if options[:action].to_s == "new"
140
+ "new_#{item_resource}_#{suffix}"
141
+ elsif options[:action].to_s == "edit"
142
+ "edit_#{item_resource}_#{suffix}(#{name})"
143
+ else
144
+ if name.include?('::') && !@namespace_model
145
+ namespace = singular_name.split('/')[0..-2]
146
+ "[:#{namespace.join(', :')}, #{name}]"
147
+ else
148
+ name
149
+ end
150
+ end
151
+ end
152
+
153
+ def item_url
154
+ if action? :show
155
+ item_path(:full_url => true, :instance_variable => true)
156
+ else
157
+ items_url
158
+ end
159
+ end
160
+
161
+ def items_url
162
+ if action? :index
163
+ item_resource.pluralize + '_url'
164
+ else
165
+ "root_url"
166
+ end
167
+ end
168
+
169
+
170
+ def plural_name
171
+ name.underscore.pluralize
172
+ end
173
+
174
+ def form_partial?
175
+ actions? :new, :edit
176
+ end
177
+
178
+ def all_actions
179
+ %w[index show new create edit update destroy parse_save_from_excel integrated_view]
180
+ end
181
+
182
+ def action?(name)
183
+ controller_actions.include? name.to_s
184
+ end
185
+
186
+ def actions?(*names)
187
+ names.all? { |name| action? name }
188
+ end
189
+
190
+ def add_gem(name, options = {})
191
+ gemfile_content = File.read(destination_path("Gemfile"))
192
+ File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
193
+ gem name, options unless gemfile_content.include? name
194
+ end
195
+
196
+ def destination_path(path)
197
+ File.join(destination_root, path)
198
+ end
199
+
200
+
201
+ # 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
202
+
203
+
204
+ end
205
+ #endd of class
206
+
207
+ end
208
+ module The_silver_spoon
209
+ class Install < Rails::Generators::Base
210
+
211
+ def self.source_root
212
+ File.expand_path("../templates", __FILE__)
213
+ end
214
+
215
+
216
+ def initialize(*args, &block)
217
+ super
218
+ #now we invokde generators off twitter boootstrap and gritter
219
+ Rails::Generators.invoke('bootstrap:install')
220
+ Rails::Generators.invoke('gritter:locale')
221
+ Rails::Generators.invoke('devise:install')
222
+ Rails::Generators.invoke('devise', ["user"])
223
+ Rails::Generators.invoke('devise:views')
224
+ Rails::Generators.invoke('cancan:ability')
225
+
226
+
227
+
228
+
229
+
230
+
231
+
232
+
233
+ end
234
+
235
+ def create_uploader
236
+ #creates the uploader ruby file using carrierwave
237
+ template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
238
+ end
239
+
240
+ def create_images
241
+
242
+ # copies the standard images into the assets/images folder
243
+ @images=Array.new
244
+ @images= Dir.entries("#{Install.source_root}/assets/images")
245
+ @images.each do |image|
246
+
247
+ if image!=".." and image !="."
248
+ copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
249
+ end
250
+ end
251
+
252
+
253
+ end
254
+
255
+ def create_javascripts
256
+
257
+ # copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
258
+ # Remove the hardcoding for the javascripts inclusion
259
+
260
+ copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"
261
+
262
+ end
263
+
264
+ def create_stylesheets_exclusions
265
+
266
+ # copies the sequenced css into the assets/stylesheets/exclusions folder
267
+ directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
268
+ end
269
+
270
+ def create_javascript_exclusions
271
+
272
+ # copies the sequenced javascript into the assets/javascripts/exclusions folder
273
+ directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
274
+ end
275
+
276
+ def create_stylesheet_images
277
+
278
+ # copies the dependent css images into the assets/stylesheets/images folder
279
+ directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"
280
+
281
+ end
282
+
283
+
284
+ def create_layouts
285
+ #remove hardcoding and make a loop for including all files in this folder
286
+ remove_file "app/views/layouts/application.html.erb"
287
+ template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
288
+ template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
289
+ template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
290
+ template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
291
+ template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"
292
+
293
+ end
294
+
295
+
296
+ end
297
+
298
+
299
+ end