lib/bluepill/group.rb in bluepill-0.0.68 vs lib/bluepill/group.rb in bluepill-0.0.69

- old
+ new

@@ -1,6 +1,5 @@ -# -*- encoding: utf-8 -*- module Bluepill class Group attr_accessor :name, :processes, :logger attr_accessor :process_logger @@ -9,24 +8,20 @@ self.processes = [] self.logger = options[:logger] end def add_process(process) - process.logger = self.logger.prefix_with(process.name) - self.processes << process + process.logger = logger.prefix_with(process.name) + processes << process end def tick - self.processes.each do |process| - process.tick - end + processes.each(&:tick) end def determine_initial_state - self.processes.each do |process| - process.determine_initial_state - end + processes.each(&:determine_initial_state) end # proxied events [:start, :unmonitor, :stop, :restart].each do |event| class_eval <<-END @@ -53,28 +48,27 @@ end def status(process_name = nil) lines = [] if process_name.nil? - prefix = self.name ? " " : "" - lines << "#{self.name}:" if self.name + prefix = name ? ' ' : '' + lines << "#{name}:" if name - self.processes.each do |process| - lines << "%s%s(pid:%s): %s" % [prefix, process.name, process.actual_pid, process.state] - if process.monitor_children? - process.children.each do |child| - lines << " %s%s: %s" % [prefix, child.name, child.state] - end + processes.each do |process| + next unless process.monitor_children? + lines << format('%s%s(pid:%s): %s', prefix, process.name, process.actual_pid, process.state) + process.children.each do |child| + lines << format(' %s%s: %s', prefix, child.name, child.state) end end + else - self.processes.each do |process| + processes.each do |process| next if process_name != process.name - lines << "%s%s(pid:%s): %s" % [prefix, process.name, process.actual_pid, process.state] + lines << format('%s%s(pid:%s): %s', prefix, process.name, process.actual_pid, process.state) lines << process.statistics.to_s end end - lines << "" + lines << '' end - end end