lib/org-converge/command.rb in org-converge-0.0.9 vs lib/org-converge/command.rb in org-converge-0.0.10
- old
+ new
@@ -161,12 +161,11 @@
cmd = "#{script[:lang]} #{file}"
# Decision: Only run blocks which have a name
next unless script[:header][:name]
- display_name = script[:header][:name]
- @engine.register display_name, cmd, { :cwd => @root_dir, :logger => logger }
+ run_procs(script, cmd)
end
logger.info "Running code blocks now! (#{babel.ob.scripts.count} runnable blocks found in total)"
@engine.start
logger.info "Run has completed successfully.".fg 'green'
end
@@ -176,12 +175,11 @@
babel.tangle_runnable_blocks!(@run_dir, :filter => @options['--name'])
scripts = babel.ob.scripts.select {|k, h| h[:header][:name] =~ Regexp.new(@options['--name']) }
scripts.each do |key, script|
file = File.expand_path("#{@run_dir}/#{key}")
cmd = "#{script[:lang]} #{file}"
- display_name = script[:header][:name]
- @engine.register display_name, cmd, { :cwd => @root_dir, :logger => logger }
+ run_procs(script, cmd)
end
logger.info "Running code blocks now! (#{scripts.count} runnable blocks found in total)"
@engine.start
logger.info "Run has completed successfully.".fg 'green'
@@ -279,10 +277,11 @@
puts "#{succeeded.count + failed.count} examples, #{failed.count} failures".fg 'green'
exit 1 if failed.count > 0
end
+ private
def diff(expected_lines, actual_lines)
output = ""
file_length_difference = 0
diffs = Diff::LCS.diff(expected_lines, actual_lines)
@@ -331,9 +330,22 @@
end
ob.scripts.each do |index, block|
puts "---------- script: #{index} to be run with: #{block[:header][:shebang]} --------------".fg 'green'
puts block[:lines]
+ end
+ end
+
+ def run_procs(script, cmd)
+ display_name = script[:header][:name]
+ if script[:header][:procs]
+ procs = script[:header][:procs].to_i
+ procs.times do |i|
+ proc_name = "#{display_name}-#{i}"
+ @engine.register proc_name, cmd, { :cwd => @root_dir, :logger => logger }
+ end
+ else
+ @engine.register display_name, cmd, { :cwd => @root_dir, :logger => logger }
end
end
end
end