class Panoramix::MPI
Public Class Methods
diff_sh()
click to toggle source
# File lib/panoramix/mpi.rb, line 57 def diff_sh system("bash -c \"diff <(echo '#{@final_mpi.pretty_inspect}') <(echo '#{@project_mpi.pretty_inspect}')| colordiff\"") end
generate()
click to toggle source
# File lib/panoramix/mpi.rb, line 61 def generate # Check whether the file already exists if File.exists? @mpi_path puts "Error: mpi.rb already exists in this project. Please, remove it before in order to create a newest version.".red exit 0 end # Get directory containing MPI.rb dir = Rake.application.original_dir # Replace each key path with the variable current_dir new_file = {} @project_mpi.each do |host ,deps| new_hash = {} deps.each do |k, v| key = k.gsub(dir, '#{current_dir}') new_hash[key] = v end new_file[host] = new_hash end header = %¤t_dir = File.expand_path(File.dirname(__FILE__)) Panoramix::MPI::Deps =& File.open(@mpi_path,"w") do |f| f.write(header) f.write(new_file.pretty_inspect.gsub('\#','#')) end end
handle_external(key, value)
click to toggle source
# File lib/panoramix/mpi.rb, line 22 def handle_external(key, value) # Get current scope scope = "local" # Save dependency into @project_mpi @project_mpi[scope] = {} if @project_mpi[scope].nil? @project_mpi[scope].merge!({key => value}) @final_mpi[scope] = {} if @final_mpi[scope].nil? @final_mpi[scope].merge!({key => value}) # Check whether dependencies can be overriden by an MPI file if (@mpi_file && @mpi_file[scope] && @mpi_file[scope][key]) # Generate the new value from MPI mpi_value = @mpi_file[scope][key] # Save overriden value to @final_mpi @final_mpi[scope] = {} if @final_mpi[scope].nil? @final_mpi[scope].merge!({key => mpi_value}) return {key => mpi_value} end {key => value} end
initialize()
click to toggle source
# File lib/panoramix/mpi.rb, line 9 def initialize @mpi_path = "MPI.rb" @mpi_file = {} @project_mpi = {} @final_mpi = {} # Read MPI.rb if exists if File.exists?(@mpi_path) load @mpi_path @mpi_file = Panoramix::MPI::Deps end end
print_final_mpi()
click to toggle source
# File lib/panoramix/mpi.rb, line 49 def print_final_mpi puts @final_mpi.pretty_inspect end
print_mpi()
click to toggle source
# File lib/panoramix/mpi.rb, line 53 def print_mpi puts @project_mpi.pretty_inspect end