<?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>fiveclouds &#187; ruby</title>
	<atom:link href="http://www.fiveclouds.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fiveclouds.com</link>
	<description>collaboration, creativity and the next big thing</description>
	<lastBuildDate>Tue, 25 May 2010 11:06:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Mixing Maven and Warbler</title>
		<link>http://www.fiveclouds.com/2008/10/19/mixing-maven-and-warbler/</link>
		<comments>http://www.fiveclouds.com/2008/10/19/mixing-maven-and-warbler/#comments</comments>
		<pubDate>Sun, 19 Oct 2008 23:01:46 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[warbler]]></category>

		<guid isPermaLink="false">http://www.fiveclouds.com/?p=81</guid>
		<description><![CDATA[<p>I have recently been working on mixing together a Ruby on Rails application with an Enterprise app.   Initially I was looking into doing it with Goldspike, however after picking up that it was going out of fashion and being replaced with Warbler I decided to use that.   I couldn&#8217;t find any clear documentation on setting up Warbler with Maven (while Goldspike came with a plugin) &#8211; so I decided to try and pull it together so that I could incorporate the Rails app into a larger Java product.</p>
<p>First of all I wanted to put my Rails application&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>I have recently been working on mixing together a Ruby on Rails application with an Enterprise app.   Initially I was looking into doing it with Goldspike, however after picking up that it was going out of fashion and being replaced with Warbler I decided to use that.   I couldn&#8217;t find any clear documentation on setting up Warbler with Maven (while Goldspike came with a plugin) &#8211; so I decided to try and pull it together so that I could incorporate the Rails app into a larger Java product.</p>
<p>First of all I wanted to put my Rails application into a Maven like directory structure so I created /src/main/rails and put the app in there,  then I knocked up a pretty standard POM for a WAR file.  Next up I wanted to Warble the project so I first up I installed the gem.</p>
<pre class="brush: xml;">pdodds:(svn)trunk[trunk:4184]/src/main/rails$ sudo gem install warbler
Bulk updating Gem source index for: http://gems.rubyforge.org
Successfully installed warbler-0.9.11
1 gem installed
Installing ri documentation for warbler-0.9.11...
Installing RDoc documentation for warbler-0.9.11...
pdodds:(svn)trunk[trunk:4184]/src/main/rails$
</pre>
<p>Then I pluginize the Warble so that it will be available in my project using <code>warble pluginize</code>.</p>
<p>Next up I wanted to get my Maven pom sorted out &#8211; the quickest way I could find to get Warble integrated was through the jruby-rake-plugin.  Adding the following plugin to my pom.xml ensures that the gems that I need are installed by the jruby plugin and then warble can be called in the compile phase.</p>
<pre class="brush: xml;">&lt;plugin&gt;
	&lt;groupId&gt;org.jruby.plugins&lt;/groupId&gt;
	&lt;artifactId&gt;jruby-rake-plugin&lt;/artifactId&gt;
	&lt;version&gt;1.1.4&lt;/version&gt;
	&lt;executions&gt;
		&lt;execution&gt;
			&lt;id&gt;install-gems&lt;/id&gt;
			&lt;phase&gt;process-resources&lt;/phase&gt;
				&lt;goals&gt;
					&lt;goal&gt;install-gems&lt;/goal&gt;
				&lt;/goals&gt;
				&lt;configuration&gt;
					&lt;gems&gt;warbler,rails&lt;/gems&gt;
				&lt;/configuration&gt;
		&lt;/execution&gt;
		&lt;execution&gt;
				&lt;id&gt;build-war&lt;/id&gt;
				&lt;phase&gt;compile&lt;/phase&gt;
				&lt;goals&gt;
					&lt;goal&gt;rake&lt;/goal&gt;
				&lt;/goals&gt;
				&lt;configuration&gt;
					&lt;launchDirectory&gt;${basedir}/src/main/rails
					&lt;/launchDirectory&gt;
			    	        &lt;args&gt;war:clean war&lt;/args&gt;
				&lt;/configuration&gt;
	           &lt;/execution&gt;
	&lt;/executions&gt;
&lt;/plugin&gt;
</pre>
<p>In the first instance of the execution of the jruby plugin we pull down and install the gems that we are going to use,  in the second we actually call the Warble goals in the project to create the WAR file.</p>
<p>In order to quickly integrate this process with the standard WAR building in Maven we need to configure the Maven WAR plugin,  you could also change the Warble output but in the end I found this way worked when I wanted to use the Jetty plugin.</p>
<pre class="brush: xml;">&lt;plugin&gt;
	&lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
	&lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
	&lt;configuration&gt;
		&lt;webappDirectory&gt;${basedir}/src/main/rails/tmp&lt;/webappDirectory&gt;
        &lt;/configuration&gt;
&lt;/plugin&gt;</pre>
<p>While this is pretty brief hopefully it helps others get going and I&#8217;m very open to alternate or better ways to achieve the same goal.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fiveclouds.com/2008/10/19/mixing-maven-and-warbler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting off the ground with EC2</title>
		<link>http://www.fiveclouds.com/2008/05/03/getting-off-the-ground-with-ec2/</link>
		<comments>http://www.fiveclouds.com/2008/05/03/getting-off-the-ground-with-ec2/#comments</comments>
		<pubDate>Sat, 03 May 2008 12:21:59 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[paas]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.fiveclouds.com/?p=43</guid>
		<description><![CDATA[<a href="http://www.fiveclouds.com/wp-content/uploads/2008/05/images.jpeg"><img align="left" class="size-medium wp-image-44" title="Amazon" src="http://www.fiveclouds.com/wp-content/uploads/2008/05/images.jpeg" alt="Amazon" width="150" height="44" /></a>Over the past couple of months I have been playing around with <a href="http://aws.amazon.com">Amazon Web Services</a>,  I have to admit they are an interesting and powerful solution to many of the IT as a Service models that have hung around in the past.  While the technology is definitely still low level I thought I would spend a rainy Saturday in Manila playing around with the Ruby EC2 library and see what I could.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.fiveclouds.com/wp-content/uploads/2008/05/images.jpeg"><img align="left" class="size-medium wp-image-44" title="Amazon" src="http://www.fiveclouds.com/wp-content/uploads/2008/05/images.jpeg" alt="Amazon" width="150" height="44" /></a>Over the past couple of months I have been playing around with <a href="http://aws.amazon.com">Amazon Web Services</a>,  I have to admit they are an interesting and powerful solution to many of the IT as a Service models that have hung around in the past.  While the technology is definitely still low level I thought I would spend a rainy Saturday in Manila playing around with the Ruby EC2 library and see what I could.</p>
<p>In order to get things started I simply set-up the new <a href="http://github.com/grempe/amazon-ec2/wikis">Amazon EC2</a> gem.</p>
<pre><code class="terminal"># ONE TIME ONLY
# Execute this on each machine where you install gems to add github as a gem source
gem sources -a http://gems.github.com/

# ONE TIME ONLY
# Only if you had a previous version of the gem installed from RubyForge before we moved to GitHub
# Say 'Y' to remove all previous versions and all binaries when prompted.
sudo gem uninstall amazon-ec2

# Finally install the gem
sudo gem install grempe-amazon-ec2
</code></pre>
<p>Once installed we need to add a couple of environment variables  to our .bash_profile,  this is useful to have around if you want to use the EC2 CLI anyway.  Here&#8217;s what I put in my .bash_profile (on Leopard):</p>
<pre><code class="terminal">export RUBYOPT="rubygems"

# For amazon-ec2 and amazon s3 ruby gems
export AMAZON_ACCESS_KEY_ID="YOUR_ACCESS_KEY_ID"
export AMAZON_SECRET_ACCESS_KEY="YOUR_SECRET_ACCESS_KEY_ID"
</code></pre>
<p><code class="terminal"> </code></p>
<p> </p>
<p>Before going too far we will need to create a key pair that we can use,  this is easy enough &#8211; lets start up the ec2sh and create a new keypair.  We store this in a local file.</p>
<pre><code class="terminal">&gt;&gt; File.open("pdodds-keypair","w") { |file| file.write(@ec2.create_keypair(:key_name=&gt;"pdodds-keypair").keyMaterial); file.close }
&gt;&gt; File.chmod 0700,"pdodds-keypair"
</code></pre>
<p>First up I thought I would take a look around the images that are available so that I can pick up something that I could use,  since I&#8217;m bedding slowly into the Ruby world I thought I would use ec2sh and get back some information on what is available.</p>
<pre><code class="terminal">&gt;&gt; @ec2.describe_images(:owner=&gt;'amazon').imagesSet.item.each { |image| puts "#{image.imageId} #{image.imageLocation}" } == true
</code></pre>
<p>Beside the scruffy ==true on the end basically this prints out the ID&#8217;s and locations of the Amazon owned images.  For those new to EC2 these are the images of operating systems that we can use to boot our instance.  EC2 machines currently only support persistent filesystems for those lucky enough to get on the beta (anyone going to invite me?).  These means that when you boot up a machine the image is all you have, and when you power down anything you have written to disk is lost.  In a while we&#8217;ll touch upon bundles &#8211; this is a way to allow you to build AMIs (Amazon Machine Image) and store them away.</p>
<p>The output of our command should give us a nice list,  we can do a little to filter down the results (since their is a fair few to choose from).</p>
<pre><code class="terminal">&gt;&gt; @ec2.describe_images(:owner=&gt;'amazon').imagesSet.item.each { |image| puts "#{image.imageId} #{image.imageLocation}" if image.imageLocation =~ /rails/} == true
</code></pre>
<p>This gave me a few to choose from</p>
<pre><code class="terminal">ami-0cf61365 ec2-on-rails-0.9.2/ec2-on-rails.manifest.xml
ami-540aef3d ec2onrails/ec2onrails-v0_9_7-x86_64.manifest.xml
ami-5c0aef35 ec2onrails/ec2onrails-v0_9_7-i386.manifest.xml
ami-6bcd2802 rails1-51193934437/rails1-51193934437.img.manifest.xml
ami-86c025ef ec2onrails/ec2onrails-v0_9_5-i386.manifest.xml
ami-99c025f0 ec2onrails/ec2onrails-v0_9_5-x86_64.manifest.xml
ami-99f712f0 ec2-on-rails-0.9.1/ec2-on-rails.manifest.xml
ami-a38b6eca amis.winelibrary.com/rails_svn.manifest.xml
ami-a3f91cca ec2onrails/ec2onrails-v0_9_3.manifest.xml
ami-a93adfc0 webficient/ec2_images/fc8-rails2-nginx-mysql/image.manifest.xml
ami-e620c58f ec2onrails/ec2onrails-v0_9_6-i386.manifest.xml
ami-ecc12485 ec2onrails/ec2onrails-v0_9_4-i386.manifest.xml
ami-efc12486 ec2onrails/ec2onrails-v0_9_4-x86_64.manifest.xml
ami-f920c590 ec2onrails/ec2onrails-v0_9_6-x86_64.manifest.xml
</code></pre>
<p>So lets get down to business &#8211; time to provision one of those servers for our use,  I have to admit this was the bit that I always thought was cool,  we can just use a simple command from ec2sh to create an instance of a server.  Back to ec2sh.</p>
<pre><code class="terminal">&gt;&gt; @ec2.run_instances :image_id=&gt;"ami-a93adfc0", :key_name=&gt;"pdodds-keypair"
</code></pre>
<p>This will dump out a bunch of XML,  basically the response from the web service.  You could probably have done something to pretty up the response,  however for now we can look up our instances to see if it is running</p>
<pre><code class="terminal">&gt;&gt; @ec2.describe_instances.reservationSet.item.each{ |reservation| puts "Reservation: #{reservation.reservationId}"; reservation.instancesSet.item.each {|item| puts "Instance: #{item.instanceId} #{item.instanceType} #{item.launchTime} #{item.dnsName}" }} == true
</code></pre>
<p>This will output the happy information,  as long as the server has had a few minutes to provision and start.</p>
<pre><code class="terminal">i-9e5a97f7 m1.small 2008-05-03T09:19:12.000Z ec2-75-101-212-159.compute-1.amazonaws.com
</code></pre>
<p>Next we need to authorize the access to the server</p>
<pre><code class="terminal">&gt;&gt; @ec2.authorize_security_group_ingress :group_name=&gt;"default",:from_port=&gt;22,:ip_protocol=&gt;"tcp", :to_port=&gt;22, :cidr_ip=&gt;"0.0.0.0/24"
</code></pre>
<p>Finally now from terminal we can SSH into the server,  note that we do need to include the key that we created.</p>
<pre><code class="terminal">ssh -i pdodds-keypair root@ec2-75-101-212-159.compute-1.amazonaws.com
</code></pre>
<p>There we go &#8211; we have an instance of that Unix box, up and running, we can play around with the instance and when it&#8217;s time to say goodbye its a simple as going back to our ec2sh session and running:</p>
<pre><code class="terminal">&gt;&gt; @ec2.terminate_instances :instance_id=&gt;"i-9e5a97f7"
</code></pre>
<p>I&#8217;ll follow up this blog post with how you can modify and then store images, later however I hope this shows how you can use the Ruby EC2 API to play around and create servers :) happy provisioning in the cloud&#8230;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fiveclouds.com/2008/05/03/getting-off-the-ground-with-ec2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Learning a little Ruby every day</title>
		<link>http://www.fiveclouds.com/2008/04/09/learning-a-little-ruby-every-day/</link>
		<comments>http://www.fiveclouds.com/2008/04/09/learning-a-little-ruby-every-day/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 21:05:06 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.fiveclouds.com/?p=35</guid>
		<description><![CDATA[<p>While I still have a lot going one I have been trying to get more time to pick up on Ruby and Rails.  I have to admit coming from a long history of statically typed languages it has taken a bit of time,  and losing the code completion of the Eclipse IDE that I have been using for Java development for so long took its toll.  Still I have to admit I&#8217;m enjoying the language more every day.</p>
<p>Some of the nice components I&#8217;ve seen included the ability to sum calculated values from arrays where the method is accessing the&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>While I still have a lot going one I have been trying to get more time to pick up on Ruby and Rails.  I have to admit coming from a long history of statically typed languages it has taken a bit of time,  and losing the code completion of the Eclipse IDE that I have been using for Java development for so long took its toll.  Still I have to admit I&#8217;m enjoying the language more every day.</p>
<p>Some of the nice components I&#8217;ve seen included the ability to sum calculated values from arrays where the method is accessing the ActiveRecord fields on the same object.</p>
<pre><code class="ruby">
def sum_invoices
 invoices.to_a.sum(&#038;:invoice_total)
end
</code></pre>
<p>Also I have been working with <a href="http://haml.hamptoncatlin.com/">HAML</a> after being introduced to it by one of the team and while it does take me back a little to all those Java templating languages and I now see how useful it is in pushing people toward using CSS.</p>
<p>Other nice little features I have been picking up on include using <a href="http://manuals.rubyonrails.com/read/chapter/26">ruby in fixtures</a> which includes being able to create large number amounts of test data.  As I get more into it the rewarding part the pace of my development appears to be picking up :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fiveclouds.com/2008/04/09/learning-a-little-ruby-every-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switching Languages</title>
		<link>http://www.fiveclouds.com/2008/03/28/switching-languages/</link>
		<comments>http://www.fiveclouds.com/2008/03/28/switching-languages/#comments</comments>
		<pubDate>Fri, 28 Mar 2008 09:44:59 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.fiveclouds.com/2008/03/28/switching-languages/</guid>
		<description><![CDATA[<p>In the past few months I have spent a lot of time discussing the state of language adoption these days. &#160; Much of my time in the past was spent in the financial services in a world of C++, Java and .Net (probably in those proportions &#8211; mixed in with a lot of database-centric stuff and legacy languages i.e. COBOL). &#160; Back in 2003 I was heavily involved in bringing more open source into the mix &#8211; it was heavily in the Java world. &#160;Working with large investment banks it was an interesting journey pushing through the barriers to get&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p>In the past few months I have spent a lot of time discussing the state of language adoption these days. &nbsp; Much of my time in the past was spent in the financial services in a world of C++, Java and .Net (probably in those proportions &#8211; mixed in with a lot of database-centric stuff and legacy languages i.e. COBOL). &nbsp; Back in 2003 I was heavily involved in bringing more open source into the mix &#8211; it was heavily in the Java world. &nbsp;Working with large investment banks it was an interesting journey pushing through the barriers to get products like JBoss into production and to allow the big savings. &nbsp; Back in 2005 I was hacking stuff with early additions of <a href="http://groovy.codehaus.org/">Groovy</a>, &nbsp;the idea was to use scripting languages to allow business people to build a DSL that would allow them to define rules without getting stuck into XML (there was a lot of that going around). &nbsp;While that work didn&#8217;t get into production it did get me thinking more about DSL&#8217;s and of course led me to Ruby. &nbsp;While I started working with Rails back then I was ultimately pulled away into the SOA world again with <a href="http://servicemix.apache.org">ServiceMix</a> &#8211; and then into the Maven space with DevZuz &#8211; and also more into Eclipse et al.</p>
<p>Now at <a href="http://www.exist.com">Exist</a> I have been given the chance to look across more technologies again and so it is back to Ruby. &nbsp; A lot has changed with a huge number of advances in Behaviour Driven Development with Rails 2.0 coming out. &nbsp;I have to admit there is a lot to pick up again, &nbsp;and I&#8217;m taking time to catch up with it all again. &nbsp;Though as I start to enter the Ruby world it is nice to see a lot of really nice tools out there to make the work of creating rich solutions easier and easier. &nbsp;Lately for me it has been working with <a href="http://newgem.rubyforge.org/">newgem</a> and <a href="http://rspec.info/">rspec</a>, &nbsp;to start to allow some definition around a component layer for a pet project.</p>
<p>Also I got a chance to hang out with the growing Ruby on Rails scene in Manila which was fun &#8211; if you are out here for a while its worth catching up with <a href="http://groups.google.com/group/ruby-phil">them</a>. &nbsp; I&#8217;m sure in the next few months I&#8217;ll be seeing more and more of Ruby and Rails, and probably a bit of <a href="http://merbivore.com/">Merb</a> and ActiveResource too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fiveclouds.com/2008/03/28/switching-languages/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prototyping with ActiveScaffold</title>
		<link>http://www.fiveclouds.com/2008/03/06/prototyping-with-activescaffold/</link>
		<comments>http://www.fiveclouds.com/2008/03/06/prototyping-with-activescaffold/#comments</comments>
		<pubDate>Thu, 06 Mar 2008 01:14:57 +0000</pubDate>
		<dc:creator>Philip</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://www.fiveclouds.com/2008/03/06/prototyping-with-activescaffold/</guid>
		<description><![CDATA[<p><img alt="Rails Code" align="left" hspace="5" src="http://www.fiveclouds.com/wp-content/uploads/2008/03/picture-3.png" /></p>
<p>There are many times when I need to put together an idea really quickly and lately I have been trying to use Ruby on Rails more, &#160;in the past couple of months I&#8217;ve been trying to make that more of a thing.</p>
<p>Lately I needed to mock up a few screens for basic data entry and I decided to put something together using rails. &#160;It was an easy start with a few migrations (Rails 2.0 style) to get a schema in place &#8211; then I considered a UI. &#160;Originally I thought about scaffold, but I was never a big&#8230;</p>]]></description>
			<content:encoded><![CDATA[<p><img alt="Rails Code" align="left" hspace="5" src="http://www.fiveclouds.com/wp-content/uploads/2008/03/picture-3.png" /></p>
<p>There are many times when I need to put together an idea really quickly and lately I have been trying to use Ruby on Rails more, &nbsp;in the past couple of months I&#8217;ve been trying to make that more of a thing.</p>
<p>Lately I needed to mock up a few screens for basic data entry and I decided to put something together using rails. &nbsp;It was an easy start with a few migrations (Rails 2.0 style) to get a schema in place &#8211; then I considered a UI. &nbsp;Originally I thought about scaffold, but I was never a big fan of generating lots of code that I would probably leave lying around. &nbsp;I wanted something that would give me a shell of functionality (in this case to allow some basic CRUD operations) but not litter the application with code that I would probably want to remove later. &nbsp;Enter <a href="http://www.activescaffold.com">ActiveScaffold</a>.</p>
<p>It only took a couple of hours to get a &nbsp;a five controllers in place to allow me to manage most of the data, &nbsp;was it bullet-proof ? err.. no &#8211; but then again it was functional and&nbsp;step in the right direction. &nbsp;Take a look at the <a href="http://demo.activescaffold.com/users">demos</a>, &nbsp;they are worth a look, and when you get a chance have a look throwing it in to see what it can do :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fiveclouds.com/2008/03/06/prototyping-with-activescaffold/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
