Class: AppBuilder

Inherits:
Rails::AppBuilder
  • Object
show all
Defined in:
lib/nsweb/generators/nsweb/app/app_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(generator) ⇒ AppBuilder

Returns a new instance of AppBuilder.



7
8
9
10
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 7

def initialize(generator)
  super
  @generator.class.source_paths << File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

#appObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 12

def app
  directory 'app'
  remove_file 'app/assets/images/rails.png'
  inside 'app/assets/stylesheets' do
    gsub_file 'application.css', /(require_tree.*)/, 'require_directory ./application'
  end
  template 'layouts/maintenance.html.erb', 'app/views/layouts/maintenance.html.erb'
  git_keep 'app/mailers'
  git_keep 'app/models'
end

#configObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 23

def config
  empty_directory 'config'

  inside 'config' do
    directory 'vhosts'
    template 'routes.rb'
    template 'application.rb'
    template 'environment.rb'
    template 'memcache.yml'
    template 'logrotate.conf'
    template 'deploy.rb'
    template 'unicorn.rb'
    template 'unicorn_init_customer_qa.sh'
    template 'unicorn_init_production.sh'
    template 'unicorn_init_shareone_qa.sh'

    empty_directory 'environments'

    inside 'environments' do
      template 'test.rb.tt', 'test.rb'
      template 'production.rb.tt', 'production.rb'
      inject_into_file 'production.rb', :before => /^end/ do <<EOB

### CUSTOM ###
config.action_mailer.default_url_options = {
  :host => '#{app_name}.nssecurebanking.org'
}
EOB
      end
      template 'development.rb.tt', 'development.rb'
      template 'production.rb.tt', 'customer_qa.rb'
      inject_into_file 'customer_qa.rb', :before => /^end/ do <<EOB

### CUSTOM ###
config.action_mailer.default_url_options = {
  :host => '#{app_name}.nssecuretesting.org'
}
EOB
      end
      template 'development.rb.tt', 'shareone_qa.rb'
      inject_into_file 'shareone_qa.rb', :before => /^end/ do <<EOB

### CUSTOM ###
config.action_mailer.default_url_options = {
  :host => '#{app_name}.hbtesting.org'
}
EOB
      end
    end

    directory 'initializers'
  end
end

#database_ymlObject



77
78
79
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 77

def database_yml
  template 'config/database.yml'
end

#dbObject



81
82
83
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 81

def db
  empty_directory 'db'
end

#docObject



85
86
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 85

def doc
end

#public_directoryObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 88

def public_directory
  empty_directory 'public'

  inside 'public' do
    template '404.html'
    template '422.html'
    template '500.html'
    template '500.js'
    template 'robots.txt'
  end
end

#testObject



100
101
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 100

def test
end

#vendorObject



103
104
105
106
# File 'lib/nsweb/generators/nsweb/app/app_generator.rb', line 103

def vendor
  directory('bundler', '.bundle')
  super
end