Class: Thesilverspoon::Install
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Thesilverspoon::Install
- Defined in:
- lib/thesilverspoon.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_appplication_helper ⇒ Object
- #create_images ⇒ Object
- #create_javascript_exclusions ⇒ Object
- #create_javascripts ⇒ Object
- #create_layouts ⇒ Object
- #create_new_user ⇒ Object
- #create_root_route ⇒ Object
- #create_stylesheet ⇒ Object
- #create_stylesheet_images ⇒ Object
- #create_stylesheets_exclusions ⇒ Object
- #create_uploader ⇒ Object
-
#initialize(*args, &block) ⇒ Install
constructor
A new instance of Install.
- #insert_devise_code ⇒ Object
- #install_quiet_assets ⇒ Object
Constructor Details
#initialize(*args, &block) ⇒ Install
Returns a new instance of Install.
222 223 224 225 226 227 228 229 230 231 232 233 234 |
# File 'lib/thesilverspoon.rb', line 222 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') Rails::Generators.invoke('migration', ["add_role_to_user", ["admin:boolean"]]) Rails::Generators.invoke('controller',["welcome",["index"]]) Rails::Generators.invoke('rails_admin:install') end |
Class Method Details
.source_root ⇒ Object
217 218 219 |
# File 'lib/thesilverspoon.rb', line 217 def self.source_root File.("../templates", __FILE__) end |
Instance Method Details
#create_appplication_helper ⇒ Object
254 255 256 257 |
# File 'lib/thesilverspoon.rb', line 254 def create_appplication_helper remove_file "app/helpers/application_helper.rb" template 'application_helper.rb', "app/helpers/application_helper.rb" end |
#create_images ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
# File 'lib/thesilverspoon.rb', line 264 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_exclusions ⇒ Object
311 312 313 314 315 |
# File 'lib/thesilverspoon.rb', line 311 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_javascripts ⇒ Object
283 284 285 286 287 288 289 290 291 292 |
# File 'lib/thesilverspoon.rb', line 283 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" copy_file "#{Install.source_root}/assets/javascripts/bootstrap.js", "app/assets/javascripts/bootstrap.js" end |
#create_layouts ⇒ Object
325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/thesilverspoon.rb', line 325 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//scaffold.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_new_user ⇒ Object
236 237 238 239 240 241 |
# File 'lib/thesilverspoon.rb', line 236 def create_new_user s="\nUser.create!(:email=>'[email protected]',:password=>'secret',:password_confirmation=>'secret',:admin=>true)" append_to_file "db/seeds.rb", s inject_into_file "app/models/user.rb",",:admin",:after=>" attr_accessible :email, :password, :password_confirmation, :remember_me" end |
#create_root_route ⇒ Object
243 244 245 246 247 248 249 250 251 252 |
# File 'lib/thesilverspoon.rb', line 243 def create_root_route s="root" s=s+":to=>" s=s+"'welcome#index'\n" # append_to_file "config/routes.rb",s inject_into_file "config/routes.rb",s,:after=>"# root :to => 'welcome#index'\n" end |
#create_stylesheet ⇒ Object
294 295 296 297 298 299 300 301 302 303 |
# File 'lib/thesilverspoon.rb', line 294 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" template "#{Install.source_root}/assets/stylesheets/bootstrap.css", "app/assets/stylesheets/bootstrap.css" end |
#create_stylesheet_images ⇒ Object
317 318 319 320 321 322 |
# File 'lib/thesilverspoon.rb', line 317 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_exclusions ⇒ Object
305 306 307 308 309 |
# File 'lib/thesilverspoon.rb', line 305 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_uploader ⇒ Object
259 260 261 262 |
# File 'lib/thesilverspoon.rb', line 259 def create_uploader #creates the uploader ruby file using carrierwave template 'file_uploader.rb', "app/uploaders/file_uploader.rb" end |
#insert_devise_code ⇒ Object
338 339 340 341 342 343 344 345 346 347 348 349 |
# File 'lib/thesilverspoon.rb', line 338 def insert_devise_code inject_into_file "config/application.rb", 'require "devise"', :after=>"require File.expand_path('../boot', __FILE__)\n" # inject_into_file "config/application.rb", "require 'bootstrap-sass'\n", :after=>"require File.expand_path('../boot', __FILE__)\n" # inject_into_file "config/application.rb", "require 'bootstrap-rails'\n", :after=>"require 'rails/all'\n" inject_into_file "config/application.rb", "require 'gritter'\n", :after=>"require 'rails/all'\n" inject_into_file "app/assets/stylesheets/application.css", "*=require_directory\n", :before=>"*/" # inject_into_file "app/assets/stylesheets/application.css", "*=require bootstrap\n", :before=>"*/" # append_to_file "app/assets/javascripts/application.js", '//= require bootstrap' inject_into_file "app/controllers/application_controller.rb", "before_filter :authenticate_user!\n", :after=>" protect_from_forgery\n" end |
#install_quiet_assets ⇒ Object
279 280 281 |
# File 'lib/thesilverspoon.rb', line 279 def install_quiet_assets copy_file "#{Install.source_root}/assets/quiet_assets.rb", "config/initializers/quiet_assets.rb" end |