<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Along Came Betty &#187; jruby</title>
	<atom:link href="http://blog.darevay.com/category/jruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.darevay.com</link>
	<description>You know, software and some other stuff like maybe guitar or something</description>
	<lastBuildDate>Tue, 24 Nov 2009 03:21:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Using rails.vim with JRuby</title>
		<link>http://blog.darevay.com/2009/07/using-rails-vim-with-jruby/</link>
		<comments>http://blog.darevay.com/2009/07/using-rails-vim-with-jruby/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 02:45:15 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[jruby]]></category>

		<guid isPermaLink="false">http://blog.darevay.com/?p=220</guid>
		<description><![CDATA[I spent this evening fiddling around with rails.vim and JRuby.  I have some Java code that I&#8217;d like to use with Rails, so I&#8217;m using JRuby (also, JRuby seems to hate Windows slightly less than MRI).  Anyway, this is really about using vim to edit Rails code. I installed rails.vim and found that it was [...]]]></description>
			<content:encoded><![CDATA[<p>I spent this evening fiddling around with <a href="http://www.vim.org/scripts/script.php?script_id=1567">rails.vim</a> and <a href="http://jruby.org">JRuby</a>.  I have some <a href="http://jsoar.googlecode.com">Java code</a> that I&#8217;d like to use with Rails, so I&#8217;m using JRuby (also, JRuby seems to hate Windows slightly less than MRI).  Anyway, this is really about using vim to edit Rails code. I installed rails.vim and found that it was hard-coded to use plain old Ruby. Assuming that <strong>jruby.bat</strong> (or jruby, I guess) is on your system path, all you need to do is modify the <strong>app_ruby_shell_command </strong>in <strong>autoload/rails.vim</strong> like this:</p>
<pre>function! s:app_ruby_shell_command(cmd) dict abort
  if self.path() =~ '://'
    return "jruby.bat ".a:cmd
  else
    return "jruby.bat -C ".s:rquote(self.path())." -S ".a:cmd
  endif
endfunction</pre>
<p>Basically, just change &#8220;ruby&#8221; to &#8220;jruby.bat&#8221; and add the <strong>-S</strong> parameter.</p>
<p>The <strong>-S</strong> flag is important. Otherwise, it seems JRuby&#8217;s implementation of the <strong>-C</strong> flag is a <a href="http://jira.codehaus.org/browse/JRUBY-3621">little buggy</a>. For example, almost any <strong>script/</strong> command will fail:</p>
<pre>&gt;jruby -C c:\path\to\rails\app script/generate
C:/Program Files/jruby-1.3.1/bin/../lib/ruby/1.8/pathname.rb:711:in `relative_path_from':
        different prefix: "C:/" and "C:\\path/to/rails/app" (ArgumentError)
        from C:/Program Files/jruby-1.3.1/lib/ruby/gems/1.8/gems/rails-2.3.3/lib/rails_generator/lookup.rb:110:in
        `use_component_sources!'</pre>
<p>Everything seems to be working well now. Yay.</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">app_ruby_shell_command</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.darevay.com/2009/07/using-rails-vim-with-jruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JRuby &#8230; Testify!</title>
		<link>http://blog.darevay.com/2008/12/jruby-testify/</link>
		<comments>http://blog.darevay.com/2008/12/jruby-testify/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 17:38:43 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.darevay.com/?p=112</guid>
		<description><![CDATA[Recently on the JRuby mailing list, a call went out for all the crypto-jrubyists to come out of their holes and tell the world about their experience with JRuby. I believe the call was inspired by this blog post by Brian Tatnall. So, I figured I&#8217;d throw in my two cents.
Unlike Brian, I am not [...]]]></description>
			<content:encoded><![CDATA[<p>Recently on the <a href="http://jruby.codehaus.org/">JRuby</a> mailing list, a call went out for all the crypto-jrubyists to come out of their holes and tell the world about their experience with JRuby. I believe the call was inspired by <a href="http://syntatic.wordpress.com/2008/11/25/the-closet-jrubyists/">this blog post</a> by Brian Tatnall. So, I figured I&#8217;d throw in my two cents.</p>
<p>Unlike Brian, I am not someone who &#8220;works with Rails every day&#8221;.  In my job, I do a lot of Java, C++, Tcl, and maybe some Python when I get lucky. I&#8217;ve heard a lot of good things about Ruby, but have never had the chance to try it out on a project. Adding yet another language to one of our systems would just be mean.  So I <a href="http://tryruby.hobix.com/">tried Ruby</a> a few times, liked it, and then forgot it.</p>
<h3>The Opportunity</h3>
<p>Anyway, a few months ago an odd (for my company) project came along that required us to build a small webapp that does custom indexing and searching of a document repository.  I should mention that not only am I a total Ruby noob, but I&#8217;m also a total webapp noob&#8230; In any case, this seemed like the perfect chance to learn something new and a colleague of mine had been playing around with Rails at home so we at least had that.</p>
<p>Some initial work had already been done using <a href="http://lucene.apache.org/java/docs/">Lucene</a> in Java and after talking with the customer, we learned that they wanted to deploy the app on <a href="http://tomcat.apache.org/">Tomcat 5.5</a>. Enter JRuby.</p>
<h3>The Development</h3>
<p>We decided to go with JRuby (version 1.1.3 at the time). Since JRuby allows Ruby code to call into existing Java libraries, I decided to stick with the existing Lucene code in Java. Thus, I built a back-end indexer and query API in Java, while we built the web front-end in JRuby and Rails.</p>
<p>Honestly, it was almost too easy. Rails makes building the webapp sickeningly easy, especially for something as straightforward as what we were doing. Calling the Java-based query interface I had built was also a snap. I just <a href="http://wiki.jruby.org/wiki/Calling_Java_from_JRuby">imported my jar and started calling methods</a>. The conversion from Java objects to Ruby objects was mostly seamless. I think I only had to resort to a couple of <a href="http://www.ruby-doc.org/core/classes/Array.html#M002212">map</a> calls to turn lists returned by the query interface into objects that Rails could use in its view templates.</p>
<p>I should note that jruby is actively supported by NetBeans and apparently in Aptana on Eclipse as well.  For everything I was doing with Rails, I stuck with vim and the command-line. Rails already does way more magic than I understand and an IDE would just add one more layer to my ignorance.</p>
<p>I think the only &#8220;hack&#8221; I ended up with was a static list of query objects stored in Java and accessed from JRuby. Since the Rails controllers are stateless, I couldn&#8217;t figure out where I should store global app data, so for expediency, I put them in a global map. I&#8217;m very bad. I chalk this up to total ignorance of Ruby and Rails (more on this below).</p>
<h3>The Deployment</h3>
<p>We finished the first phase of development way under budget largely thanks to JRuby and Rails. Yay!  This turns out to have been a good thing, because we needed that extra time when we went to deploy. Recall that we were going to deploy to the customer&#8217;s Tomcat server.  Luckily, the <a href="http://blog.nicksieger.com/articles/2007/09/04/warbler-a-little-birdie-to-introduce-your-rails-app-to-java">Warbler</a> tool makes this process mostly painless. Given a Rails app, Warbler packages everything up and generates a war file.</p>
<p>I had a few issues with Warbler. First, there was some inconsistency in what command to actually run. In some documentation, it said to &#8220;warble&#8221;, when the command was really &#8220;warbler&#8221;, or vice versa, I don&#8217;t remember. Second, it took me a little while to figure out the right method of specifying the gems and Java libraries that my app depended on. I recall spending a day fiddling with Tomcat, trying to make sure my jars were discovered as well as the right JDBC ActiveRecord adapter, etc. I think this again has more to do with my ignorance than any actual problems with Warbler.</p>
<p>So I set up a box that mirrored the customers setup and documented the deployment process. Unfortunately, the customer was in another state which meant the install was actually going to be done by a coworker in that state who knew even less about this stuff than me. It took her a day or two of phone calls clarifying everything I&#8217;d missed in my installation guide, but eventually, everything worked and we had a working webapp!</p>
<p><em>I should also mention that more than half of the install time was spent on issues with my Java indexer. JRuby wasn&#8217;t really much of a problem.</em></p>
<h2>The Conclusion and p.s. I Don&#8217;t Know Ruby</h2>
<p>So, the project was really a success. Even with the deployment hassles, we were still under budget, impressed the customer and were able to get follow-on funding to add features. Thanks JRuby!</p>
<p>However, while I was working on the project, I noticed a phenomenon I had read about <a href="http://www.bitwisemag.com/2/Ruby-Off-The-Rails">here</a>. I had built and deployed Ruby on Rails app and can safely say that I barely know Ruby any better than I did when I started. Rails does so much work for you that you can get by without really knowing any Ruby at all. That&#8217;s a little sad, since projects like this are usually the only time I get to really learn a new language in any depth. Maybe I need to start with a pure Ruby app. I&#8217;ve been thinking that a lot of the Swing UI code I&#8217;ve been doing for the <a href="http://jsoar.googlecode.com">jsoar </a><a href="http://code.google.com/p/jsoar/wiki/JSoarDebugger">debugger</a> would be quicker and more educational if it was done in jruby, or one of the other JVM-based languages that have been multiplying like rabbits lately. We&#8217;ll see.</p>
<h2>Others</h2>
<p>Here are other JRuby testimonials and I&#8217;ve come across:</p>
<ul>
<li><a href="http://wekti.com/2008/12/12/who-is-using-jruby-for-large-scale-projects/">Who is using JRuby for large scale projects?</a></li>
<li><a href="http://zargony.com/2008/09/26/why-i-m-starting-to-like-jruby-even-though-i-dislike-java">Why I&#8217;m starting to like JRuby even though I dislike Java</a></li>
<li><a href="http://syntatic.wordpress.com/2008/11/25/the-closet-jrubyists/">The Closet JRubyist</a><a href="http://syntatic.wordpress.com/2008/11/25/the-closet-jrubyists/">s</a></li>
<li><a href="http://archive.codehaus.org/lists/org.codehaus.jruby.user/msg/1de158390811290923u6617ac52ncb6ea80cc675f20b@mail.gmail.com">JRuby Mailing List Thread</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.darevay.com/2008/12/jruby-testify/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Nice intro to JRuby/Java integration</title>
		<link>http://blog.darevay.com/2008/11/nice-intro-to-jrubyjava-integration/</link>
		<comments>http://blog.darevay.com/2008/11/nice-intro-to-jrubyjava-integration/#comments</comments>
		<pubDate>Tue, 25 Nov 2008 13:30:16 +0000</pubDate>
		<dc:creator>dave</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[jruby]]></category>

		<guid isPermaLink="false">http://blog.darevay.com/?p=73</guid>
		<description><![CDATA[Mikio Braun has written a good summary on calling Java code from JRuby.  A lot of this material is covered on the JRuby Wiki, but Mikio adds some much needed exposition. Thanks Mikio!
]]></description>
			<content:encoded><![CDATA[<p>Mikio Braun has written a <a href="http://mikiobraun.blogspot.com/2008/11/java-integration-in-jruby.html">good summary</a> on calling Java code from JRuby.  A lot of this material is <a href="http://wiki.jruby.org/wiki/Calling_Java_from_JRuby">covered on the JRuby Wiki</a>, but Mikio adds some much needed exposition. Thanks Mikio!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.darevay.com/2008/11/nice-intro-to-jrubyjava-integration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
