This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/src/org/jruby/embed/jsr223/JRubyCompiledScript.java b/src/org/jruby/em | |
| index ea0ba5c..294c177 100644 | |
| --- a/src/org/jruby/embed/jsr223/JRubyCompiledScript.java | |
| +++ b/src/org/jruby/embed/jsr223/JRubyCompiledScript.java | |
| @@ -69,6 +69,7 @@ public class JRubyCompiledScript extends CompiledScript { | |
| public Object eval(ScriptContext context) throws ScriptException { | |
| try { | |
| + engine.setContext(context); | |
| IRubyObject ret = unit.run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- a/src/org/jruby/Ruby.java | |
| +++ b/src/org/jruby/Ruby.java | |
| @@ -195,6 +195,23 @@ public final class Ruby { | |
| private static Ruby globalRuntime; | |
| + /** | |
| + * Tests whether globalRuntime has been instantiated or not. | |
| + * | |
| + * This method is used by singleton model of org.jruby.embed.ScriptingContainer |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| electra:jruby~main yoko$ jirb | |
| irb(main):001:0> require 'java' | |
| => true | |
| irb(main):002:0> c = org.jruby.embed.ScriptingContainer.new | |
| => org.jruby.embed.ScriptingContainer@4d28c7 | |
| irb(main):003:0> c.run_scriptlet("puts \"Hello\"") | |
| Hello | |
| => nil | |
| irb(main):004:0> c.run_scriptlet("puts \"Hello\"") | |
| java.lang.ArrayIndexOutOfBoundsException: -1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ManyVarsDynamicScope getManyVarsDynamicScope(Ruby runtime, int depth) { | |
| ManyVarsDynamicScope scope; | |
| ThreadContext context = runtime.getCurrentContext(); | |
| DynamicScope currentScope = context.getCurrentScope(); | |
| String[] names4Injection = container.getVarMap().getLocalVarNames(); | |
| if (names4Injection == null || names4Injection.length == 0) { | |
| scope = | |
| new ManyVarsDynamicScope(new EvalStaticScope(currentScope.getStaticScope()), currentScope); | |
| } else { | |
| scope = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def test_inspect_ns | |
| xml = Nokogiri::XML(<<-eoxml) { |c| c.noblanks } | |
| <root xmlns="http://tenderlovemaking.com/" xmlns:foo="bar"> | |
| <awesome/> | |
| </root> | |
| eoxml | |
| p xml.to_s | |
| ins = xml.inspect | |
| puts "ins: #{ins}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| "<?xml version=\"1.0\"?>\n<root xmlns=\"http://tenderlovemaking.com/\" xmlns:foo=\"bar\">\n <awesome/>\n</root>\n" | |
| ins: #<Nokogiri::XML::Document:0x3f32b2 name="document" children=[#<Nokogiri::XML::Element:0x3f2f32 name="root" namespace=#<Nokogiri::XML::Namespace:0x3f2eb4 href="http://tenderlovemaking.com/"> children=[#<Nokogiri::XML::Element:0x3f2a46 name="awesome" namespace=#<Nokogiri::XML::Namespace:0x3f2eb4 href="http://tenderlovemaking.com/">>]>]> | |
| node.class.name: Nokogiri::XML::Element | |
| node.namespace.class.name: Nokogiri::XML::Namespace | |
| node.namespace.href: http://tenderlovemaking.com/ | |
| node.class.name: Nokogiri::XML::Element | |
| node.namespace.class.name: Nokogiri::XML::Namespace | |
| node.namespace.href: http://tenderlovemaking.com/ | |
| node.class.name: Nokogiri::XML::Document |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| irb(main):001:0> require 'java' | |
| => true | |
| irb(main):002:0> c = org.jruby.embed.ScriptingContainer.new | |
| => org.jruby.embed.ScriptingContainer@4e0a2a38 | |
| irb(main):003:0> c.run_scriptlet("require 'rubygems'") | |
| => true | |
| irb(main):004:0> c.run_scriptlet("require 'active_support'") | |
| => true | |
| irb(main):005:0> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| jruby -v test/test_socket.rb | |
| jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-03-02 cefba78) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_17) [x86_64-java] | |
| Loaded suite test/test_socket | |
| Started | |
| ..............^\2010-03-02 16:49:27 | |
| Full thread dump Java HotSpot(TM) 64-Bit Server VM (14.3-b01-101 mixed mode): | |
| "Low Memory Detector" daemon prio=5 tid=0x0000000101843000 nid=0x12df54000 runnable [0x0000000000000000] | |
| java.lang.Thread.State: RUNNABLE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import org.jruby.embed.LocalContextScope; | |
| import org.jruby.embed.ScriptingContainer; | |
| public class HelloWorldInJapanese { | |
| private HelloWorldInJapanese() { | |
| ScriptingContainer container = new ScriptingContainer(LocalContextScope.SINGLETHREAD); | |
| container.runScriptlet("puts \"こんにちは世界\""); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package vanilla; | |
| import java.util.Date; | |
| import org.jruby.RubyClass; | |
| import org.jruby.RubyObject; | |
| import org.jruby.embed.AttributeName; | |
| import org.jruby.embed.LocalContextScope; | |
| import org.jruby.embed.LocalVariableBehavior; | |
| import org.jruby.embed.ScriptingContainer; |
OlderNewer