Class: The_silver_spoon::Install

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/thesilverspoon.rb,
lib/integratedscaffold.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ Install

Returns a new instance of Install.



217
218
219
220
221
222
223
224
225
226
# File 'lib/thesilverspoon.rb', line 217

def initialize(*args, &block)
  super
  #now we invokde generators off twitter boootstrap and gritter
  Rails::Generators.invoke('bootstrap:install')
  Rails::Generators.invoke('gritter:locale')
  Rails::Generators.invoke('devise:install')
  Rails::Generators.invoke('devise', ["user"])
  Rails::Generators.invoke('devise:views')
  Rails::Generators.invoke('cancan:ability')
end

Class Method Details

.source_rootObject



212
213
214
# File 'lib/thesilverspoon.rb', line 212

def self.source_root
  File.expand_path("../templates", __FILE__)
end

Instance Method Details

#create_appplication_helperObject



228
229
230
231
# File 'lib/thesilverspoon.rb', line 228

def create_appplication_helper
  remove_file "app/helpers/application_helper.rb"
  template 'application_helper.rb', "app/helpers/application_helper.rb"
end

#create_imagesObject



238
239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/thesilverspoon.rb', line 238

def create_images

  # copies the standard images into the assets/images folder
  @images=Array.new
  @images= Dir.entries("#{Install.source_root}/assets/images")
  @images.each do |image|

    if image!=".." and image !="."
      copy_file "assets/images/#{image.to_s}", "app/assets/images/#{image}"
    end
  end


end

#create_javascript_exclusionsObject



277
278
279
280
281
# File 'lib/thesilverspoon.rb', line 277

def create_javascript_exclusions

  # copies the sequenced javascript into the assets/javascripts/exclusions folder
  directory "#{Install.source_root}/assets/javascripts/exclusions", "app/assets/javascripts/exclusions"
end

#create_javascriptsObject



253
254
255
256
257
258
259
260
# File 'lib/thesilverspoon.rb', line 253

def create_javascripts

  # copies the standard javascripts into the assets/javascripts folder - Currently hard-coded
  #  : Remove the hardcoding for the javascripts inclusion

  copy_file "#{Install.source_root}/assets/javascripts/jquery.dataTables.min.js", "app/assets/javascripts/jquery.dataTables.min.js"

end

#create_layoutsObject



291
292
293
294
295
296
297
298
299
300
301
302
# File 'lib/thesilverspoon.rb', line 291

def create_layouts
=begin
  #remove hardcoding and make a loop for including all files in this folder
=end
  remove_file "app/views/layouts/application.html.erb"
  template "#{Install.source_root}/layouts/application.html.erb", "app/views/layouts/application.html.erb"
  template "#{Install.source_root}/layouts//dummy_data.html.erb", "app/views/layouts/scaffold.html.erb"
  template "#{Install.source_root}/layouts/information_page.html.erb", "app/views/layouts/information_page.html.erb"
  template "#{Install.source_root}/layouts/pageslide_form_at.html.erb", "app/views/layouts/pageslide_form_at.html.erb"
  template "#{Install.source_root}/layouts/welcome.html.erb", "app/views/layouts/welcome.html.erb"

end

#create_stylesheetObject



262
263
264
265
266
267
268
269
# File 'lib/thesilverspoon.rb', line 262

def create_stylesheet
  template "#{Install.source_root}/assets/stylesheets/silverspoon.css.scss", "app/assets/stylesheets/silverspoon.css.scss"
  template "#{Install.source_root}/assets/stylesheets/base_classes.css.scss", "app/assets/stylesheets/base_classes.css.scss"
  template "#{Install.source_root}/assets/stylesheets/silverspoon.css.scss", "app/assets/stylesheets/information_page.css.scss"
  template "#{Install.source_root}/assets/stylesheets/jquery-ui-1.8.17.custom.css", "app/assets/stylesheets/jquery-ui-1.8.17.custom.css"


end

#create_stylesheet_imagesObject



283
284
285
286
287
288
# File 'lib/thesilverspoon.rb', line 283

def create_stylesheet_images

  # copies the dependent css images into the assets/stylesheets/images folder
  directory "#{Install.source_root}/assets/stylesheets/images", "app/assets/stylesheets/images"

end

#create_stylesheets_exclusionsObject



271
272
273
274
275
# File 'lib/thesilverspoon.rb', line 271

def create_stylesheets_exclusions

  # copies the sequenced css into the assets/stylesheets/exclusions folder
  directory "#{Install.source_root}/assets/stylesheets/exclusions", "app/assets/stylesheets/exclusions"
end

#create_uploaderObject



233
234
235
236
# File 'lib/thesilverspoon.rb', line 233

def create_uploader
  #creates the uploader ruby file using carrierwave
  template 'file_uploader.rb', "app/uploaders/file_uploader.rb"
end

#insert_devise_codeObject



304
305
306
307
308
# File 'lib/thesilverspoon.rb', line 304

def insert_devise_code
  prepend_to_file "config/application.rb",'require "devise"'
	inject_to_file "app/assets/stylesheets/application.css",'*=require_directory'
append_to_file "app/assets/javascripts/application.js",'//= require bootstrap'
end