<?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>Delivering Quality &#187; Ruby</title>
	<atom:link href="http://www.markdeepwell.com/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.markdeepwell.com</link>
	<description>A Software Developers View of the World</description>
	<lastBuildDate>Sat, 31 Dec 2011 22:41:24 +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>Ruby Subversion Bindings</title>
		<link>http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/</link>
		<comments>http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/#comments</comments>
		<pubDate>Sun, 27 Jun 2010 05:30:01 +0000</pubDate>
		<dc:creator>Mark</dc:creator>
				<category><![CDATA[Basics]]></category>
		<category><![CDATA[Software Bindings]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby Subversion Bindings]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[SVN]]></category>

		<guid isPermaLink="false">http://www.markdeepwell.com/?p=516</guid>
		<description><![CDATA[Subversion has bindings for a variety of languages: Java, Perl, Python and Ruby. Of these I am most interested in the Ruby bindings as I&#8217;m building a Rails application. Unfortunately the documentation is completely lacking and bits of it are scattered throughout the web. This is an attempt to provide the code and how-to for [...]]]></description>
			<content:encoded><![CDATA[<p>Subversion has bindings for a variety of languages: Java, Perl, Python and Ruby. Of these I am most interested in the Ruby bindings as I&#8217;m building a Rails application. Unfortunately the documentation is completely lacking and bits of it are scattered throughout the web. This is an attempt to provide the code and how-to for the most common tasks.</p>
<p>Before we get to the code, validate you have the Ruby Subversion bindings installed correctly by running irb from a terminal:</p>
<p>irb(main):001:0&gt; require &#8216;svn/client&#8217;<br />
=&gt; true</p>
<p>Onto the source code. Start it off by including the required svn modules:</p>
<pre class="brush: ruby; title: ; notranslate">
require &quot;svn/core&quot;
require &quot;svn/client&quot;
require &quot;svn/wc&quot;
require &quot;svn/repos&quot;
</pre>
<p>Then setup the context with your subversion credentials:</p>
<pre class="brush: ruby; title: ; notranslate">
ctx = Svn::Client::Context.new()
ctx.add_simple_provider
ctx.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_USERNAME] = 'username'
ctx.auth_baton[Svn::Core::AUTH_PARAM_DEFAULT_PASSWORD] = 'password'
</pre>
<p>Now you can run any of the following commands on a remote subversion repository.</p>
<h3>SVN Info</h3>
<pre class="brush: ruby; title: ; notranslate">
repos_uri = 'http://svn.website.com/project/trunk'
revision = 50
begin
  ctx.info(repos_uri, revision) do |path, info|
    puts(&quot;Url: #{info.url}&quot;)
    puts(&quot;Last changed rev: #{info.last_changed_rev}&quot;)
    puts(&quot;Last changed author: #{info.last_changed_author}&quot;)
    puts(&quot;Last changed date: #{info.last_changed_date}&quot;)
    puts(&quot;Kind: #{info.kind}&quot;)
  end
rescue Svn::Error =&gt; e
  # catch a generic svn error
  raise &quot;Failed to retrieve SVN info at revision &quot; + revision.to_s
end
</pre>
<h3>SVN Checkout</h3>
<pre class="brush: ruby; title: ; notranslate">
repos_uri = 'http://svn.website.com/project/trunk'
output_dir '/home/billy/project_name'
revision = 50
begin
  ctx.checkout(repos_uri, output_dir, revision.to_i, nil)
rescue Svn::Error::CLIENT_UNRELATED_RESOURCES =&gt; e # revision doesn't exist
  raise &quot;No such revision &quot; + revision.to_s + &quot; at &quot; + repos_uri
end
</pre>
<h3>SVN Log</h3>
<pre class="brush: ruby; title: ; notranslate">
repos_uri = 'http://svn.website.com/project/trunk'
ctx.log(repos_uri, 0, 'HEAD', 0, true, nil) do |changed_paths, rev, author, date, message|
  puts(&quot;Revision: #{rev}&quot;)
  puts(&quot;Author: #{author}&quot;)
  puts(&quot;Date: #{date}&quot;)
  puts(&quot;Message: #{message}&quot;)
  puts(&quot;---------------------------&quot;)
end
</pre>
<h3>SVN List</h3>
<pre class="brush: ruby; title: ; notranslate">
repos_uri = 'http://svn.website.com/project/trunk'
ctx.list(repos_uri, &quot;HEAD&quot;) do |path, dirent, lock, abs_path|
  if !path.blank?
    puts(&quot;Path: #{path}&quot;)
  end
end
</pre>
<p>That should get you started with the ruby bindings. If you want to know how to do anything else let me know in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.markdeepwell.com/2010/06/ruby-subversion-bindings/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

