lib/screwcap/task_manager.rb in screwcap-0.6.3 vs lib/screwcap/task_manager.rb in screwcap-0.7

- old
+ new

@@ -8,11 +8,10 @@ def initialize(opts = {}) super self.__options = opts self.__tasks = [] self.__servers = [] - self.__command_sets = [] self.__sequences = [] instance_eval(File.read(self.__options[:recipe_file])) if self.__options[:recipe_file] end @@ -80,14 +79,15 @@ # ====Any command sets that are nested within another command set will inerit all the variables from the parent command set. # def task name, options = {}, &block t = Task.new(options.merge(:name => name), &block) t.clone_from(self) - t.validate(self.__servers) unless options[:local] == true + t.validate(self.__servers) self.__tasks << t end alias :task_for :task + alias :command_set :task # ====A *command set* is like a generic set of tasks that you intend to use in multiple tasks. # # command_set :redundant_task do # run "redundant_task" @@ -112,16 +112,10 @@ # # task_for :pet_horse, :server => s2 do # redundant_task # end - def command_set(name,options = {},&block) - t = Task.new(options.merge(:name => name), &block) - t.clone_from(self) - self.__command_sets << t - end - # ====A *server* is the address(es) that you run a *:task* on. # server :myserver, :address => "abc.com", :password => "xxx" # server :app_servers, :addresses => ["abc.com","def.com"], :keys => "~/.ssh/my_key" # # ==== Options @@ -185,40 +179,15 @@ tasks_to_run.flatten! tasks_to_run.compact! ret = [] tasks_to_run.each do |task| - commands = task.__build_commands(self.__command_sets) - if task.__options[:local] == true - Runner.execute_locally! :commands => commands, :silent => self.__options[:silent] - else - threads = [] - self.__servers.select {|s| task.__servers.include? s.__name }.each do |server| - server.__addresses.each do |address| - if task.__options[:parallel] == false - Runner.execute!(:name => task.__name, - :commands => commands, - :address => address, - :server => server, - :silent => self.__options[:silent]) - else - threads << Thread.new(server,address) do |server, address| - Runner.execute!(:name => task.__name, - :commands => commands, - :address => address, - :server => server, - :silent => self.__options[:silent]) - end - end - end - end - threads.each {|t| t.join } - end - ret << commands + ret << task.__build_commands(self.__tasks) + Runner.execute!(:task => task, :servers => self.__servers, :silent => self.__options[:silent], :verbose => self.__options[:verbose]) end $stdout << "\033[0m" - ret.flatten + ret.flatten # return this for tests end # ====Use will dynamically include another file into an existing configuration file. # Screwcap currently looks in the same directory as the current recipe file. #