<?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>The Brian Olore Story &#187; training</title>
	<atom:link href="http://brian.olore.net/wp/tag/training/feed/" rel="self" type="application/rss+xml" />
	<link>http://brian.olore.net</link>
	<description>Less of a story, more of a brain dump</description>
	<lastBuildDate>Sun, 18 Dec 2011 17:19:51 +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>Compleat Rubyist &#8211; Day 1</title>
		<link>http://brian.olore.net/wp/2010/06/compleat-rubyist-day-1/</link>
		<comments>http://brian.olore.net/wp/2010/06/compleat-rubyist-day-1/#comments</comments>
		<pubDate>Sat, 19 Jun 2010 12:25:21 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[work]]></category>
		<category><![CDATA[compleatrubyist]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://brian.olore.net/?p=193</guid>
		<description><![CDATA[Day 1 of 2 of my notes for the Compleat Rubyist training course Ruby Versions and Implementations  &#8211; David http://ruby-versions.net/ &#8211; David&#8217;s home for ruby versions &#38; implementations for learning &#38; historical reference Ruby version manager &#8211; http://rvm.beginrescueend.com &#8211; lets you install several ruby versions/implementations and easily switch between (including your own custom compiled version). [...]]]></description>
			<content:encoded><![CDATA[<p>Day 1 of 2 of my notes for the <a href="http://www.compleatrubyist.com">Compleat Rubyist</a> training course</p>
<h3><span style="text-decoration: underline;">Ruby Versions and Implementations  &#8211; David</span></h3>
<p><a href="http://ruby-versions.net/">http://ruby-versions.net/</a> &#8211; David&#8217;s home for ruby versions &amp; implementations for learning &amp; historical reference</p>
<p>Ruby version manager &#8211; <a href="http://rvm.beginrescueend.com">http://rvm.beginrescueend.com</a> &#8211; lets you install several ruby versions/implementations and easily switch between (including your own custom compiled version). Suggestion &#8211; don&#8217;t install as root, even though it is allowed.</p>
<p>Notes on a few of the existing options:</p>
<ul>
<li>MacRuby &#8211; interacts with Cocoa</li>
<li> Rubinius &#8211; Ruby in Ruby</li>
<li> JRuby &#8211; Ruby on JVM</li>
<li> REE &#8211; optimized &#8211; created by Phusion Passenger team</li>
<li> MagLev &#8211; built in object persistence, repository instead of files, smalltalk-ish</li>
<li> IronRuby &#8211; Ruby on .NET</li>
<li> URABE &#8211; ?</li>
</ul>
<p>rvm allows you to compare performance between versions/implementation:</p>
<pre>rvm ruby-1.8.6,ruby1.9.2 benchmark filename.rb</pre>
<p>Why does everyone use 1.8 instead of 1.9?</p>
<ul>
<li>Same amount of people are using it as last year (like almost no one)</li>
<li>Rails considerations</li>
<li>1.9 is not 100% backwards compatible</li>
<li>1.8.7 backported many of the features of 1.9, so people feel safer</li>
</ul>
<p>Ruby Enterprise Edition has major memory and speed improvements</p>
<p><strong>Highlights of changes between 1.8 &amp; 1.9</strong></p>
<ul>
<li> Enumerators</li>
<li> Method parameters</li>
<li> Block variable binding &amp; scope</li>
<li> Syntax changes</li>
</ul>
<p><strong><span id="more-193"></span>Discussion</strong></p>
<ul>
<li>&#8220;Ruby 1.9 was plenty different enough to be 2.0&#8243; &#8211; David</li>
<li>1.9.1 is currently the stable supported version and has been for about a year.</li>
<li>1.8.6 to 1.8.7 was a big jump &#8211; major backporting of 1.9 features into 1.8</li>
<li>1.8.7 was a safe harbor for those that wanted 1.9 features but were scared of 1.9</li>
<li>rails3 + ruby 1.9.1 = segfaults <img src='http://brian.olore.net/wp/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />    … works with certain revisions of 1.9.2 HEAD</li>
</ul>
<p><strong>Enumerator object &#8211; 1.9</strong></p>
<ul>
<li>mixes in Enumerable</li>
<li>you write the &#8216;each&#8217; method
<ul>
<li> borrow from another object (can be lazy)</li>
<li> or</li>
<li> pass in code block on instantiation (via a yielder)</li>
</ul>
</li>
<li>once it knows how to &#8216;each&#8217;, it can do select, map, each_cons ….</li>
<li>1.8.6 &#8211; require &#8216;enumerator&#8217; &#8211; Enumerable::Enumerator</li>
<li>1.9.x &#8211; no require needed &#8211; promoted to top level &#8216;Enumerator&#8217;</li>
</ul>
<p>side bar: each_cons vs each_slice</p>
<p>Note to self: I need to memorize each/select/map/collect</p>
<p>What methods do I get with Enumerator that I don&#8217;t get with Enumerable (Array)?</p>
<pre>Enumerator.instance_methods - Array.instance_methods
:with_index, :with_object, :next, :rewind</pre>
<p><strong>Method argument semantics<br />
</strong>required args can now come after optional args<br />
def m(a, b=1, c)<br />
def m(a, *b, c)<br />
def m((a,b),c)<br />
required arguments get filled first</p>
<p><strong>Block variable scope</strong></p>
<ul>
<li>probably the most important/annoying/significant change</li>
<li>breaks stuff in surprising ways</li>
<li>but if it does break stuff, you were likely doing something buggy before</li>
</ul>
<p>Example 1:</p>
<pre>a = [1,2,3]
a.each {|x| p x}</pre>
<p>x gets value of 3 when you are done</p>
<p>|x| literally assigns x ( |x=…| ), so it becomes available outside the block</p>
<p>Example 2:</p>
<pre>a = 1
array.each { a = 2 }</pre>
<p>does not change the value of a</p>
<ul>
<li>Matz said he wished he had done this from the beginning</li>
<li>Unifies the parameter syntax between methods &amp; lambas</li>
</ul>
<p><strong>1.9 Miscellany</strong></p>
<ul>
<li>no more String#each
<ul>
<li>&#8220;Hello&#8221;[0] = &#8220;H&#8221;  #in 1.8 it returns 72</li>
</ul>
</li>
<li>new instance_exec is like instance_eval but takes a param to inject</li>
</ul>
<p>JRuby &#8211; ask David about using ArrayList instead of [] in playpoker.rb</p>
<h3><span style="text-decoration: underline;">The Testing Landscape</span></h3>
<p>Test::Unit is gone in 1.9<br />
Test::Unit::TestCase -&gt; Mini::Test::TestCase<br />
Mini::Test has a new option: refute_match<br />
require &#8216;shoulda&#8217; &#8211; makes it more like RSpec without going full RSpec<br />
RSpec is the defacto standard for Behavior-driven testing</p>
<p>Jeremy &#8211; wrote &#8216;context&#8217; and &#8216;match&#8217;<br />
Given/When/Then &#8211; cucumber is most popular<br />
&#8220;Think in units of features rather than units of code&#8221; &#8211; Gregory<br />
require &#8216;could&#8217; &#8211; another tool &#8211; include feature test right in the same file as tests</p>
<p><strong>Test data </strong></p>
<ul>
<li>YAML/CSV &#8211; hard to maintain, csv is kinda nice because you can open in spreadsheet program (or rather your testers can)</li>
<li>model_stubbing  <a href="http://github.com/technoweenie/model_stubbing">http://github.com/technoweenie/model_stubbing</a></li>
<li>Factories is the new hotness
<ul>
<li> FactoryGirl</li>
<li> Machinist &#8211; <a href="http://github.com/notahat/machinist">http://github.com/notahat/machinist</a>
<ul>
<li> create shams &amp; blueprints</li>
<li> &#8220;way slower&#8221; than fixtures</li>
</ul>
</li>
</ul>
</li>
<li>mocking/stubbing
<ul>
<li> can extend a class to do it</li>
<li> can use OpenStruct to do it require &#8216;ostrich&#8217;</li>
<li> Jeremy likes using &#8216;rr&#8217;</li>
<li> RSpec has it&#8217;s own stubbing</li>
<li> flexmock</li>
</ul>
</li>
<li>Proxies
<ul>
<li>Proxies are like mocks &amp; stubs &amp; real code combined</li>
<li>Proxies are the Ken Jennings of mocks &amp; stubs</li>
</ul>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://brian.olore.net/wp/2010/06/compleat-rubyist-day-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

