1. Stefan Saasen
  2. atlassian-jruby-example-plugin

Commits

Stefan Saasen  committed a992a22

Show how to make files reloadable in the example servlet

  • Participants
  • Parent commits 926f72e
  • Branches master

Comments (0)

Files changed (2)

File src/main/java/com/atlassian/plugins/polyglot/jrubyexample/servlet/ExampleRubyServlet.java

View file
  • Ignore whitespace
 package com.atlassian.plugins.polyglot.jrubyexample.servlet;
 
+import com.atlassian.confluence.core.ConfluenceSystemProperties;
 import com.atlassian.plugins.polyglot.jrubyexample.bridge.ScriptingContainerProvider;
 import com.atlassian.templaterenderer.TemplateRenderer;
 import org.apache.commons.lang.StringUtils;
         if (StringUtils.isNotBlank(url)) {
             try {
                 ScriptingContainer container = scriptingContainerProvider.getScriptingContainer();
-                container.runScriptlet("require 'rurl'");
+                if(ConfluenceSystemProperties.isDevMode()) {
+                    container.runScriptlet("load 'rurl.rb'");
+                } else {
+                    container.runScriptlet("require 'rurl'");
+                }
 
                 Object rurl = container.runScriptlet("Rurl.new");
                 HttpResponseInformation responseInformation = (HttpResponseInformation) container.callMethod(rurl, "curl", url);

File src/main/ruby/rurl.rb

View file
  • Ignore whitespace
 class Rurl
   def curl(url)
     open(url) do |f|
-      RurlResponse.new(f.meta, f.each_line.to_a)
+      RurlResponse.new(f.meta, f.each_line.to_a[1..16])
     end
   end
 end