lib/reciper/helpers.rb in reciper-0.0.2 vs lib/reciper/helpers.rb in reciper-0.0.3

- old
+ new

@@ -19,11 +19,11 @@ def run_tests(options={}) Dir.chdir(@ruby_app_path) do response = `bundle exec rspec spec` - if response =~ /([.FE]+)/ + if response =~ /([.FE*]+)/ $1.split("").reject { |char| char == "." }.size else puts "Can't get any test output" fail NoTestOutput end @@ -59,17 +59,35 @@ to_file_output.close @operations << [:copy_range, to, original_output.join("\n")] end - def rollback @operations.reverse.each do |operation| if operation[0] == :copy FileUtils.rm(@ruby_app_path + "/" + operation[1]) elsif operation[0] == :copy_range File.open(@ruby_app_path + "/" + operation[1], "w") { |file| file.write(operation[2]) } + elsif operation[0] == :run_command + spawn(operation[1]) if operation[1] + + Process.wait end + end + end + + def run_command(command, rollback_command=nil) + Dir.chdir(@ruby_app_path) do + spawn("bundle exec #{command}", :out => "/dev/null", :err => "/dev/null") + + Process.wait + end + + if $?.exitstatus == 0 + @operations << [:run_command, rollback_command || nil] + true + else + false end end end end \ No newline at end of file