class ScriptMapper

Public Class Methods

new(script_hash) click to toggle source
# File lib/spinjector/script_mapper.rb, line 5
def initialize(script_hash)
    @script_hash = script_hash
    verify_syntax
end

Public Instance Methods

load_script(path) click to toggle source
# File lib/spinjector/script_mapper.rb, line 32
def load_script(path)
    raise "[Error] File #{path} does not exist" unless !path.nil? && File.exist?(path)
    File.read(path)
end
map() click to toggle source
# File lib/spinjector/script_mapper.rb, line 10
def map
    script_code = @script_hash["script"] || load_script(@script_hash["script_path"])
    Script.new(
        @script_hash["name"],
        script_code,
        @script_hash["shell_path"] || '/bin/sh',
        @script_hash["input_paths"] || [],
        @script_hash["output_paths"] || [],
        @script_hash["input_file_list_paths"] || [],
        @script_hash["output_file_list_paths"] || [],
        @script_hash["dependency_file"],
        @script_hash["execution_position"] || :before_compile,
        @script_hash["show_env_vars_in_log"]
    )
end
verify_syntax() click to toggle source
# File lib/spinjector/script_mapper.rb, line 26
def verify_syntax
    raise "[Error] Invalid script description #{@script_hash}" unless @script_hash.is_a?(Hash)
    raise "[Error] Script must have a name and an associated script" unless @script_hash.has_key?("name") && @script_hash.has_key?("script") || @script_hash.has_key?("script_path")
    raise "[Error] Invalid name in script #{@script_hash}" unless !@script_hash["name"].nil?
end