-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jason Knight
committed
May 15, 2008
1 parent
ad12a2b
commit a65c036
Showing
2 changed files
with
3 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1 @@ | ||
require File.dirname(__FILE__) + '/../../../config/environment' | ||
puts IO.read(File.join(File.dirname(__FILE__), 'README')) | ||
puts "\n\nAltering ApplicationController, this can be undone by editing that file..." | ||
#install alter the app controller | ||
app_controller = File.readlines(RAILS_ROOT + '/app/controllers/application.rb') | ||
i = 0 | ||
new_app_controller = '' | ||
app_controller.each do |line| | ||
if line.include? 'class ApplicationController' then | ||
i = i + 1 | ||
app_controller[i] = "\s\sinclude ExceptionLoggable #Automatically Added by install script\n" + app_controller[i] | ||
end | ||
i = i + 1 | ||
new_app_controller << line | ||
end | ||
app_controller_target = File.open(RAILS_ROOT + '/app/controllers/application.rb','w') | ||
app_controller_target.write(new_app_controller) | ||
app_controller_target.close | ||
#app controller alter done | ||
puts ".....Completed.\n" | ||
puts "Altering routes.rb, this can be undone by editing that file..." | ||
#modify the routes | ||
routes = File.readlines(RAILS_ROOT + '/config/routes.rb') | ||
i = 0 | ||
new_routes = '' | ||
routes.each do |line| | ||
if line.include? 'ActionController::Routing::Routes.draw' then | ||
i = i + 1 | ||
routes[i] = "map.connect \"logged_exceptions/:action/:id\", :controller => \"logged_exceptions\" #Automatically Added by install script\n" + routes[i] | ||
end | ||
i = i + 1 | ||
new_routes << line | ||
end | ||
routes_target = File.open(RAILS_ROOT + '/config/routes.rb','w') | ||
routes_target.write(new_routes) | ||
routes_target.close | ||
#altered routes file | ||
puts ".....Completed.\n" | ||
puts "Attempting to determine your pagination plugin..." | ||
@pagination = 'none' | ||
Dir.foreach(RAILS_ROOT + '/vendor/plugins') do |file| | ||
if file.strip == 'will_paginate' then | ||
@pagination = 'will_paginate' | ||
elsif file.strip == 'paginating_find' then | ||
@pagination = 'paginating_find' | ||
end | ||
end | ||
puts @pagination | ||
if @pagination == 'will_paginate' then | ||
puts "You are using will_paginate, editing init.rb to reflect that..." | ||
#set it to will_paginate | ||
init_rb = File.readlines(File.join(File.dirname(__FILE__), 'init.rb')) | ||
i = 0 | ||
new_init = '' | ||
init_rb.each do |line| | ||
if line.include? "$PAGINATION_TYPE = 'none'" | ||
line = '#' + line | ||
j = i + 1 | ||
init_rb[j] = init_rb[j].gsub('#','') | ||
j = j + 1 | ||
init_rb[j] = init_rb[j].gsub('#','') | ||
j = j + 1 | ||
init_rb[j] = init_rb[j].gsub('#','') | ||
end | ||
i = i + 1 | ||
new_init << line | ||
end | ||
target = File.open(File.join(File.dirname(__FILE__), 'init.rb'),'w') | ||
target.write(new_init) | ||
target.close | ||
elsif @pagination == 'paginating_find' then | ||
puts "You are using paginating_find, editing init.rb to reflect that..." | ||
#set it to paginating_find | ||
init_rb = File.readlines(File.join(File.dirname(__FILE__), 'init.rb')) | ||
i = 0 | ||
new_init = '' | ||
init_rb.each do |line| | ||
if line.include? "$PAGINATION_TYPE = 'none'" | ||
line = '#' + line | ||
j = i + 4 | ||
init_rb[j] = init_rb[j].gsub('#','') | ||
j = j + 1 | ||
init_rb[j] = init_rb[j].gsub('#','') | ||
end | ||
i = i + 1 | ||
new_init << line | ||
end | ||
target = File.open(File.join(File.dirname(__FILE__), 'init.rb'),'w') | ||
target.write(new_init) | ||
target.close | ||
else | ||
puts "Could not detect a pagination plugin, using home brewed pagination instead..." | ||
end | ||
#generate migration | ||
puts "...Completed\n" | ||
puts "Now use script/generate exception_migration\n Then run rake db:migrate\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters