Method: RemoteCodeRunner.new

Defined in:
lib/coderunner/remote_code_runner.rb

.new(host, folder, copts = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/coderunner/remote_code_runner.rb', line 34

def new(host, folder, copts = {})
	if host.length == 0
# 				p 'hello'
# 				copts[:Y] = folder
# 				copts[:no_print_out] = true
# 				copts[:no_update] = true
# 				return go(copts)
		folder.sub!(/~/, ENV['HOME'])
# 				Dir.chdir(folder){read_defaults(copts)}
# 				p copts
		return CodeRunner.new(folder, copts)
	end
	if copts[:cache]
		if copts[:cache] == :auto and FileTest.exists? cache_file(host, folder)
			begin
				runner =  Marshal.load(File.read(cache_file(host, folder)))
			rescue TypeError, ArgumentError => err
				eputs err
				eputs data [0..100] if err.class == TypeError
				raise err unless err.message =~ /undefined class/
				repair_marshal_run_class_not_found_error(err)
				retry
			end
			 runner.remote_cache = copts[:cache]
			 runner.libraries ||= []
			 return runner
		else
			runner =  old_new(host, folder, copts)
			runner.update
			runner.remote_cache = copts[:cache]
			unless FileTest.exist? cache_folder(host, folder)
				FileUtils.makedirs cache_folder(host, folder)
			end
			File.open(cache_file(host, folder), 'w') do |file|
				file.puts Marshal.dump(runner)
			end
			return runner
		end
	else
		return old_new(host, folder, copts)
	end

end