Browse files

Merge pull request #286 from mgallego/273

#273. Make more flexible clear_controllers
  • Loading branch information...
2 parents 6339251 + b76932d commit 067fec85e5f5952ff7ec633b1f354dba12cdf813 @willdurand willdurand committed Nov 27, 2012
Showing with 35 additions and 2 deletions.
  1. +9 −1 lib/capifony_symfony2.rb
  2. +6 −1 lib/symfony2/symfony.rb
  3. +2 −0 spec/capifony_symfony2_spec.rb
  4. +18 −0 spec/capifony_symfony2_symfony_spec.rb
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

0 comments on commit 067fec8

Please sign in to comment.