<?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>Look alive. Here comes a buzzard. &#187; Ruby</title>
	<atom:link href="http://blog.glenc.net/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.glenc.net</link>
	<description>Treading water in a sea of man-made confusion.</description>
	<lastBuildDate>Fri, 10 Jun 2011 05:10:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Nu &#8211; Package Management for .NET Open Source</title>
		<link>http://blog.glenc.net/2010/08/31/nu-package-management-for-net-open-source/</link>
		<comments>http://blog.glenc.net/2010/08/31/nu-package-management-for-net-open-source/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 02:34:54 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=135</guid>
		<description><![CDATA[I heard about Nu on the Herding Code podcast and was immediately interested.  Ruby Gems is a great way to distribute open source libraries and manage dependencies.  The .NET scene has been struggling with this issue for quite a while so it&#8217;s great to see somebody take on this issue. Not only does Nu make [...]]]></description>
			<content:encoded><![CDATA[<p>I heard about <a href="http://groups.google.com/group/nu-net" target="_blank">Nu</a> on the <a href="http://herdingcode.com/?p=272" target="_blank">Herding Code</a> podcast and was immediately interested.  Ruby Gems is a great way to distribute open source libraries and manage dependencies.  The .NET scene has been struggling with this issue for quite a while so it&#8217;s great to see somebody take on this issue.</p>
<p>Not only does Nu make it super simple to add existing libraries to your project, but it&#8217;s also a great resource for finding <a href="http://nu.wikispot.org/Current_Packages" target="_blank">existing open source projects</a> out there.</p>
<p>I just happened to be building a brand new system so I&#8217;ll go through the steps I took to get Nu up and running.</p>
<ol>
<li>Installed Ruby for Windows using the latest <a href="http://rubyinstaller.org/" target="_blank">Ruby Installer</a></li>
<li>Opened a command prompt and ran the following commands:<br />
<code><br />
c:\gem update --system<br />
c:\gem update<br />
c:\gem install activesupport<br />
c:\gem install nu</p>
<p></code></li>
<li>Next I navigated to a new project folder and typed the following commands to add NHibernate and FluentNHibernate:<br />
<code><br />
nu install nhibernate<br />
nu install fluentnhibernate<br />
</code></li>
</ol>
<p>That&#8217;s it &#8211; super simple!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2010/08/31/nu-package-management-for-net-open-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RPoint &#8211; Why Ruby?  What about XML?</title>
		<link>http://blog.glenc.net/2008/08/11/rpoint-why-ruby-what-about-xml/</link>
		<comments>http://blog.glenc.net/2008/08/11/rpoint-why-ruby-what-about-xml/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 04:49:54 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[RPoint]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=94</guid>
		<description><![CDATA[I wanted to do a quick post on why I chose Ruby for RPoint. I talked about this a little in the first post but just looking at the examples I&#8217;ve given so far, one could make the argument that rather than creating these scripts in ruby, you could just create a simple XML document [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted to do a quick post on why I chose Ruby for RPoint.  I talked about this a little in the first post but just looking at the examples I&#8217;ve given so far, one could make the argument that rather than creating these scripts in ruby, you could just create a simple XML document that defines your structure, templates, etc.</p>
<p>This is very true &#8211; and in fact I have written tools like this in the past.  But here&#8217;s the problem I&#8217;ve encountered with XML.  You end up trying to build a programming language out of XML.  That&#8217;s basically where CAML has ended up.  And I don&#8217;t know a single person who actually <em>enjoys</em> looking at, much less creating, CAML.</p>
<p>Here&#8217;s what I like about the ruby approach.  It let&#8217;s you write something like this:</p>
<pre name="code" class="ruby">site_names = ["Site One", "Site Two", "Site Three"]
at "http://localhost" do
  site_names.each do |name|
    create_web name, TeamSite
  end
end
</pre>
<p>Just the simple addition of an array of site names is something that would be hard to do in XML.  What if you wanted to pull your information from a database?  Or a file system?  Or an Excel spreadsheet?  For any of those you would have to write more logic into your XML mini-language &#8211; constructs like looping, conditionals, some mechanism to handle plug-ins for additional logic, etc.  By leveraging an actual programming language, we get all of that for free.</p>
<p>Want to create 50 test sites?  Here you go.</p>
<pre name="code" class="ruby">at "http://localhost" do
  50.times do |i|
    create_web "Site #{i}", BlankSite
  end
end
</pre>
<p>&#8217;nuff said.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/08/11/rpoint-why-ruby-what-about-xml/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>RPoint &#8211; Hopes and Dreams</title>
		<link>http://blog.glenc.net/2008/08/11/rpoint-vision/</link>
		<comments>http://blog.glenc.net/2008/08/11/rpoint-vision/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 02:47:56 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[RPoint]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=87</guid>
		<description><![CDATA[Yesterday I posted about RPoint for the first time and I showed you a simple script to create a site structure. All of that code is working today. I wanted to keep the example simple and show you something that was actually functional. Today I want to dream a little. Here are a few scripts [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I posted about RPoint for the first time and I showed you a simple script to create a site structure.  All of that code is working today.  I wanted to keep the example simple and show you something that was actually functional.</p>
<p>Today I want to dream a little.  Here are a few scripts I want RPoint to be able to support.</p>
<h2>Creating a List Template</h2>
<p>This script would create a list template.</p>
<pre name="code" class="ruby">class Milestones
  include ListTemplateMixin

  name "Milestones"
  description "A Simple Milestone List"

  column "Milestone", Text, :is_title => true, :required => true
  column "Description", RichText
  column "Date", Date, :required => true, :default => :today

  view "All Milestones" do
    show_columns "Milestone", "Date"
  end

  view "Overdue Milestones" do
    show_columns "Milestone", "Date"
    where :date => less_than(:today)
    order_by :date => :descending
  end
end
</pre>
<p>Once you had defined your template, you could use it in a few different ways.  First, you could use it in a site creation script:</p>
<pre name="code" class="ruby">at "http://localhost" do
  create_list "My Milestones", Milestones
end
</pre>
<p>Second, and possibly cooler, you could generate a list definition:</p>
<pre name="code" class="bash">>ir generate.rb list_definition --source MilestoneTemplate.rb</pre>
<h2>Migrations</h2>
<p>Migrations in Rails is a great pre-defined structure for handling your database schema and changes to it over time.  It may not be anything too ground-breaking on its own, but it enforces a discipline when it comes to managing your database.  You are encouraged to think about situations where you want to change your database but data already exists.  You can write scripts to migrate existing data to your new structure and it&#8217;s all managed within source control as an ordered list of steps to execute.</p>
<p>I want to be able to do something similar with RPoint.</p>
<pre name="code" class="ruby"># first migration - create my site collection
class CreateSiteMigration
  at :webapp => "http://localhost" do
    create_site "My Site", TeamSite
  end
end

# second migration - add a list and add a lookup to that list on an existing list
class AddIssuesMigration
  at "http://localhost/sites/mysite" do
    create_list "Issues", Issues
    update_list "Tasks" do
      add_column "Related Issue", Lookup("Issues", :field => :title)
    end
  end
end
</pre>
<p>Okay &#8211; that&#8217;s enough dreaming for now.  Just incase anyone missed the intro THIS CODE DOES NOT WORK.  It is completely imaginary.  I am <em>hoping</em> that something along these lines will become reality.  And I hope that you will agree that this would be a much nicer way to create SharePoint solutions than slogging through hundreds of lines of XML.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/08/11/rpoint-vision/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RPoint &#8211; a DSL for SharePoint</title>
		<link>http://blog.glenc.net/2008/08/10/rpoint-a-dsl-for-sharepoint/</link>
		<comments>http://blog.glenc.net/2008/08/10/rpoint-a-dsl-for-sharepoint/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 19:14:01 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[RPoint]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=72</guid>
		<description><![CDATA[A few days back I talked about how the release of IronRuby would be great for SharePoint scripting. In my opinion, what makes Ruby such a powerful language is that it is great for creating domain specific languages (DSLs). I&#8217;m going to keep this post short so I won&#8217;t go into what DSLs are or [...]]]></description>
			<content:encoded><![CDATA[<p>A few days back I <a href="http://blog.glenc.net/2008/07/25/ironruby-a-sharepoint-developers-best-friend/">talked about</a> how the release of <a href="http://rubyforge.org/projects/ironruby">IronRuby</a> would be great for SharePoint scripting.  In my opinion, what makes Ruby such a powerful language is that it is great for creating domain specific languages (DSLs).  I&#8217;m going to keep this post short so I won&#8217;t go into what DSLs are or examples of them.  If you want to find out more info, look at some other ruby libraries such as <a href="http://rspec.info">rspec</a>, <a href="http://rake.rubyforge.org/">rake</a>, and <a href="http://datamapper.org/">datamapper</a>.</p>
<p>I think that SharePoint is in dire need of better tools to facilitate solution development, deployment, and maintenance.  It is simply too difficult to build a site in one environment and then deploy it in production.  Sure you can do backup and restore, but what about when you want to make some upgrades?</p>
<p>Anyway, this weekend I started working on an IronRuby-based DSL for SharePoint scripting.  I&#8217;m calling it RPoint for now (until I think of something sexier!).  Now, this is very very very early in development and I am sure things aren&#8217;t set up today as nicely as they should be long term, but I&#8217;ve been really excited by the progress and the possibilities.</p>
<p>RPoint will allow you to write code like this to create SharePoint sites:</p>
<pre name="code" class="ruby"># create a new subweb beneath an existing site
at "http://localhost" do
  create_web "New Web", TeamSite
end

# create a new site collection and website structure
at :webapp =&gt; "http://localhost" do
  create_site "New Site Collection", BlankSite, "domain\\user" do
    inside root_web do

      # create our site structure
      create_web "Child Web", TeamSite
      create_web "Another Child", BlankSite do
        create_web "Private Site", TeamSite, :inherit_permissions => false
      end

      # create a few lists
      create_list "Documents", DocumentLibrary
      create_list "Announcements", Announcements

    end
  end
end</pre>
<p>I think that&#8217;s pretty cool.  Beyond simply creating sites, RPoint will allow you to create lists, views and probably upload resources like images and documents.</p>
<p>My goals for RPoint are to be able to do the following:</p>
<ul>
<li>Easily write scripts to create site structures and lists</li>
<li>Rails-like &#8220;Migrations&#8221; for applying changes to existing sites</li>
<li>Custom site template and list definitions in ruby as opposed to XML</li>
<li>Ability to run template/list definitions against a live site or generate schema.xml/onet.xml files for production deployment</li>
<li>Support web-services automation as well as object model automation (this will be tough)
</ul>
<p>SharePoint is a huge product.  The code-base is enormous and the aspirations for RPoint are lofty.  I would greatly appreciate any assistance.  The more hands there are to help, the sooner we will have a tool to make SharePoint development a little easier.</p>
<p>To get RPoint in its current form, you can <a href="http://github.com/glenc/rpoint/tree/master">download it from GitHub</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/08/10/rpoint-a-dsl-for-sharepoint/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IronRuby &#8211; a SharePoint Developer&#8217;s Best Friend</title>
		<link>http://blog.glenc.net/2008/07/25/ironruby-a-sharepoint-developers-best-friend/</link>
		<comments>http://blog.glenc.net/2008/07/25/ironruby-a-sharepoint-developers-best-friend/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 18:33:37 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[SharePoint]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/?p=71</guid>
		<description><![CDATA[I wrote a while back about SharePoint scripting with IronPython. Well today&#8217;s announcement of the first binary release of IronRuby got me pretty darn excited. I really like Python, but I LOVE Ruby. I&#8217;ve been waiting for IronRuby to catch up to IronPython for quite a while and it looks like they&#8217;re getting close. Here&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote a while back about SharePoint scripting with IronPython.  Well <a href="http://www.iunknown.com/2008/07/ironruby-at-oscon.html" target="_blank">today&#8217;s announcement</a> of the first binary release of IronRuby got me pretty darn excited.  I really like Python, but I <em>LOVE</em> Ruby.  I&#8217;ve been waiting for IronRuby to catch up to IronPython for quite a while and it looks like they&#8217;re getting close.</p>
<p>Here&#8217;s a quick guide to getting up and running with IronRuby and SharePoint.</p>
<p><strong>Installation:</strong></p>
<ol>
<li>First, <a href="http://rubyforge.org/projects/ironruby" target="_blank">download the IronRuby release from Rubyforge</a>.</li>
<li>Next, copy the ironruby folder you extract to your Program Files (put it wherever you like &#8211; that&#8217;s where I put mine).</li>
<li>Update your system&#8217;s PATH environment variable to contain the path to the ironruby\bin folder.  So if you placed it in your Program Files, you would add this to your PATH: c:\program files\ironruby\bin</li>
</ol>
<p><strong>Creating a Script:</strong></p>
<p>Next you&#8217;ll want to create a new text file called print_sites.rb.  I recommend the <a href="http://e-texteditor.com/" target="_blank">e text editor</a> by the way &#8211; great tool.  Add the following lines to your file:</p>
<pre name="code" class="ruby">require 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL'
require 'Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL'

Uri = System::Uri
SPSite = Microsoft::SharePoint::SPSite
SPWebApplication = Microsoft::SharePoint::Administration::SPWebApplication
</pre>
<p>Okay &#8211; what does that do?  Well the first two lines are like adding a reference to a standard Visual Studio project.  They tell IronRuby that we need to reference (require) the System and Microsoft.SharePoint assemblies.  The next three lines are for convenience.  They set up aliases to the System.Uri class and two SharePoint classes.  In our ruby code, now we can just use Uri, SPSite, etc instead of having to type out the fully qualified path.</p>
<p>Next, let&#8217;s add some ruby code to enumerate all sites in a web application.</p>
<pre name="code" class="ruby">
webapp = SPWebApplication.Lookup(Uri.new("http://localhost"))
webapp.Sites.each do |site|
  puts site.Url
end
</pre>
<p><em>(hmm, looks like I don&#8217;t actually need the SPSite alias after all)</em></p>
<p>Now, save your file.  You can execute it like this:</p>
<pre name="code" class="bash">> ir print_sites.rb
</pre>
<p>If everything is set up right, you should see the URL for each site collection be printed to the screen.</p>
<p>There you go.  Have fun.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/07/25/ironruby-a-sharepoint-developers-best-friend/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Region Folding in Textmate</title>
		<link>http://blog.glenc.net/2008/04/20/region-folding-in-textmate/</link>
		<comments>http://blog.glenc.net/2008/04/20/region-folding-in-textmate/#comments</comments>
		<pubDate>Sun, 20 Apr 2008 15:27:36 +0000</pubDate>
		<dc:creator>glenc</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Software Development]]></category>

		<guid isPermaLink="false">http://blog.glenc.net/2008/04/20/region-folding-in-textmate/</guid>
		<description><![CDATA[As a long time Microsoft developer who is in the progress of branching out and learning new things, I sometimes find it hard to give up certain features I&#8217;ve grown accustom to.  When it comes to writing code, one feature of Visual Studio I have learned to rely on is folding sections of code using [...]]]></description>
			<content:encoded><![CDATA[<p>As a long time Microsoft developer who is in the progress of branching out and learning new things, I sometimes find it hard to give up certain features I&#8217;ve grown accustom to.  When it comes to writing code, one feature of Visual Studio I have learned to rely on is folding sections of code using #region and #endregion.  I find regions to be a great way to organize code around different subjects, activities, etc.  For me it&#8217;s a way to reduce the visual clutter and immediately jump to the section of code I need to work on.</p>
<p>On the Mac, TextMate does a great job of code folding based on syntax.  I&#8217;m doing a fair amount of work with Ruby these days and TextMate is an excellent tool.  Unfortunately for me however all folding is based on the syntax of the code, and not extra non-code markers like #region.  Luckily TextMate&#8217;s bundle system is completely extensible and customizable.  Folding is based on regular expressions so with a fairly simple change I was able to get #region folding in TextMate.</p>
<p>The first step is to figure out the regular expression.  The core regex for #region folding would be this:</p>
<p><code>^\s*\#region<br />
^\s*\#endregion</code></p>
<p>Next open up TextMate&#8217;s Bundle editor, open the Ruby language, and locate  the foldingStartMarker and foldingStopMarker sections.  Below is the entire contents of my foldingStartMarker and foldingStopMarker sections.</p>
<p><code>foldingStartMarker = '(?x)^<br />
(\s*+<br />
(module|class|def<br />
|unless|if<br />
|case<br />
|begin<br />
|for|while|until<br />
|(  "(\\.|[^"])*+"          # eat a double quoted string<br />
| ''(\\.|[^''])*+''        # eat a single quoted string<br />
|   [^#"'']                # eat all but comments and strings<br />
)*<br />
(                 \s   (do|begin|case)<br />
| [-+=&amp;|*/~%^&lt;&gt;~] \s*+ (if|unless)<br />
)<br />
)\b<br />
(?! [^;]*+ ; .*? \bend\b )<br />
|(  "(\\.|[^"])*+"              # eat a double quoted string<br />
| ''(\\.|[^''])*+''            # eat a single quoted string<br />
|   [^#"'']                    # eat all but comments and strings<br />
)*<br />
( \{ (?!  [^}]*+ \} )<br />
| \[ (?! [^\]]*+ \] )<br />
)<br />
).*$<br />
|   [#] .*? \(fold\) \s*+ $         # Sune’s special marker<br />
|    ^\s*\#region<br />
';<br />
foldingStopMarker = '(?x)<br />
(   (^|;) \s*+ end   \s*+ ([#].*)? $<br />
|   ^     \s*+ [}\]] \s*+ ([#].*)? $<br />
|   [#] .*? \(end\) \s*+ $    # Sune’s special marker<br />
|   ^\s*\#endregion<br />
)';</code></p>
<p>You can see where my two regular expressions were added near the end of each section.</p>
<p>Once you do that, close the editor, reload your bundles, and you&#8217;re good to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.glenc.net/2008/04/20/region-folding-in-textmate/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

