Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

#273. Make more flexible clear_controllers #286

Merged
merged 2 commits into from

2 participants

@mgallego

Change the clear_controllers task

In the deploy.rb file:

  • set :clear_controllers, false: Don't remove any controller
  • set :clear_controllers, true: Remove app_*.php controllers
  • set :clear_controllers, ['app_dev.php', 'app_test.php', 'config.php' , ....]: Remove the files in the array
@willdurand
Collaborator

tests?

@willdurand
Collaborator

Great. Did you fix your code thanks to the examples (tests) you wrote?

@willdurand willdurand merged commit 067fec8 into everzet:master
@mgallego

Yes, with the tests I found that it could further simplify.

@willdurand
Collaborator
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 26, 2012
  1. @mgallego
Commits on Nov 27, 2012
  1. @mgallego
This page is out of date. Refresh to see the latest.
View
10 lib/capifony_symfony2.rb
@@ -84,6 +84,9 @@ def self.load_into(configuration)
# Need to clear *_dev controllers
set :clear_controllers, true
+
+ # Controllers to clear
+ set :controllers_to_clear, ['app_*.php']
# Files that need to remain the same between deploys
set :shared_files, false
@@ -243,8 +246,13 @@ def write(s)
if dump_assetic_assets
symfony.assetic.dump # Dump assetic assets
end
-
+
if clear_controllers
+ # If clear_controllers is an array set controllers_to_clear,
+ # else use the default value 'app_*.php'
+ if clear_controllers.is_a? Array
+ set(:controllers_to_clear) { clear_controllers }
+ end
symfony.project.clear_controllers
end
end
View
7 lib/symfony2/symfony.rb
@@ -193,8 +193,13 @@
desc "Clears all non production environment controllers"
task :clear_controllers do
capifony_pretty_print "--> Clear controllers"
+
+ command = "#{try_sudo} sh -c 'cd #{latest_release} && rm -f"
+ controllers_to_clear.each do |link|
+ command += " #{web_path}/" + link
+ end
+ run command + "'"
- run "#{try_sudo} sh -c 'cd #{latest_release} && rm -f #{web_path}/app_*.php'"
capifony_puts_ok
end
end
View
2  spec/capifony_symfony2_spec.rb
@@ -27,5 +27,7 @@
@configuration.fetch(:shared_children).should == ['app/logs', 'web/uploads']
@configuration.fetch(:asset_children).should == ['web/css', 'web/images', 'web/js']
@configuration.fetch(:writable_dirs).should == ['app/logs', 'app/cache']
+ @configuration.fetch(:controllers_to_clear).should == ['app_*.php']
end
+
end
View
18 spec/capifony_symfony2_symfony_spec.rb
@@ -288,6 +288,24 @@
end
it "defines symfony:project tasks" do
+ @configuration.fetch(:controllers_to_clear).should == ['app_*.php']
@configuration.find_task('symfony:project:clear_controllers').should_not == nil
end
+
+ context "when running symfony:project:clear_controllers" do
+ before do
+ @configuration.find_and_execute_task('symfony:project:clear_controllers')
+ end
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && rm -f web/app_*.php\'') }
+ end
+
+ context "when running symfony:project:clear_controllers with a given controllers_to_clear" do
+ before do
+ @configuration.set :controllers_to_clear, ['config.php', 'app_dev.php', 'app_test.php']
+ @configuration.find_and_execute_task('symfony:project:clear_controllers')
+ end
+ it { should have_run(' sh -c \'cd /var/www/releases/20120927 && rm -f web/config.php web/app_dev.php web/app_test.php\'') }
+ end
+
+
end
Something went wrong with that request. Please try again.