Class: Laces::AppBuilder
- Inherits:
-
Rails::AppBuilder
- Object
- Rails::AppBuilder
- Laces::AppBuilder
show all
- Includes:
- Actions
- Defined in:
- lib/laces/app_builder.rb
Instance Method Summary
collapse
Methods included from Actions
#action_mailer_host, #concat_file, #download_file, #replace_in_file
Instance Method Details
#add_application_helper ⇒ Object
220
221
222
223
224
|
# File 'lib/laces/app_builder.rb', line 220
def add_application_helper
name = 'app/helpers/application_helper.rb'
remove_file name
copy_file 'app/helpers/app_helper.rb', name
end
|
#add_config_file ⇒ Object
198
199
200
|
# File 'lib/laces/app_builder.rb', line 198
def add_config_file
copy_file 'config/app.yml'
end
|
#add_images ⇒ Object
215
216
217
218
|
# File 'lib/laces/app_builder.rb', line 215
def add_images
remove_dir 'app/assets/images'
directory 'app/assets/imgs', 'app/assets/images'
end
|
#add_pages_controller_and_home ⇒ Object
226
227
228
229
|
# File 'lib/laces/app_builder.rb', line 226
def add_pages_controller_and_home
copy_file 'app/controllers/pages_controller.rb'
directory 'app/views/pages'
end
|
#add_templating ⇒ Object
202
203
204
205
206
|
# File 'lib/laces/app_builder.rb', line 202
def add_templating
copy_file 'app/controllers/templating_controller.rb'
copy_file 'lib/templating.rb'
create_file 'config/templating.yml'
end
|
#api_directory ⇒ Object
167
168
169
|
# File 'lib/laces/app_builder.rb', line 167
def api_directory
empty_directory 'app/controllers/api'
end
|
#copy_misc_files ⇒ Object
153
154
155
|
# File 'lib/laces/app_builder.rb', line 153
def copy_misc_files
copy_file 'Procfile'
end
|
#create_application_layout ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/laces/app_builder.rb', line 60
def create_application_layout
name = 'app/views/layouts'
remove_file "#{name}/application.html.erb"
template "#{name}/application.html.haml"
template "#{name}/_head.haml"
template "#{name}/_header.haml"
copy_file "#{name}/_content.haml"
copy_file "#{name}/_column.haml"
copy_file "#{name}/_extra.haml"
template "#{name}/_footer.haml"
art = Artii::Base.new :font => 'slant'
art = art.asciify app_name.classify
art = "<!--\n#{art}\n-->"
create_file "#{name}/_ascii.erb", art
end
|
#create_database ⇒ Object
84
85
86
|
# File 'lib/laces/app_builder.rb', line 84
def create_database
bundle_command 'exec rake db:create'
end
|
#create_heroku_apps ⇒ Object
136
137
138
139
140
141
142
143
144
145
|
# File 'lib/laces/app_builder.rb', line 136
def create_heroku_apps
path_additions = ''
if ENV['TESTING']
support_bin = File.expand_path(File.join('..', '..', '..', 'features', 'support', 'bin'))
path_addition = "PATH=#{support_bin}:$PATH"
end
name = "#{path_addition} heroku create #{app_name}"
run "#{name}-production --remote=production --stack=cedar"
run "#{name}-staging --remote=staging --stack=cedar"
end
|
#create_js_directories ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/laces/app_builder.rb', line 31
def create_js_directories
name = 'app/assets/javascripts'
remove_file "#{name}/application.js"
copy_file "#{name}/application.coffee"
copy_file "#{name}/admin.coffee"
empty_directory "#{name}/routers"
empty_directory "#{name}/views"
empty_directory "#{name}/views/shared"
empty_directory "#{name}/collections"
empty_directory "#{name}/helpers"
empty_directory "#{name}/models"
empty_directory "#{name}/lib"
directory "#{name}/lib", "#{name}/lib"
empty_directory "#{name}/admin"
empty_directory "#{name}/admin/routers"
empty_directory "#{name}/admin/views"
empty_directory "#{name}/views/shared"
empty_directory "#{name}/admin/collections"
empty_directory "#{name}/admin/models"
empty_directory "#{name}/admin/helpers"
empty_directory "#{name}/admin/lib"
end
|
#create_views_shared ⇒ Object
27
28
29
|
# File 'lib/laces/app_builder.rb', line 27
def create_views_shared
empty_directory 'app/views/shared'
end
|
#document_heroku ⇒ Object
147
148
149
150
151
|
# File 'lib/laces/app_builder.rb', line 147
def document_heroku
heroku_readme_path = find_in_source_paths 'HEROKU_README.md'
documentation = File.open(heroku_readme_path).read
inject_into_file 'README.md', "#{documentation}\n", :before => 'Most importantly'
end
|
#generate_cucumber ⇒ Object
98
99
100
101
102
103
104
|
# File 'lib/laces/app_builder.rb', line 98
def generate_cucumber
generate 'cucumber:install', '--rspec', '--capybara'
inject_into_file 'features/support/env.rb',
%{Capybara.save_and_open_page_path = 'tmp'\n} +
%{Capybara.javascript_driver = :webkit\n},
:before => %{Capybara.default_selector = :css}
end
|
#generate_devise ⇒ Object
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/laces/app_builder.rb', line 171
def generate_devise
generate 'devise:install'
generate 'devise user'
name = 'app/models/user.rb'
remove_file name
copy_file name
dir = destination_root()
dir = "#{dir}/db/migrate"
files = Dir.entries dir
file = files.grep /devise_create_users.rb/
file = file.first
remove_file "db/migrate/#{file}"
copy_file 'db/migrate/user_migration.rb', "db/migrate/#{file}"
directory 'app/views/devise', 'app/views/users'
copy_file 'app/helpers/users_helper.rb'
end
|
#generate_rspec ⇒ Object
93
94
95
96
|
# File 'lib/laces/app_builder.rb', line 93
def generate_rspec
generate 'rspec:install'
replace_in_file 'spec/spec_helper.rb', '# config.mock_with :mocha', 'config.mock_with :mocha'
end
|
#gitignore_files ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/laces/app_builder.rb', line 111
def gitignore_files
concat_file 'laces_gitignore', '.gitignore'
dirs = %w{
app/models
db/migrate
log
public/images
spec/support
spec/lib
spec/models
spec/views
spec/controllers
spec/helpers
spec/support/matchers
spec/support/mixins
spec/support/shared_examples}
dirs.each{|dir| empty_directory_with_gitkeep(dir) }
end
|
#init_git ⇒ Object
130
131
132
133
134
|
# File 'lib/laces/app_builder.rb', line 130
def init_git
run 'git init'
run 'git add -A .'
run "git commit -m 'Initial commit - suspended project'"
end
|
#intializer_files ⇒ Object
208
209
210
211
212
213
|
# File 'lib/laces/app_builder.rb', line 208
def intializer_files
copy_file 'config/initializers/rabl_init.rb'
name = 'config/initializers/devise.rb'
remove_file name
copy_file name
end
|
#raise_delivery_errors ⇒ Object
19
20
21
|
# File 'lib/laces/app_builder.rb', line 19
def raise_delivery_errors
replace_in_file 'config/environments/development.rb', 'raise_delivery_errors = false', 'raise_delivery_errors = true'
end
|
#readme ⇒ Object
7
8
9
|
# File 'lib/laces/app_builder.rb', line 7
def readme
copy_file 'README.md'
end
|
#remove_public_images_rails ⇒ Object
15
16
17
|
# File 'lib/laces/app_builder.rb', line 15
def remove_public_images_rails
remove_file 'public/images/rails.png'
end
|
#remove_public_index ⇒ Object
11
12
13
|
# File 'lib/laces/app_builder.rb', line 11
def remove_public_index
remove_file 'public/index.html'
end
|
#replace_application ⇒ Object
192
193
194
195
196
|
# File 'lib/laces/app_builder.rb', line 192
def replace_application
name = 'config/application.rb'
remove_file name
template 'config/application.erb', name
end
|
#replace_application_controller ⇒ Object
54
55
56
57
58
|
# File 'lib/laces/app_builder.rb', line 54
def replace_application_controller
name = 'app/controllers/application_controller.rb'
remove_file name
copy_file 'app/controllers/app_controller.rb', name
end
|
#replaced_gemfile ⇒ Object
88
89
90
91
|
# File 'lib/laces/app_builder.rb', line 88
def replaced_gemfile
remove_file 'Gemfile'
copy_file 'Gemfile_template', 'Gemfile'
end
|
#setup_default_rake_task ⇒ Object
161
162
163
164
165
|
# File 'lib/laces/app_builder.rb', line 161
def setup_default_rake_task
append_file "Rakefile" do
"task(:default).clear\ntask :default => [:spec, :cucumber]"
end
end
|
#setup_mail ⇒ Object
231
232
233
234
|
# File 'lib/laces/app_builder.rb', line 231
def setup_mail
copy_file 'config/initializers/setup_mail.rb'
copy_file 'lib/development_mail_interceptor.rb'
end
|
#setup_root_route ⇒ Object
157
158
159
|
# File 'lib/laces/app_builder.rb', line 157
def setup_root_route
route "root :to => 'pages#home'"
end
|
#setup_staging_environment ⇒ Object
23
24
25
|
# File 'lib/laces/app_builder.rb', line 23
def setup_staging_environment
run 'cp config/environments/production.rb config/environments/staging.rb'
end
|
#setup_stylesheets ⇒ Object
106
107
108
109
|
# File 'lib/laces/app_builder.rb', line 106
def setup_stylesheets
remove_dir 'app/assets/stylesheets'
directory 'app/assets/styles', 'app/assets/stylesheets'
end
|
#use_mysql_config_template ⇒ Object
77
78
79
80
81
82
|
# File 'lib/laces/app_builder.rb', line 77
def use_mysql_config_template
name = 'config/database.yml'
remove_file name
template name
create_file 'app/assets/javascripts/template.js'
end
|