Class: Sbdevcore::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/sbdevcore/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#databaseObject



14
15
16
17
18
19
# File 'lib/generators/sbdevcore/install_generator.rb', line 14

def database
  directory "config", "config", :force => true
  template  'database.yml', 'config/database.yml', :force => true
  rake "db:drop:all"
  rake "db:create"
end

#gitObject



63
64
65
66
67
68
69
# File 'lib/generators/sbdevcore/install_generator.rb', line 63

def git
  run "git init ."
  copy_file ".gitignore", ".gitignore", :force => true
  copy_file "git_config", ".git/config", :force => true
  run "git add ."
  run "git commit -m 'first commit'"
end

#migrationsObject



21
22
23
24
# File 'lib/generators/sbdevcore/install_generator.rb', line 21

def migrations
  rake "sbdevcore:install:migrations"
  rake "db:migrate"
end

#remove_bsObject



7
8
9
10
11
12
# File 'lib/generators/sbdevcore/install_generator.rb', line 7

def remove_bs
  remove_file 'public/index.html'
  remove_file 'public/images/rails.png'
  remove_file 'app/views/layouts/application.html.erb'
  remove_file 'app/assets/stylesheets/application.css'
end

#seedsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/generators/sbdevcore/install_generator.rb', line 37

def seeds
  copy_file "seeds.rb", "db/seeds.rb", :force => true

  copy_file "application.scss", "app/assets/stylesheets/application.scss", :force => true
  copy_file "sass.scss", "app/assets/stylesheets/sass.scss", :force => true
  directory "application", "app/views/application"

  copy_file "new_contact.html.erb", "app/views/contacts/new.html.erb", :force => true
  inject_into_file "app/assets/javascripts/application.js", "//= require sbdevcore\n", :before => "//= require_tree ."

  dev_mailer = <<-OPTS

ActionMailer::Base.perform_deliveries = false
ActionMailer::Base.raise_delivery_errors = true
  OPTS
  inject_into_file "config/environments/development.rb", dev_mailer, :after => "Tester::Application.configure do"

  prod_mailer = <<-OPTS

ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = false
  OPTS
  inject_into_file "config/environments/production.rb", prod_mailer, :after => "Tester::Application.configure do"
  gsub_file "config/environments/production.rb", /"X-Sendfile"/, "nil" 
end

#set_routesObject



26
27
28
29
30
31
32
33
34
35
# File 'lib/generators/sbdevcore/install_generator.rb', line 26

def set_routes
  route "Sbdevcore::Routes.draw(self)"
  statics = <<-STR
Index.find_all_by_name(APP_CONFIG[:static_pages]).each do |page|
    match page.name => "indices#show", :id => page.id, :as => page.name.to_sym
  end rescue true
  root :to => "indices#show", :id => (Index.find_by_name('home').id rescue 1)
  STR
  route statics
end