<?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>NiceCabbage Blog &#187; ruby</title>
	<atom:link href="http://www.nicecabbage.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.nicecabbage.com</link>
	<description>Life, Design, Web Application</description>
	<lastBuildDate>Mon, 07 Jun 2010 02:03:24 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>mw: printing variables to Growl using Meow</title>
		<link>http://www.nicecabbage.com/2009/11/mw-printing-variables-to-growl-using-meow/</link>
		<comments>http://www.nicecabbage.com/2009/11/mw-printing-variables-to-growl-using-meow/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 02:57:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[rubygems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=184</guid>
		<description><![CDATA[Today I uploaded a new Rubygem called &#8220;mw&#8221; (pronounced as [mi'u]).
mw is a tiny useful library to output the result of pp to Growl.The original idea of Growl printing comes from jugyo&#8217;s g. Though the concept is great, g does not work on my environment. I&#8217;ve got &#8220;connection errors&#8221; from Growl.
I suspect that &#8220;ruby-growl&#8221; library [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_185" class="wp-caption alignnone" style="width: 465px"><a href="http://www.nicecabbage.com/wp-content/uploads/2009/11/091129-0002.png"><img class="size-full wp-image-185   " title="mw-image" src="http://www.nicecabbage.com/wp-content/uploads/2009/11/091129-0002.png" alt="mw" width="455" height="135" /></a><p class="wp-caption-text">mw</p></div>
<p>Today I uploaded a new Rubygem called &#8220;mw&#8221; (pronounced as [<span>mi'u</span>]).</p>
<p>mw is a tiny useful library to output the result of pp to <a href="http://growl.info/">Growl</a>.The original idea of Growl printing comes from <a href="http://jugyo.org/">jugyo</a>&#8217;s <a href="http://www.slideshare.net/jugyo/g-is-very-useful">g</a>. Though the concept is great, g does not work on my environment. I&#8217;ve got &#8220;connection errors&#8221; from Growl.<br />
I suspect that &#8220;ruby-growl&#8221; library on my machine does not work well.</p>
<p>Anyway, to overcome this problem, I reinvented the same feature using Meow, a Growl notification wrapper for the rb-cocoa environment.</p>
<h2>INSTALL</h2>
<p>First, you need to be a Mac-user, and have installed rb-cocoa.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">port <span style="color: #c20cb9; font-weight: bold;">install</span> rb-cocoa</pre></div></div>

<p>Sinece I uploaded <a href="http://gemcutter.org/gems/mw">mw.gem</a> to <a href="http://gemcutter.org/">gemcutter.org</a>, installing mw is as easy as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #c20cb9; font-weight: bold;">install</span> gemcutter
gem tumble
gem <span style="color: #c20cb9; font-weight: bold;">install</span> mw</pre></div></div>

<h2>USAGE</h2>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mw'</span>
mw <span style="color:#996600;">&quot;message&quot;</span>
mw YourClass.<span style="color:#9900CC;">new</span></pre></div></div>

<p>To change priority, you can use mw1~5. (mw3 is normal, mw1 is the lowest, and mw5 is the highest. mw4 and mw5 will fire the sticky notes, so that the note will live on your screen persitently.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">begin</span>
do_dangerous_and_raise_some_exception
<span style="color:#9966CC; font-weight:bold;">rescue</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; e
mw4 e
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<h2>SOURCES</h2>
<p>all the sources can be seen at <a href="http://github.com/tomoya55/mw">http://github.com/tomoya55/mw</a>.</p>
<h2>NOTES</h2>
<p>1. If you are still not sure what mw is, please take a look at <a href="http://www.slideshare.net/jugyo/g-is-very-useful">jugyo&#8217;s presentation of g</a>.</p>
<p>2. My mw requires rb-cocoa and meow. If you runs ruby on Linux or Windows, you cannot use this library. use g instead.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/11/mw-printing-variables-to-growl-using-meow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>root_url undefined</title>
		<link>http://www.nicecabbage.com/2009/08/root_url-undefined/</link>
		<comments>http://www.nicecabbage.com/2009/08/root_url-undefined/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 18:18:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=156</guid>
		<description><![CDATA[Problem
On Ruby on Rails, you see the NameError of &#8220;undefined local variable or method `root_url&#8217; for #&#60;YourController&#62;&#8221;.
Solution
You need to set map.root in config/routes.rb, such as 

  mpa.root :controller =&#62; :welcome

]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>On Ruby on Rails, you see the NameError of &#8220;undefined local variable or method `root_url&#8217; for #&lt;YourController&gt;&#8221;.</p>
<h2>Solution</h2>
<p>You need to set map.root in config/<strong>routes.rb</strong>, such as </p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  mpa.<span style="color:#9900CC;">root</span> <span style="color:#ff3333; font-weight:bold;">:controller</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:welcome</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/08/root_url-undefined/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Stop installing rubygems to your home directory when you don&#8217;t &#8220;sudo&#8221;</title>
		<link>http://www.nicecabbage.com/2009/08/stop-installing-rubygems-to-your-home-directory-when-you-dont-sudo/</link>
		<comments>http://www.nicecabbage.com/2009/08/stop-installing-rubygems-to-your-home-directory-when-you-dont-sudo/#comments</comments>
		<pubDate>Thu, 06 Aug 2009 03:01:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=153</guid>
		<description><![CDATA[Problem
You don&#8217;t want to install rubygems under your home direcotry(~/.gem/ruby/1.x/) when you just forgot to &#8220;sudo&#8221; and don&#8217;t have right permissions to write to system directories. 
Solution
First, You need to install rubygems newer than 1.3.2. To check the version, type as


gem -v
1.3.1


To update your gems itself, type as


sudo gem update --system

 Next, you need to [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You don&#8217;t want to install rubygems under your home direcotry(~/.gem/ruby/1.x/) when you just forgot to &#8220;sudo&#8221; and don&#8217;t have right permissions to write to system directories. </p>
<h2>Solution</h2>
<p>First, You need to install rubygems newer than 1.3.2. To check the version, type as
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">gem <span style="color: #660033;">-v</span>
1.3.1</pre></div></div>

<p>
To update your gems itself, type as
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem update <span style="color: #660033;">--system</span></pre></div></div>

<p> Next, you need to edit your ~/.gemrc file. Add </p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">gem:  --no-user-install</pre></div></div>

<p>
at the bottom of the file.
</p>
<p>
Now, if you forgot to &#8220;sudo&#8221; when installing new rubygems, gem will simply fail with permission erros, like
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tomoya<span style="color: #000000; font-weight: bold;">@</span>hongkong<span style="color: #000000; font-weight: bold;">%</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> sequel
ERROR:  While executing gem ... <span style="color: #7a0874; font-weight: bold;">&#40;</span>Gem::FilePermissionError<span style="color: #7a0874; font-weight: bold;">&#41;</span>
    You don<span style="color: #ff0000;">'t have write permissions into the /opt/local/lib/ruby/gems/1.8 directory.</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/08/stop-installing-rubygems-to-your-home-directory-when-you-dont-sudo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sending ISO-2022-JP Mail from Ruby1.8</title>
		<link>http://www.nicecabbage.com/2009/07/sending-iso-2022-jp-mail-from-ruby1-8/</link>
		<comments>http://www.nicecabbage.com/2009/07/sending-iso-2022-jp-mail-from-ruby1-8/#comments</comments>
		<pubDate>Wed, 08 Jul 2009 23:34:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[email]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=130</guid>
		<description><![CDATA[Problem
You want to send Japanese mail encodded in ISO-2022-JP from Ruby
Solution
I wrote a small class called Hog for this purpose.

]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You want to send Japanese mail encodded in ISO-2022-JP from Ruby</p>
<h2>Solution</h2>
<p>I wrote a small class called Hog for this purpose.</p>
<p><script src="http://gist.github.com/143297.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/07/sending-iso-2022-jp-mail-from-ruby1-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fail to compile Ruby1.9 on VPS because of the RAM size.</title>
		<link>http://www.nicecabbage.com/2009/06/compiling-ruby1-9-1-on-vps/</link>
		<comments>http://www.nicecabbage.com/2009/06/compiling-ruby1-9-1-on-vps/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 13:03:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=102</guid>
		<description><![CDATA[Problem

You want to compile ruby1.9, but failed with errors:


gcc -I. -I.ext/include/i686-linux -I./include -I. -D_FILE_OFFSET_BITS=64  -DONIG_ENC_REGISTER=rb_enc_register -fPIC  -O2 -g -Wall -Wno-parentheses  -o enc/trans/gb18030.o -c ./enc/trans/gb18030.c
virtual memory exhausted: Cannot allocate memory
make[1]: *** [enc/trans/gb18030.o] Error 1
make[1]: Leaving directory `/home/roiadmin/tmp/ruby-1.9.1-p129'
make: *** [trans] Error 2


You maybe tried changing ulimit values or add gcc-min-heapsize parameters, but all failed [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>
You want to compile ruby1.9, but failed with errors:
</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">gcc -I. -I.ext/include/i686-linux -I./include -I. -D_FILE_OFFSET_BITS=64  -DONIG_ENC_REGISTER=rb_enc_register -fPIC  -O2 -g -Wall -Wno-parentheses  -o enc/trans/gb18030.o -c ./enc/trans/gb18030.c
virtual memory exhausted: Cannot allocate memory
make[1]: *** [enc/trans/gb18030.o] Error 1
make[1]: Leaving directory `/home/roiadmin/tmp/ruby-1.9.1-p129'
make: *** [trans] Error 2</pre></div></div>

<p>
You maybe tried changing ulimit values or add gcc-min-heapsize parameters, but all failed in vain.
</p>
<h2>Solution</h2>
<p>
The best way to do so is remove gb18030.c from compilation packages. Hope you are not planning to use Chinese GB18030 encoded-strings in Ruby.<br />
The compile instructions are written in <strong>&#8220;enc.mk&#8221;</strong>. So all you need to do is delete all lines about gb18030 in <strong>&#8220;enc.mk&#8221;</strong>.<br />
<br />
If you are compileing 1.9.1-p129, you can use <a href="http://www.nicecabbage.com/wp-content/uploads/2009/06/enc.mk.patch">this patch file</a>.
</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">*** enc.mk.org	Wed Jun 17 21:36:49 2009
--- enc.mk	Wed Jun 17 21:38:44 2009
***************
*** 79,85 ****
  	  enc/euc_kr.$(OBJEXT) \
  	  enc/euc_tw.$(OBJEXT) \
  	  enc/gb2312.$(OBJEXT) \
- 	  enc/gb18030.$(OBJEXT) \
  	  enc/gbk.$(OBJEXT) \
  	  enc/iso_8859_1.$(OBJEXT) \
  	  enc/iso_8859_2.$(OBJEXT) \
--- 79,84 ----
***************
*** 113,119 ****
  	 $(ENCSODIR)/euc_kr.$(DLEXT) \
  	 $(ENCSODIR)/euc_tw.$(DLEXT) \
  	 $(ENCSODIR)/gb2312.$(DLEXT) \
- 	 $(ENCSODIR)/gb18030.$(DLEXT) \
  	 $(ENCSODIR)/gbk.$(DLEXT) \
  	 $(ENCSODIR)/iso_8859_1.$(DLEXT) \
  	 $(ENCSODIR)/iso_8859_2.$(DLEXT) \
--- 112,117 ----
***************
*** 147,153 ****
  TRANSCSRCS = enc/trans/big5.c \
  	     enc/trans/chinese.c \
  	     enc/trans/escape.c \
- 	     enc/trans/gb18030.c \
  	     enc/trans/gbk.c \
  	     enc/trans/iso2022.c \
  	     enc/trans/japanese.c \
--- 145,150 ----
***************
*** 161,167 ****
  	    enc/trans/big5.$(OBJEXT) \
  	    enc/trans/chinese.$(OBJEXT) \
  	    enc/trans/escape.$(OBJEXT) \
- 	    enc/trans/gb18030.$(OBJEXT) \
  	    enc/trans/gbk.$(OBJEXT) \
  	    enc/trans/iso2022.$(OBJEXT) \
  	    enc/trans/japanese.$(OBJEXT) \
--- 158,163 ----
***************
*** 175,181 ****
  	   $(ENCSODIR)/trans/big5.$(DLEXT) \
  	   $(ENCSODIR)/trans/chinese.$(DLEXT) \
  	   $(ENCSODIR)/trans/escape.$(DLEXT) \
- 	   $(ENCSODIR)/trans/gb18030.$(DLEXT) \
  	   $(ENCSODIR)/trans/gbk.$(DLEXT) \
  	   $(ENCSODIR)/trans/iso2022.$(DLEXT) \
  	   $(ENCSODIR)/trans/japanese.$(DLEXT) \
--- 171,176 ----
***************
*** 267,276 ****
  	@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(LDSHARED) -o $@ enc/gb2312.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
&nbsp;
- $(ENCSODIR)/gb18030.$(DLEXT): enc/gb18030.$(OBJEXT)
- 	@$(MAKEDIRS) &quot;$(@D)&quot;
- 	$(LDSHARED) -o $@ enc/gb18030.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
- 
  $(ENCSODIR)/gbk.$(DLEXT): enc/gbk.$(OBJEXT)
  	@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(LDSHARED) -o $@ enc/gbk.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
--- 262,267 ----
***************
*** 383,392 ****
  	@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(LDSHARED) -o $@ enc/trans/escape.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
&nbsp;
- $(ENCSODIR)/trans/gb18030.$(DLEXT): enc/trans/gb18030.$(OBJEXT)
- 	@$(MAKEDIRS) &quot;$(@D)&quot;
- 	$(LDSHARED) -o $@ enc/trans/gb18030.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
- 
  $(ENCSODIR)/trans/gbk.$(DLEXT): enc/trans/gbk.$(OBJEXT)
  	@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(LDSHARED) -o $@ enc/trans/gbk.$(OBJEXT) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
--- 374,379 ----
***************
*** 451,460 ****
  	-@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/gb2312.c
&nbsp;
- enc/gb18030.$(OBJEXT): $(encsrcdir)/gb18030.c
- 	-@$(MAKEDIRS) &quot;$(@D)&quot;
- 	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/gb18030.c
- 
  enc/gbk.$(OBJEXT): $(encsrcdir)/gbk.c
  	-@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/gbk.c
--- 438,443 ----
***************
*** 567,576 ****
  	-@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/trans/escape.c
&nbsp;
- enc/trans/gb18030.$(OBJEXT): $(encsrcdir)/trans/gb18030.c
- 	-@$(MAKEDIRS) &quot;$(@D)&quot;
- 	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/trans/gb18030.c
- 
  enc/trans/gbk.$(OBJEXT): $(encsrcdir)/trans/gbk.c
  	-@$(MAKEDIRS) &quot;$(@D)&quot;
  	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(encsrcdir)/trans/gbk.c
--- 550,555 ----</pre></div></div>

<p>
Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/compiling-ruby1-9-1-on-vps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Sinatra application on Google App Engine Java</title>
		<link>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/</link>
		<comments>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 03:36:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Turoial]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=88</guid>
		<description><![CDATA[
This article is all about what I have done to make my first Sinatra application on Google’s App engine/Java aka GAE. As you know, Sinatra is a light web application framework for Ruby. We can run Sinatra on GAE because GAE has started to support Java since April 2009 and there existed a Java implementation [...]]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://content.screencast.com/users/ltrain/folders/Jing/media/96a766bf-7287-4583-85ff-731add765cc7/2009-06-17_1245.png" class="alignnone" width="300" height="200" /></p>
<p>This article is all about what I have done to make my first <a href="http://www.sinatrarb.com/">Sinatra</a> application on <a href="http://code.google.com/appengine">Google’s App engine/Java</a> aka GAE. As you know, Sinatra is a light web application framework for <a href="http://www.ruby-lang.org/">Ruby</a>. We can run Sinatra on GAE because GAE has started to support Java since April 2009 and there existed a Java implementation of Ruby called <a href="http://jruby.codehaus.org/">JRuby</a>.</p>
<p>Before proceeding, you are sure that you already have a valid account for GAE. Otherwise, hurry up to register your account at <a href="http://appengine.google.com/">here</a>.</p>
<p>OK, now you are ready and let’s get started!</p>
<h2>Install JRuby</h2>
<p><img alt="" src="http://asset-1.kenai.com/attachments/images/project/jruby.png" class="alignnone" width="150" height="148" /></p>
<p>First, download a JRuby package using <a href="http://git-scm.com/">git</a>. If you are unfamiliar with <a href="http://git-scm.com">Git</a>, <a href="http://github.com/guides/home">tutorials and articles</a> on <a href="http://github.com">github</a>, including <a href="http://github.com/guides/git-screencasts">screencasts</a> and <a href="http://github.com/guides/git-podcasts">podcasts</a> are your good introduction. </p>
<p>Installation of git on Ubuntu is as easy as </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> git-core</pre></div></div>

<p>If you are using other operating systems, check <a title="http://github.com/guides/home" href="http://github.com/guides/home">http://github.com/guides/home</a>.</p>
<p>To install JRuby, type</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> git clone git:<span style="color: #000000; font-weight: bold;">//</span>kenai.com<span style="color: #000000; font-weight: bold;">/</span>jruby~main</pre></div></div>

<p>Do not type <strong>jruby-main.</strong> <strong>jruby~main </strong>is correct.</p>
<p>Moving to jruby~main directory, start compiling.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> jruby~main
<span style="color: #000000; font-weight: bold;">%</span> ant
<span style="color: #000000; font-weight: bold;">%</span> ant jar-complete</pre></div></div>

<p>Check the jruby version with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –version
jruby 1.4.0dev <span style="color: #7a0874; font-weight: bold;">&#40;</span>ruby 1.8.6p287<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2009</span>-06-<span style="color: #000000;">16</span> <span style="color: #000000;">6586</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>Java HotSpot<span style="color: #7a0874; font-weight: bold;">&#40;</span>TM<span style="color: #7a0874; font-weight: bold;">&#41;</span> Client VM 1.5.0_16<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>i386-java<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<h2>Install Sinatra and related gems</h2>
<p><img alt="" src="http://www.sinatrarb.com/images/logo.gif" width="156" height="108" /></p>
<p>Check the gem version with</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –S gem –version
1.3.3</pre></div></div>

<p>To install rubygems for your new jruby, try</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> bin<span style="color: #000000; font-weight: bold;">/</span>jruby –S gem <span style="color: #c20cb9; font-weight: bold;">install</span> rake sinatra wabler mongrel
JRuby limited openssl loaded. gem <span style="color: #c20cb9; font-weight: bold;">install</span> jruby-openssl <span style="color: #000000; font-weight: bold;">for</span> full support.
<span style="color: #000000; font-weight: bold;">&lt;</span>a <span style="color: #007800;">href</span>=<span style="color: #ff0000;">&quot;http://wiki.jruby.org/wiki/JRuby_Builtin_OpenSSL&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>http:<span style="color: #000000; font-weight: bold;">//</span>wiki.jruby.org<span style="color: #000000; font-weight: bold;">/</span>wiki<span style="color: #000000; font-weight: bold;">/</span>JRuby_Builtin_OpenSSL<span style="color: #000000; font-weight: bold;">&lt;/</span>a<span style="color: #000000; font-weight: bold;">&gt;</span>
Successfully installed rake-0.8.7
Successfully installed rack-1.0.0
Successfully installed sinatra-0.9.2
Successfully installed warbler-0.9.13
Successfully installed gem_plugin-0.2.3
Successfully installed mongrel-1.1.5-java
<span style="color: #000000;">6</span> gems installed</pre></div></div>

<p>Did you see OpenSSL messages, too? You can leave it for now.</p>
<h2>Install JRuby-Rack</h2>
<p>Get a copy of jruby-rack from github.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #666666; font-style: italic;"># only if you are still in jruby~main directory</span>
<span style="color: #000000; font-weight: bold;">%</span> git clone git:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>nicksieger<span style="color: #000000; font-weight: bold;">/</span>jruby-rack.git
<span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> jruby-rack
<span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby\~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jruby <span style="color: #660033;">-S</span> rake <span style="color: #007800;">SKIP_SPECS</span>=<span style="color: #c20cb9; font-weight: bold;">true</span></pre></div></div>

<p>Be careful not to forget to add “SKIP_SPECS=true” when you perform rake command in jruby-rack. Without it, rake will fail.</p>
<h2>Create Sinatra Appcalition</h2>
<p>Now, let’s create a new Sinatra application. First make a directory for our first app.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> myway-app</pre></div></div>

<p>Make directories</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> views public config lib</pre></div></div>

<p>Create files</p>
<h4>1. config.ru</h4>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">require <span style="color: #ff0000;">'rubygems'</span>
require <span style="color: #ff0000;">'sinatra'</span>
root_dir = File.dirname<span style="color: #7a0874; font-weight: bold;">&#40;</span>__FILE__<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">set</span> :environment, :production
<span style="color: #000000; font-weight: bold;">set</span> :root, root_dir
<span style="color: #000000; font-weight: bold;">set</span> :app_file, File.join<span style="color: #7a0874; font-weight: bold;">&#40;</span>root_dir, <span style="color: #ff0000;">'app.rb'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
disable :run
require <span style="color: #ff0000;">'app'</span>
run Sinatra::Application</pre></div></div>

<h4>2. app.rb</h4>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'sinatra'</span>
&nbsp;
get <span style="color:#996600;">'/'</span> <span style="color:#9966CC; font-weight:bold;">do</span>
  <span style="color:#996600;">&quot;Hello from Sinatra running on Java!&quot;</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>3. appengine-web.xml</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appengine-web-app</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://appengine.google.com/ns/1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>live-ch<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;static-files</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;resource-files</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sessions-enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>false<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/sessions-enabled<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;system-properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.management.enabled&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;os.arch&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.mode&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;JIT&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span> <span style="color: #808080; font-style: italic;">&lt;!-- JIT|FORCE|OFF --&gt;</span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastest&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.frameless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.positionless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.threadless&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastops&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.fastcase&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.chainsize&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;500&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.lazyHandles&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jruby.compile.peephole&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/system-properties<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appengine-web-app<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>4. config/warble.rb</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">Warbler::Config</span>.<span style="color:#9900CC;">new</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>config<span style="color:#006600; font-weight:bold;">|</span>
  config.<span style="color:#9900CC;">dirs</span> = <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>lib views public<span style="color:#006600; font-weight:bold;">&#41;</span>
  config.<span style="color:#9900CC;">includes</span> = FileList<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">&quot;appengine-web.xml&quot;</span>, <span style="color:#996600;">&quot;app.rb&quot;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">staging_dir</span> = <span style="color:#996600;">'war'</span>
  config.<span style="color:#9900CC;">java_libs</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">gems</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'sinatra'</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  config.<span style="color:#9900CC;">gem_dependencies</span> = <span style="color:#0000FF; font-weight:bold;">true</span> 
  config.<span style="color:#9900CC;">webxml</span>.<span style="color:#9900CC;">booter</span> = <span style="color:#ff3333; font-weight:bold;">:rack</span> 
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>For a test run,</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ruby app.rb
== Sinatra<span style="color: #000000; font-weight: bold;">/</span>0.9.2 has taken the stage on <span style="color: #000000;">4567</span> <span style="color: #000000; font-weight: bold;">for</span> development with backup from Mongrel</pre></div></div>

<p>Go to <a href="http://localhost:4567/">http://localhost:4567/</a>, and you will see a string message that sinatra is running. OK, press Ctrl+C to stop the server.</p>
<h2>Setup for GAE</h2>
<p><img alt="" src="http://code.google.com/intl/ja/appengine/images/appengine_lowres.gif" class="alignnone" width="142" height="109" /></p>
<p>You need to download GAE SDK for Java from <a href="http://code.google.com/appengine/downloads.html">here</a>. The latest version at this moment is version 1.2.1, released on May 13, 2009. </p>
<p>After the download is finished, we need to copy appengine-java-sdk-1.2.1/lib/user/appengine-api-1.0-sdk-1.2.1.jar to Sinatra Application’s lib directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ~<span style="color: #000000; font-weight: bold;">/</span>Downloads<span style="color: #000000; font-weight: bold;">/</span>appengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>user<span style="color: #000000; font-weight: bold;">/</span>appengine-api-<span style="color: #000000;">1.0</span>-sdk-1.2.1.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Also, we need to copy jruby-rack jars to lib directory.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby-rack<span style="color: #000000; font-weight: bold;">/</span>target<span style="color: #000000; font-weight: bold;">/</span>jruby-rack-0.9.5-SNAPSHOT.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Next, we need to copy jruby itself in lib directory, and split it into a two files because the original jruby-complete.jar is too big to use in GAE.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> ..<span style="color: #000000; font-weight: bold;">/</span>juby~main<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>jruby-complete.jar lib<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Then, create a shellscript called split-jar.sh</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-core.jar
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> ruby-stdlib.jar
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> tmp_unpack
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> tmp_unpack
<span style="color: #7a0874; font-weight: bold;">cd</span> tmp_unpack
jar xf ..<span style="color: #000000; font-weight: bold;">/</span>jruby-complete.jar
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> jruby-core
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>org jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>com jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jline jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jay jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mv</span> tmp_unpack<span style="color: #000000; font-weight: bold;">/</span>jruby jruby-core<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> jruby-core
jar cf ..<span style="color: #000000; font-weight: bold;">/</span>jruby-core.jar .
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>tmp_unpack
jar cf ..<span style="color: #000000; font-weight: bold;">/</span>ruby-stdlib.jar .
<span style="color: #7a0874; font-weight: bold;">cd</span> ..
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-core
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> tmp_unpack
<span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> jruby-complete.jar</pre></div></div>

<p>And run</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> split-jar.sh</pre></div></div>

<p>Try “ls” to see that you have “jruby-core.jar” and “jruby-stdlib.jar” instead of “jruby-complete.jar”.</p>
<p>Now it is time to create “war” files with warbler.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jrruby –S warble</pre></div></div>

<p>Run at localhost.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>appgengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>dev_appserver.sh <span style="color: #660033;">--port</span>=<span style="color: #000000;">18080</span> war</pre></div></div>

<p>If you have no error, open <a href="http://localhost:18080/">http://localhost:18080/</a> with your own browser. you will see the messages.</p>
<h2>Deployment</h2>
<p>You need to overwrite APPLICATION-ID with your own in appengine-web.xml. When finished, create war files again as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>jruby~main<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>jrruby –S warble</pre></div></div>

<p>Then running deployment script</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">%</span> ..<span style="color: #000000; font-weight: bold;">/</span>appgengine-java-sdk-1.2.1<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>appcfg.sh update war</pre></div></div>

<p>If you run this script first time, you will be prompted to input your email address and password. Input your email of your GAE account correctly. After a while, the script will be finished, and you can see your Sinatra/GAE apps at <a href="http://{YOUR-APPLICATION-ID}.appspot.com">http://{YOUR-APPLICATION-ID}.appspot.com</a>.</p>
<p>&#160;</p>
<p>This is all. Enjoy making Ruby web application on GAE!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/ruby-sinatra-application-on-google-app-engine-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dump YAML Strings with UTF-8 multibyte characters in Ruby</title>
		<link>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/</link>
		<comments>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 11:21:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=84</guid>
		<description><![CDATA[Problem
You want to dump your Ruby object to YAML-formatted file, but your object contains UTF-8 multibyte characters. In this situation, original yaml dumper will output in a human-unfriendly format like

  - !binary &#124;
   5a6X6LC35bKs

Solution
The easiest way to solve is to use ya2yaml.

 sudo gem install ya2yaml

Then, in your source code,

open&#40;&#34;save.yml&#34;, &#34;w&#34;&#41; do [...]]]></description>
			<content:encoded><![CDATA[<h2>Problem</h2>
<p>You want to dump your Ruby object to YAML-formatted file, but your object contains UTF-8 multibyte characters. In this situation, original yaml dumper will output in a human-unfriendly format like</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#006600; font-weight:bold;">-</span> !binary <span style="color:#006600; font-weight:bold;">|</span>
   5a6X6LC35bKs</pre></div></div>

<h2>Solution</h2>
<p>The easiest way to solve is to use <a href="http://rubyforge.org/projects/ya2yaml/">ya2yaml</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> ya2yaml</pre></div></div>

<p>Then, in your source code,</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;save.yml&quot;</span>, <span style="color:#996600;">&quot;w&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>f<span style="color:#006600; font-weight:bold;">|</span> 
 f.<span style="color:#9900CC;">write</span> multiByteObj.<span style="color:#9900CC;">ya2yaml</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/dump-yaml-string-with-utf8-multibyte-characters/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gisty for gist and gisty for Ruby1.9.1</title>
		<link>http://www.nicecabbage.com/2009/06/gisty-for-gist-and-gisty-for-ruby1-9-1/</link>
		<comments>http://www.nicecabbage.com/2009/06/gisty-for-gist-and-gisty-for-ruby1-9-1/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 07:30:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubygems]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=76</guid>
		<description><![CDATA[Introduction

gist is a simple web service by github for posting and sharing your cool code snippets. gisty is a command-line client for gist.

Installation of gisty

sudo gem install nokogiri
sudo gem sources -a http://gems.github.com
sudo gem install swdyh-gisty

Usage

 Posting a source code is as easy as


 gisty post hello.c world.c


 Also, you can &#8216;clone&#8217; all your code snippets.


 [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>
<a href='http://gist.github.com'>gist</a> is a simple web service by github for posting and sharing your cool code snippets. <a href="">gisty</a> is a command-line client for gist.
</p>
<h2>Installation of gisty</h2>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> nokogiri
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem sources <span style="color: #660033;">-a</span> http:<span style="color: #000000; font-weight: bold;">//</span>gems.github.com
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> swdyh-gisty</pre></div></div>

<h2>Usage</h2>
<p>
 Posting a source code is as easy as
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> gisty post hello.c world.c</pre></div></div>

<p>
 Also, you can &#8216;clone&#8217; all your code snippets.
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> gisty <span style="color: #c20cb9; font-weight: bold;">sync</span></pre></div></div>

<p>
For more information, type
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"> gisty <span style="color: #7a0874; font-weight: bold;">help</span></pre></div></div>

<p><br/><br />
<br/><br />
And the problem is&#8230;</p>
<h2>Problem</h2>
<p>
gisty does not work with Ruby1.9.1.
</p>
<h2>Solution</h2>
<p>
I made a forked version of gisty on <a href=''http://github.com/tomoya55/gisty/tree/master">github repos</a>. Soon, you will be able to download this version
</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> tomoya55-gisty</pre></div></div>

<p>
Notice: you cannot install tomoya55-gisty at this moment. I am now investigating what is going on on my gems. Thank you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/gisty-for-gist-and-gisty-for-ruby1-9-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>REXML Error on Ruby1.9</title>
		<link>http://www.nicecabbage.com/2009/06/rexml-error-on-ruby19/</link>
		<comments>http://www.nicecabbage.com/2009/06/rexml-error-on-ruby19/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 13:28:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[TechTips]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://www.nicecabbage.com/?p=6</guid>
		<description><![CDATA[Symptom
I encountered an REXML Error of

Last 80 unconsumed characters

when parsing utf-8 xml strings using REXML on Ruby1.9.1.

Solution
try check encoding

puts xmlstring.encoding #=&#38;gt; 'US-ASCII' in my case

If the return value is not &#8220;utf-8&#8243;, you can change the encoding as below.

xmlstring.force_encoding&#40;&#34;utf-8&#34;&#41;

By this change, REXML will parse the input with the correct encodings.
]]></description>
			<content:encoded><![CDATA[<h3>Symptom</h3>
<p>I encountered an REXML Error of</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Last 80 unconsumed characters</pre></div></div>

<p>when parsing utf-8 xml strings using REXML on Ruby1.9.1.</p>
<h3></h3>
<h3>Solution</h3>
<p>try check encoding</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">puts</span> xmlstring.<span style="color:#9900CC;">encoding</span> <span style="color:#008000; font-style:italic;">#=&amp;gt; 'US-ASCII' in my case</span></pre></div></div>

<p>If the return value is not &#8220;utf-8&#8243;, you can change the encoding as below.</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">xmlstring.<span style="color:#9900CC;">force_encoding</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">&quot;utf-8&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>

<p>By this change, REXML will parse the input with the correct encodings.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.nicecabbage.com/2009/06/rexml-error-on-ruby19/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
