<?xml version="1.0" encoding="UTF-8"?>
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
  <title>RubyIreland - Home</title>
  <id>tag:rubyireland.com,2007:mephisto/</id>
  <generator version="0.7.3" uri="http://mephistoblog.com">Mephisto Noh-Varr</generator>
  <link href="http://rubyireland.com/feed/atom.xml" rel="self" type="application/atom+xml"/>
  <link href="http://rubyireland.com/" rel="alternate" type="text/html"/>
  <updated>2007-08-02T17:42:10Z</updated>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Aidan</name>
    </author>
    <id>tag:rubyireland.com,2007-08-02:12</id>
    <published>2007-08-02T15:32:00Z</published>
    <updated>2007-08-02T17:42:10Z</updated>
    <link href="http://rubyireland.com/2007/8/2/rubyireland-members-where-are-you-based" rel="alternate" type="text/html"/>
    <title>RubyIreland members: where are you based?</title>
<content type="html">
            &lt;p&gt;&amp;lt;noscript&gt; &lt;a href=&quot;http://www.polldaddy.com&quot;&gt;Surveys&lt;/a&gt; - &lt;a href=&quot;http://www.polldaddy.com/poll.asp?p=80732&quot;&gt;Take Our Poll&lt;/a&gt; &amp;lt;/noscript&gt;&lt;/p&gt;

&lt;p&gt;I though it would be interesting to see what the geographical spread of Ruby Ireland members is. So let us know by taking the poll above. If I've missed your city/town/region/country, select other and enter the name in the text box.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Rob</name>
    </author>
    <id>tag:rubyireland.com,2007-05-28:9</id>
    <published>2007-05-28T10:03:00Z</published>
    <updated>2007-05-28T10:14:04Z</updated>
    <category term="capistrano connection failure"/>
    <link href="http://rubyireland.com/2007/5/28/handling-connection-failures-with-capistrano" rel="alternate" type="text/html"/>
    <title>Handling connection failures with capistrano</title>
<content type="html">
            &lt;p&gt;We&#8217;ve had some problems with handling connection failures/timeouts with capistrano, because it currently (1.99.1) causes capistrano to exit from an exception trigged by Net::SSH. We wanted to handle this just like a command failure. I&#8217;ve not had time to form a proper patch for capistrano to submit upstream for this because of an impending deadline, but we&#8217;ve put a monkey patch in place (re-opening classes in ruby is just, well, awesome). I will of course write a proper patch for this once I&#8217;ve time, including being more specific about the Exceptions we wish to catch  :)&lt;/p&gt;


	&lt;p&gt;You can use this to have capistrano treat a connection failure as a command failure:&lt;/p&gt;


