<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Floehopper: Tag syntax</title>
    <link>http://blog.floehopper.org/articles/tag/syntax?tag=syntax</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>thoughts on the bergy bits of life</description>
    <item>
      <title>Vim Learning Curve</title>
      <description>&lt;p&gt;Because I&amp;#8217;ve been doing a lot of &lt;a href="http://blog.floehopper.org/articles/2008/03/13/remote-pair-programming"&gt;remote pair programming&lt;/a&gt; using &lt;a href="http://www.vim.org/"&gt;vim&lt;/a&gt; and &lt;a href="http://www.gnu.org/software/screen/"&gt;screen&lt;/a&gt;,  I&amp;#8217;ve been making a real effort to improve my vim skills in order to be more productive and feel like I&amp;#8217;ve made some progress. &lt;a href="http://blog.seagul.co.uk"&gt;Chris&lt;/a&gt; has rightly suggested that the only way to really improve is to make vim your editor of choice even when not remote pairing, so that&amp;#8217;s what I&amp;#8217;ve been trying to do. I&amp;#8217;ve come across a few useful but random bits and pieces which I thought I&amp;#8217;d record in case they were useful to anyone else&amp;#8230;&lt;/p&gt;


	&lt;h2&gt;Textile&lt;/h2&gt;


	&lt;p&gt;I&amp;#8217;m using a &lt;a href="http://rubychan.de/share/textile.vim"&gt;vim syntax file&lt;/a&gt; for &lt;a href="http://hobix.com/textile/"&gt;Textile&lt;/a&gt; written by Kornelius Kalnbach to write this article.&lt;/p&gt;


	&lt;h2&gt;svn blame&lt;/h2&gt;


	&lt;p&gt;I&amp;#8217;ve found Tammer Saleh&amp;#8217;s &lt;a href="http://tammersaleh.com/posts/quick-vim-svn-blame-snippet"&gt;key mapping&lt;/a&gt; for &lt;a href="http://svnbook.red-bean.com/en/1.0/re02.html"&gt;svn blame&lt;/a&gt; useful&amp;#8230;&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;  vmap gl :&amp;lt;C-U&amp;gt;!svn blame &amp;lt;C-R&amp;gt;=expand(&amp;quot;%:p&amp;quot;) &amp;lt;CR&amp;gt; \| sed -n &amp;lt;C-R&amp;gt;=line(&amp;quot;'&amp;lt;&amp;quot;) &amp;lt;CR&amp;gt;,&amp;lt;C-R&amp;gt;=line(&amp;quot;'&amp;gt;&amp;quot;) &amp;lt;CR&amp;gt;p &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;I decided to invest a bit of time understanding how it worked and broke it down as follows&amp;#8230;&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;  # key mapping for visual mode
  vmap gl
  # remove all characters between the cursor position and the beginning of the line
  :&amp;lt;C-U&amp;gt;
  # current file with full path
  &amp;lt;C-R&amp;gt;=expand(&amp;quot;%:p&amp;quot;) &amp;lt;CR&amp;gt;
  # pipe std out to sed which only outputs line N to line M
  \| sed -n N,M
  # line number of first line of selection
  &amp;lt;C-R&amp;gt;=line(&amp;quot;'&amp;lt;&amp;quot;) &amp;lt;CR&amp;gt;
  # line number of last line of selection
  &amp;lt;C-R&amp;gt;=line(&amp;quot;'&amp;gt;&amp;quot;) &amp;lt;CR&amp;gt;
  # print output
  p &amp;lt;CR&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;h2&gt;Search &amp;#38; Replace&lt;/h2&gt;


	&lt;p&gt;At the end of last week, &lt;a href="http://blog.seagul.co.uk"&gt;Chris&lt;/a&gt; &amp;#38; I found out from Ibrahim Ahmed&amp;#8217;s blog how to &lt;a href="http://www.ibrahim-ahmed.com/2008/01/find-and-replace-in-multiple-files-in.html"&gt;search and replace across multiple files&lt;/a&gt;...&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;  # select file on which to operate
  :args path/with/wildcards
  # find pattern, replace with replacement, and save file
  :argdo %s/pattern/replacement/ge | update&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;h2&gt;vimdiff&lt;/h2&gt;


	&lt;p&gt;&lt;a href="http://www.vim.org/htmldoc/diff.html"&gt;&lt;code&gt;vimdiff&lt;/code&gt;&lt;/a&gt; seems like a nice tool, but unfortunately it doesn&amp;#8217;t immediately play well with &lt;a href="http://svnbook.red-bean.com/en/1.0/re09.html"&gt;&lt;code&gt;svn diff&lt;/code&gt;&lt;/a&gt; and its &lt;code&gt;--diff-cmd&lt;/code&gt; option. There seem to be a couple of alternatives: (a) write a &lt;a href="http://svn.haxx.se/users/archive-2005-04/1048.shtml"&gt;wrapper script for &lt;code&gt;vimdiff&lt;/code&gt;&lt;/a&gt; which works with &lt;code&gt;--diff-cmd&lt;/code&gt;; or (b) write a &lt;a href="http://erik.thauvin.net/blog/comments.jsp?postid=1024"&gt;script which uses &lt;code&gt;svn cat&lt;/code&gt; and then calls &lt;code&gt;vimdiff&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;


	&lt;h2&gt;Test::Unit&lt;/h2&gt;


	&lt;p&gt;One of the things I really want to be able to do, is run Ruby &lt;a href="http://www.ruby-doc.org/stdlib/libdoc/test/unit/rdoc/classes/Test/Unit.html"&gt;Test::Unit&lt;/a&gt; tests and view the output, so I can jump to the line where an assertion failed. I haven&amp;#8217;t managed to find anything suitable on the web, so here&amp;#8217;s my first attempt&amp;#8230;&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_default "&gt;  function! Ruby_run_tests()
    let results = tempname()
    set splitbelow
    silent execute &amp;quot;:! ruby % &amp;gt; &amp;quot; . results . &amp;quot; 2&amp;gt;&amp;amp;1 &amp;quot;
    silent execute &amp;quot;:10 sview &amp;quot; . results
  endfunction

  map &amp;lt;silent&amp;gt; &amp;lt;F7&amp;gt; :call Ruby_run_tests()&amp;lt;cr&amp;gt;
  imap &amp;lt;silent&amp;gt; &amp;lt;F7&amp;gt; &amp;lt;ESC&amp;gt;&amp;lt;F7&amp;gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;I&amp;#8217;m sure this isn&amp;#8217;t the best way of doing it, but when you put this in your vimrc file, pressing the &lt;code&gt;F7&lt;/code&gt; key runs the current file using Ruby and pipes the results to a temporary file. This temporary file is opened in a read-only window 10 lines high at the bottom of the screen. By moving the cursor onto the relevant line of any stack trace, you can then use &amp;#8220;goto file&amp;#8221; key sequence &lt;code&gt;gf&lt;/code&gt; to goto the failing assertion. Although for some reason this only seems to work the first time round for me.&lt;/p&gt;


	&lt;p&gt;Ideally I&amp;#8217;d like to be able to do the equivalent of &amp;#8220;run focussed test&amp;#8221; in &lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt;, which should be quite straightforward, but that&amp;#8217;ll have to wait for another day.&lt;/p&gt;


	&lt;p&gt;In the meantime, I&amp;#8217;d love to hear from anyone else who has useful vim tricks for &lt;a href="http://www.ruby-lang.org/"&gt;Ruby&lt;/a&gt; development. I&amp;#8217;ll be bookmarking any useful links I find on &lt;a href="http://del.icio.us/jamesthecat/vim"&gt;del.icio.us&lt;/a&gt;.&lt;/p&gt;</description>
      <pubDate>Sat, 12 Jul 2008 22:52:35 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c7afcd35-0c86-40a8-88c1-d0485fbc2477</guid>
      <author>James Mead</author>
      <link>http://blog.floehopper.org/articles/2008/07/12/vim-learning-curve</link>
      <category>vim</category>
      <category>svn</category>
      <category>diff</category>
      <category>blame</category>
      <category>syntax</category>
      <category>textile</category>
      <category>search</category>
      <category>replace</category>
      <category>testing</category>
      <category>textmate</category>
    </item>
    <item>
      <title>New Mocha Docs</title>
      <description>&lt;p&gt;Spurred on by &lt;a href="http://glu.ttono.us/articles/2006/09/02/mocking-models#comment-1106"&gt;Thorsten&amp;#8217;s comment&lt;/a&gt; on &lt;a href="http://glu.ttono.us/"&gt;Gluttonous&amp;#8217; blog&lt;/a&gt; and a mention of &lt;a href="http://mocha.rubyforge.org"&gt;Mocha&lt;/a&gt; in the &lt;a href="http://cleanair.highgroove.com/articles/2006/09/03/ruby_on_rails_enterprise_capistrano_mocked_models_class_variables_rest"&gt;Top 5 Rails Stories of the Week&lt;/a&gt;, I&amp;#8217;ve given the Mocha &lt;a href="http://mocha.rubyforge.org"&gt;documentation&lt;/a&gt; a major overhaul.&lt;/p&gt;


	&lt;p&gt;Now the &lt;a href="http://rdoc.sourceforge.net/"&gt;RDoc&lt;/a&gt; only shows the public &lt;span class="caps"&gt;API&lt;/span&gt; which should hopefully improve the signal-to-noise ratio and show how simple it is to use.&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/classes/Mocha/AutoVerify.html"&gt;Create traditional mock objects&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/classes/Mocha/MockMethods.html"&gt;Set expectations on traditional mock objects&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/classes/Object.html"&gt;Set expectations on real (non-mock) classes&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/classes/Mocha/Expectation.html"&gt;Make expectations more specific or define behaviour of stub&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


I&amp;#8217;ve also had a play with &lt;a href="http://coderay.rubychan.de/"&gt;CodeRay&lt;/a&gt; and generated syntax-highlighted examples.
	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/examples/misc.html"&gt;Quick Start&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/examples/mocha.html"&gt;Traditional mocking&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://mocha.rubyforge.org/examples/stubba.html"&gt;Setting expectations on real (non-mock) classes&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;Good general information on mocking&amp;#8230;&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;a href="http://www.martinfowler.com/articles/mocksArentStubs.html"&gt;Mocks Aren&amp;#8217;t Stubs&lt;/a&gt; by &lt;a href="http://www.martinfowler.com/"&gt;Martin Fowler&lt;/a&gt;&lt;/li&gt;
		&lt;li&gt;&lt;a href="http://www.jmock.org/yoga.html"&gt;JMock &amp;#8211; Yoga for your unit tests&lt;/a&gt; by &lt;a href="http://nat.truemesh.com/"&gt;Nat Pryce&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;</description>
      <pubDate>Sun, 03 Sep 2006 18:20:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:d79eed64-175c-4108-887d-e122324a8696</guid>
      <author>James Mead</author>
      <link>http://blog.floehopper.org/articles/2006/09/03/new-mocha-docs</link>
      <category>mocha</category>
      <category>stubba</category>
      <category>test</category>
      <category>testing</category>
      <category>mock</category>
      <category>stub</category>
      <category>jmock</category>
      <category>coderay</category>
      <category>syntax</category>
      <category>highlight</category>
      <category>mocking</category>
      <category>stubbing</category>
      <category>ruby</category>
      <category>rails</category>
    </item>
  </channel>
</rss>
