<?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>Conceptric &#187; ruby</title>
	<atom:link href="http://www.conceptric.co.uk/tag/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://www.conceptric.co.uk</link>
	<description>Ideas and Applications</description>
	<lastBuildDate>Fri, 12 Aug 2011 13:00:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Bundler for Sinatra dependencies</title>
		<link>http://www.conceptric.co.uk/bundler-for-sinatra-dependencies.htm</link>
		<comments>http://www.conceptric.co.uk/bundler-for-sinatra-dependencies.htm#comments</comments>
		<pubDate>Tue, 27 Jul 2010 16:40:34 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=396</guid>
		<description><![CDATA[Package dependencies are always a nightmare and with multiple applications on my server, each with their own set of Ruby gems, controlling the version they&#8217;re using has become important. I&#8217;ve been using Sinatra for more and more projects, but there came a point this week when I realised that I was in danger of accidentally [...]]]></description>
			<content:encoded><![CDATA[<p>Package dependencies are always a nightmare and with multiple applications on my server, each with their own set of Ruby gems, controlling the version they&#8217;re using has become important.</p>

<p>I&#8217;ve been using <a href="http://www.sinatrarb.com/">Sinatra</a> for more and more projects, but there came a point this week when I realised that I was in danger of accidentally upgrading gem versions without testing first.
<span id="more-396"></span></p>

<h3>Dependencies in crisis</h3>

<p>You see, my applications all use the system gems, and <code>require "gem_name"</code> to load the most recent local version.</p>

<p>As the number of applications on the server grew, I found that this had the effect of automatically upgrading all my applications whenever I upgraded a gem, whether intentional or otherwise.</p>

<p>Now I like to take advantage of bug fixes and new features of the latest releases whenever possible, but I don&#8217;t necessarily want to upgrade every application in a single mammoth coding session, or have to hold back the deployment of a new application until the others have been upgraded and fully tested.</p>

<h3>Gem and version dependency control</h3>

<p>It dawned on me that I needed some control over both the actual gems and the versions each application used.</p>

<h4>Simplicity</h4>

<p>The simplest approach is to control what it available in the application load path before loading it in the usual way, and these are the commands for the job.</p>

<p><code class="terminal">gem "gem_name", "gem_version"
require "gem_name"
</code></p>

<p>I tried this with some success, and quite a few of my applications are still using this method for now. But I decided to try using Bundler as a long term solution.</p>

<h4>Bundler</h4>

<p>If you want to know about <a href="http://gembundler.com/">Bundler</a> I suggest you try the <a href="http://github.com/carlhuda/bundler/">github repository</a> or some of the <a href="http://yehudakatz.com/?s=bundler&#038;x=0&#038;y=0">posts on Yehuda Katz blog</a>.</p>

<p>I found it pretty easy to integrate with Sinatra by following <a href="http://gembundler.com/sinatra.html">these instructions</a>, and my <code>Gemfile</code> looked like this.</p>

<p><code class="terminal">source "http://rubygems.org"
gem 'sinatra', '1.0'
gem 'haml', '3.0.13'
group :test do
  gem 'rspec', '1.3.0', :require => 'spec'
  gem 'rspec-rails', '1.3.2'
  gem 'cucumber', '0.8.3'
  gem 'cucumber-rails', '0.3.2'
  gem 'webrat', '0.7.1'
end
</code></p>

<p>Testing with WEBrick went like clockwork, working smoothly with both RSpec and Cucumber, but when I tried to get things running on Passenger this is what I saw.</p>

<p><img style="display:block; margin-left:auto; margin-right:auto;" src="http://www.conceptric.co.uk/wp-content/uploads/BundlerLoadError.jpeg" alt="BundlerLoadError.JPEG" border="0" width="500" height="234" /></p>

<p>This had me stumped for quite a while. I reinstalled Bundler; checked out the installation of Passenger, my $GEM_PATH, and the Ruby environment; nothing worked.</p>

<p>The solution turned out to be much simpler than all that: add the Bundler gem to the Gemfile dependencies.</p>

<p><code class="terminal">gem 'bundler', '0.9.26'
gem 'sinatra', '1.0'
gem 'haml', '3.0.13'
</code></p>

<p>I wish it had occurred to me earlier, but the simple ones never do. Anyhow, my Passenger deployments work perfectly, and I&#8217;ll be migrating all my Sinatra apps over to Bundler.</p>

<h3>Capistrano integration</h3>

<p>And if you, like me, want to use Bundler to manage dependencies during Capistrano deployment, you might like to try these <a href="http://gist.github.com/250979">useful recipes</a>.</p>

<script src="http://gist.github.com/250979.js?file=bundler_cap.rb"></script>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/bundler-for-sinatra-dependencies.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Evolving style after six months on Rails</title>
		<link>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm</link>
		<comments>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm#comments</comments>
		<pubDate>Thu, 04 Feb 2010 17:31:08 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[BDD]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=331</guid>
		<description><![CDATA[It's coming up to 6 months since I announced my transition from PHP to Ruby and I'm really getting the hang of my new web development toolkit by working on a personal project.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ruby-lang.org/en/">Ruby</a> which is an interpreted programming language, often called a scripting language, that I&#8217;ve been using alongside BASH for automating tasks on my Mac. Call me slow&#8230; no don&#8217;t, I&#8217;m quite sensitive, but I only recently coupled this with the Rails web <a href="http://en.wikipedia.org/wiki/Software_framework">software framework</a> and started working on a Ruby on Rails web application.</p>

<p>There&#8217;s no better way to learn a new language than to actually use it in real life. My Nature Notes started as a project for my partner in PHP, CodeIgniter actually, but progress was slow due to an enjoyment deficit.</p>

<p>Testing is the main reason that I grew unhappy with PHP, most of the tools were there, but the integration was patchy: the basics are all there in Ruby and it&#8217;s associated development frameworks and integrating new packages via ruby gems or plugins is simple.</p>

<p>I started using the built-in Rails testing tools, but for no particular reason I&#8217;ve moved on to <a href="http://rspec.info/">RSpec</a> for unit and functional Rails model and standalone Ruby code testing coupled with <a href="http://cukes.info/">Cucumber</a> based integration testing. I&#8217;ve found that I need both.</p>

<p>Cucumber tests try to exercise the whole software stack &#8211; views, controllers, models and even the database. The use of natural language makes it easier to translate user stories into the appropriate tests, though it still needs some discipline to ensure that the edge cases are covered: I don&#8217;t think clients could write these as acceptance tests.</p>

<p>Involving the whole stack makes tests a little brittle, how specific is too specific? I&#8217;ve managed to break tests by removing fullstops (periods) from the rendered HTML!</p>

<p>I think that this is where unit and functional testing with RSpec at the model level is indispensable. I test model associations, validations and custom business logic in that order, I draw the limit at all the ActiveRecord <abbr title="Create Read Update Delete">CRUD</abbr> functionality.</p>

<p>I&#8217;ve found that the development environment hasn&#8217;t really changed in the move, the same basic toolkit does PHP and Ruby.</p>

<p>I regularly use several code version control systems including Subversion, Git and Mercurial. Recently though I&#8217;ve increasingly turned to Git and GitHub. Like most good tools the more you use it the more attached you become, so I&#8217;ll have to force myself to use the equally fine Mercurial again soon. I love these distributed tools.</p>

<p>TextMate is my editor of choice for Rails development. I&#8217;ve tried to use Netbeans <abbr title="Integrated Development Environment">IDE</abbr>, I use this for Java, but it seems like overkill. TextMate is quicker, simpler and provides the tools I need via the a range of bundles.</p>

<p>I have to admit that the code syntax highlighting is the most useful feature because I like using the command line too much, but I&#8217;m increasingly using code completion and I&#8217;m going to try the <a href="http://code.google.com/p/zen-coding/">Zen coding</a> bundles for HTML and CSS, I don&#8217;t like the default tools much.</p>

<p>That&#8217;s a round up of my current practice, more about the resulting software once I&#8217;ve decided to move on to a public beta.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/evolving-style-after-six-months-on-rails.htm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Switching to Rails</title>
		<link>http://www.conceptric.co.uk/switching-to-rails.htm</link>
		<comments>http://www.conceptric.co.uk/switching-to-rails.htm#comments</comments>
		<pubDate>Sun, 30 Aug 2009 18:30:00 +0000</pubDate>
		<dc:creator>James Whinfrey</dc:creator>
				<category><![CDATA[Personal Perspectives]]></category>
		<category><![CDATA[Software Engineering]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[productivity]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ruby on rails]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.conceptric.co.uk/?p=302</guid>
		<description><![CDATA[I know that a good developer should choose the best tool for the job in hand, but their own productivity and inspiration must inform the decision in selecting the best tool.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working on a personal project based on CodeIgniter and it&#8217;s been uphill work. I finally lost patience with both the framework and language and followed the advice given on <a href="http://www.conceptric.co.uk/codeigniter-test-coverage.htm">my last post about code testing</a>.</p>

<p>I&#8217;ve used Ruby for scripting, and deploying PHP applications with custom Capistrano recipes for years now, but I&#8217;ve never tried any of the available web frameworks.</p>

<p>This week I switched to Ruby on Rails, and I&#8217;ve accomplished more in a couple of days than in a couple of months with CodeIgniter.</p>

<p>I&#8217;m not trying to claim that there&#8217;s anything fundamentally wrong with PHP, so don&#8217;t beat me up over it, but I find working with Ruby and Java much more intuitive, enjoyable and productive: it&#8217;s a personal choice, I feel more inspired.</p>

<p>I&#8217;m particularly loving the default support for <a href="http://guides.rubyonrails.org/testing.html">unit, functional and integration testing</a>; I now feel in control of my code and I&#8217;ve yet to explore the full range of testing frameworks and approaches available for Rails.</p>

<p>I know that <a href="http://cakephp.org/">CakePHP</a> mirrors Rails functionality very closely, but I&#8217;m afraid it&#8217;s the PHP language that I find too ugly to love &#8211; personal choice again, don&#8217;t shoot &#8211; consequently this is one developer who may have written his last line of PHP code&#8230;&#8230; maybe.</p>

<p>I&#8217;m now hoping to have the first release of the nature and wildlife recording application I&#8217;ve been promising Clare for&#8230;&#8230; much too long, up and running in the next couple of weeks.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.conceptric.co.uk/switching-to-rails.htm/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