&lt;code&gt;
&lt;pre&gt;
module Capistrano
  class Configuration
    module Connections    
      # Hack, we return a fake connection which always reports closed.
      class FakeConnection
        def initialize(server)
          @server = server
        end

        def open_channel(&#38;block)
          logger.important &quot;could not open channel&quot;, @server if logger
          { :closed =&amp;gt; true, :server =&amp;gt; @server }
        end
      end

      class DefaultConnectionFactory
        def wrapped_connect_to(server)
          begin
            connection = capistrano_connect_to(server)
          rescue Exception
            FakeConnection.new(server)
          end
        end

        alias capistrano_connect_to connect_to
        alias connect_to wrapped_connect_to
      end
    end
end
&lt;/pre&gt;
&lt;/code&gt;
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Rob</name>
    </author>
    <id>tag:rubyireland.com,2007-05-24:6</id>
    <published>2007-05-24T14:01:00Z</published>
    <updated>2007-05-24T14:02:10Z</updated>
    <link href="http://rubyireland.com/2007/5/24/attr_history-almost-perfect" rel="alternate" type="text/html"/>
    <title>attr_history, almost perfect</title>
<content type="html">
            &lt;p&gt;I wanted to have an &lt;code&gt;attr_history&lt;/code&gt; method that would behave like &lt;code&gt;attr_accessor :foo&lt;/code&gt; but also keep a &lt;code&gt;foo_history&lt;/code&gt; variable around so I can look back through the values the variable held during it&#8217;s life time.&lt;/p&gt;


	&lt;p&gt;Googling around and some help from Chris McGrath led me to write this:&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
module AttrHistory
  def attr_history(*syms)
    syms.each { |sym|
      class_eval(&amp;lt;&amp;lt;-EOS, __FILE__, __LINE__)
        attr_reader :#{sym}
        attr_reader :#{sym}_history

        def #{sym}=(value)
          @#{sym}_history ||= []
          if @#{sym}
            @#{sym}_history &amp;lt;&amp;lt; @#{sym}.dup
            @#{sym}.replace(value)
          else
            @#{sym} = value
          end
        end

        def has_#{sym}_history?
          not @#{sym}_history.empty?
        end
      EOS
    }
  end
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;I was really pleased with the fact it worked, even that it was possible. I love the the shiney things you can do with &lt;code&gt;*_eval&lt;/code&gt; and so on. There is just one problem, in that I can&#8217;t get it to behave quite like &lt;code&gt;attr_accessor&lt;/code&gt; does. Because of the way Ruby parses code (explained at: http://www.rubycentral.com/book/language.html#UO) I end up having to use &lt;code&gt;self.foo=&lt;/code&gt; when referring to the setter, because otherwise ruby thinks it&#8217;s a local variable. That&#8217;s a real shame in this instance, as I actually want the stuff to be available in an &#8220;DSL&#8221;-like environment similar to RSpec. As it is, the user must prefix the setters, &lt;code&gt;self.foo=&lt;/code&gt; instead of simply &lt;code&gt;foo=&lt;/code&gt;, which is a bit ugly. Oh well.&lt;/p&gt;


The code for using Spex (which I&#8217;ll release soon, certainly before the next meeting) ends up looking like:
&lt;pre&gt;
&lt;code&gt;
klass :name =&amp;gt; /^Xsd(AnyUri|Byte|HexBinary|String|Xmltext)$/ do
  self.name = 'String'
end
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;The &#8216;self.&#8217; really bugs me. If anyone knows how to fix that, please let me know :)&lt;/p&gt;


	&lt;p&gt;Chris made a good suggestion that I just pass in a variable &#8216;k&#8217; to the block so they can do &lt;code&gt;k.name =&lt;/code&gt; which would resolve properly and not be so ugly. I think I&#8217;ll go with that for now, but I&#8217;d love to properly &#8220;fix it&#8221;. Not sure it&#8217;s possible though.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Aidan</name>
    </author>
    <id>tag:rubyireland.com,2007-05-23:5</id>
    <published>2007-05-23T11:06:00Z</published>
    <updated>2007-05-23T11:10:10Z</updated>
    <category term="apress"/>
    <category term="books"/>
    <category term="rails"/>
    <category term="ruby"/>
    <link href="http://rubyireland.com/2007/5/23/free-apress-books" rel="alternate" type="text/html"/>
    <title>Free Apress books</title>
<content type="html">
            &lt;p&gt;Apress sent us some review copies of some of their recent ruby/rails books along with some Apress branded notepads. &lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://rubyireland.com/assets/2007/5/23/apress_books.JPG&quot;&gt;&lt;/p&gt;

&lt;p&gt;The books are&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beginning Ruby, Cooper&lt;/li&gt;
&lt;li&gt;Rails Solutions, Williams&lt;/li&gt;
&lt;li&gt;Beginning Ruby on Rails E-commerce, Hellsten, Laine&lt;/li&gt;
&lt;li&gt;Practical Ruby Gems, Berube&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are interested in reviewing any of these books see the &lt;a href=&quot;http://groups.google.com/group/ruby_ireland/browse_thread/thread/fcf2f62fc442b5e6&quot;&gt;thread on the mailing list&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;P.S. Thanks to Apress for sending these out.&lt;/p&gt;
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Rob</name>
    </author>
    <id>tag:rubyireland.com,2007-05-22:4</id>
    <published>2007-05-22T20:10:00Z</published>
    <updated>2007-05-22T20:18:41Z</updated>
    <link href="http://rubyireland.com/2007/5/22/dude-where-s-my-string" rel="alternate" type="text/html"/>
    <title>Dude, where's my String?</title>
<content type="html">
            &lt;p&gt;Ruby passes by reference, so I thought the following code would work just fine&#8230;&lt;/p&gt;


&lt;pre&gt;
&lt;code&gt;
#!/usr/bin/ruby

class Filter
  @@filters = []

  def Filter.apply(string)
    # We don't actually use the Filter instance,
    # but don't worry about that.
    @@filters.each { |f| yield string }
  end

  def initialize
    @@filters &amp;lt;&amp;lt; self
  end
end

Filter.new()
Filter.new()
Filter.new()
Filter.new()

Filter.apply('foo') { |string|
  string += 'h'
  puts string
}
&lt;/code&gt;
&lt;/pre&gt;

	&lt;p&gt;So, after the last iteration &#8216;foohhhh&#8217; should be printed. But no. Hmm. But Ruby passes by reference&#8230; So&#8230; Eh?&lt;/p&gt;


	&lt;p&gt;I asked on #ruby.ie on freenode and Chris McGrath suggested I try &lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; instead of &lt;code&gt;+=&lt;/code&gt;, it worked. The deal is that &lt;code&gt;string += 'h'&lt;/code&gt; translates to &lt;code&gt;string = string + 'h'&lt;/code&gt;, which is fine, obvious even. The problem is that the &lt;code&gt;+&lt;/code&gt; operator causes a copy of the combined string to be returned, and &lt;code&gt;string&lt;/code&gt; adjusted to point to the new instance of &lt;code&gt;String&lt;/code&gt;. I would have expected this to change &lt;code&gt;string&lt;/code&gt; in all scopes, but it only affected the local scope. Subsequent filters did not see the new &lt;code&gt;string&lt;/code&gt;.&lt;/p&gt;


&lt;code&gt;&amp;lt;&amp;lt;&lt;/code&gt; differs in that it is a method on the &lt;code&gt;string&lt;/code&gt; instance itself which does an in-place change. This allows the other filters to see the change. Subtle, and a little surprising to me. Nice to know the fix, thanks Chris :)
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>Olivier</name>
    </author>
    <id>tag:rubyireland.com,2007-05-16:3</id>
    <published>2007-05-16T19:30:00Z</published>
    <updated>2007-05-16T19:59:57Z</updated>
    <category term="rails"/>
    <category term="sqlite3"/>
    <category term="test"/>
    <link href="http://rubyireland.com/2007/5/16/speed-up-rails-tests-using-an-in-memory-database" rel="alternate" type="text/html"/>
    <title>Speed up Rails tests using an in-memory database</title>
<content type="html">
            &lt;p&gt;One cheap solution to speed up your unit tests is to configure the test database to run in-memory. If your code isn&#8217;t database specific, you&#8217;ll simply have to follow &lt;a href=&quot;http://nubyonrails.com/articles/2006/06/01/san-francisco-sqlite3-memory-tests-asteroids&quot;&gt;Geoffrey Grosenbach&#8217;s instructions&lt;/a&gt;.&lt;/p&gt;


Other links you might want to check out on this topic:
	&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;http://blog.seagul.co.uk/articles/2006/02/08/in-memory-sqlite-database-for-rails-testing&quot;&gt;if you want to do it by hand, without the plugin&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href=&quot;http://www.artofmission.com/articles/2007/3/4/speed-up-tests-with-sqlite3-in-memory&quot;&gt;if you have any problem with sqlite3 you might want to check this out&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
          </content>  </entry>
  <entry xml:base="http://rubyireland.com/">
    <author>
      <name>admin</name>
    </author>
    <id>tag:rubyireland.com,2007-04-19:1</id>
    <published>2007-04-19T11:18:00Z</published>
    <updated>2007-04-19T21:27:27Z</updated>
    <link href="http://rubyireland.com/2007/4/19/welcome-to-rubyireland-com" rel="alternate" type="text/html"/>
    <title>Welcome to RubyIreland.com</title>
<content type="html">
            &lt;br /&gt;
&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Welcome to RubyIreland.com, the website of the Ruby Ireland group. We share one passion: the Ruby programming language.&lt;/p&gt;
&lt;h2&gt;Participate&lt;/h2&gt;
&lt;p&gt;If &lt;strong&gt;Ruby interests you&lt;/strong&gt;, even if you have no experience with it, do not hesitate to &lt;strong&gt;join us&lt;/strong&gt;. To get in touch, you are encouraged to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;participate on the &lt;a href=&quot;http://groups.google.com/group/ruby_ireland&quot;&gt;mailing list&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;chat on our irc channel: &lt;a href=&quot;irc://irc.freenode.net/#ruby.ie&quot;&gt;#ruby.ie on irc.freenode.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;engage in our monthly meetings &amp;lt;q&gt;Ruby Tuesdays&amp;lt;/q&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Looking forward to meeting you soon!&lt;/p&gt;
          </content>  </entry>
</feed>
