-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathAWSLambdaJRuby.java
More file actions
31 lines (18 loc) · 815 Bytes
/
AWSLambdaJRuby.java
File metadata and controls
31 lines (18 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.Map;
import org.jruby.embed.IsolatedScriptingContainer;
import org.jruby.embed.PathType;
import com.amazonaws.services.lambda.runtime.Context;
public class AWSLambdaJRuby {
private static final String mainRubyFile = "main.rb";
private static final String gemsRubyFile = "gems.rb";
@SuppressWarnings("rawtypes")
public String handler(Map data, Context context) throws Exception {
IsolatedScriptingContainer container = new IsolatedScriptingContainer();
context.getLogger().log(data.toString());
container.put("$lambda_arg", data);
String result = "";
result += "yaml: " + container.runScriptlet(PathType.CLASSPATH, mainRubyFile);
result += " gems: " + container.runScriptlet(PathType.CLASSPATH, gemsRubyFile);
return result;
}
}