<?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>Visoft, Inc. Blogs &#187; ruby_odata</title>
	<atom:link href="http://blogs.visoftinc.com/category/ruby-odata/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.visoftinc.com</link>
	<description>.NET, ASP.NET, AJAX, Ruby and more</description>
	<lastBuildDate>Mon, 12 Mar 2012 18:05:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>Major Ruby OData Update v0.1.0</title>
		<link>http://blogs.visoftinc.com/2011/12/07/major-ruby-odata-update-v0-1-0/</link>
		<comments>http://blogs.visoftinc.com/2011/12/07/major-ruby-odata-update-v0-1-0/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 04:40:41 +0000</pubDate>
		<dc:creator>Damien White</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_odata]]></category>
		<category><![CDATA[WCF Data Services]]></category>
		<category><![CDATA[WCF]]></category>
		<guid isPermaLink="false">http://blogs.visoftinc.com/?p=263</guid>
		<description><![CDATA[It’s here! I’m happy to announce a major release of ruby_odata, v0.1.0. There are many enhancements found in this release so let’s dig in and see what’s new. There is one thing that we need to get out of the way first, a breaking change. In v0.0.10 and below, queries and some instances of calls [...]]]></description>
			<content:encoded><![CDATA[<p><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 10px 15px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="OData_logo_MS_small_thumb7" border="0" alt="OData_logo_MS_small_thumb7" align="right" src="http://blogs.visoftinc.com/wp-content/uploads/2011/12/OData_logo_MS_small_thumb7.png" width="300" height="37" />It’s here! I’m happy to announce a major release of <a href="https://github.com/visoft/ruby_odata/" target="_blank">ruby_odata</a>, v0.1.0. There are many enhancements found in this release so let’s dig in and see what’s new.</p>
<p>There is one thing that we need to get out of the way first, a <strong>breaking change</strong>. In v0.0.10 and below, queries and some instances of calls to <code>save_changes</code> would return a single entity if there was only one returned. This was confusing and could lead to errors. As a consumer of the gem, you wouldn’t know if a call to the Service’s <code>execute</code> method was a single object or an enumerable. Instead of you having to guess, those calls now return enumerables all the time. This applies to calls to <code>execute</code> and <code>save_change</code> additions. Updates, deletes, and <code>add_link</code> calls (we’ll get to those in a minute), as well as batch saves all return Booleans, but single <code>save_change</code> add calls will return an enumerable because those results are parsed similar to <code>execute</code> calls.</p>
<p>Now that that’s out of the way, let’s look at the new features.</p>
<p><span id="more-263"></span><br />
<h2>The Features</h2>
<h3>Partial Results</h3>
<p>The first change is thanks to <a href="https://github.com/arienmalec" target="_blank">arienmalec</a>. OData allows services to do server-side paging in Atom by defining a next link. The default behavior is to repeatedly consume partial feeds until the result set is complete, for example:</p>
<pre class="brush: ruby;">svc.Partials
results = svc.execute # =&gt; retrieves all results in the Partials collection</pre>
<p>If desired (e.g., because the result set is too large to fit in memory), explicit traversal of partial results can be requested via options:</p>
<pre class="brush: ruby;">svc = OData::Service.new &quot;http://example.com/Example.svc&quot;, { :eager_partial =&gt; false }
svc.Partials
results = svc.execute # =&gt; retrieves the first set of results returned by the server
if svc.partial? # =&gt; true if the last result set was a partial result set (i.e., had a next link)
  results.concat svc.next # =&gt; retrieves the next set of results
end
while svc.partial? # =&gt; to retrieve all partial result sets
  results.concat svc.next
end</pre>
<h3>Single Layer Inheritance</h3>
<p>This feature was long overdue! Back in July 2010, <a href="http://odetocode.com/Blogs/scott/articles/about-scott-allen.aspx" target="_blank">Scott Allen</a> wrote <a href="http://odetocode.com/Blogs/scott/archive/2010/07/11/odata-and-ruby.aspx" target="_blank">a post about ruby_odata</a> where he mentioned a change to the Service class that would parse models with single layer inheritance. His code has finally been integrated into ruby_odata. Note, that the addition currently only support single layer inheritance, but that should handle most of the cases you will encounter.</p>
<h3>Querying Links</h3>
<p>There are times when you don’t necessarily want to bring down full navigation property entities. In these cases the OData protocol has support for <a href="http://www.odata.org/developers/protocols/uri-conventions#AddressingLinksBetweenEntries" target="_blank">Addressing Links Between Entities</a>. To support this, there is a new method that can be tacked on to a single entity query (e.g. finding an entity by id) called <code>links</code> where you pass the name of the navigation property of the links that you want to retrieve. For example:</p>
<pre class="brush: ruby;">svc.Categories(1).links(&quot;Products&quot;)
product_links = svc.execute # =&gt; returns URIs for the products</pre>
<h3>Add Link</h3>
<p>There are times when you need to <a href="http://www.odata.org/developers/protocols/operations#CreatingLinksbetweenEntries" target="_blank">create a linkage between a parent and a child</a>, and you don’t want be required to perform an add or update. You can now simply call the <code>add_link</code> method on the <code>OData::Service</code> with the parent object, the name of the navigation property, and the child object. Finally, call <code>save_changes</code>. For example:</p>
<pre class="brush: ruby;">svc.add_link(&lt;Parent&gt;, &lt;Navigation Property Name&gt;, &lt;Child&gt;)
svc.save_changes</pre>
<h3>Lazy Loading</h3>
<p>In previous versions of ruby_odata, if you wanted to perform lazy loading of navigation properties you would need to do it manually, which was extremely ugly. I’m happy to say that there is now a way to perform lazy loading in a graceful way. All you need to do is to call the <code>load_property</code> method on the <code>OData::Service</code> with the entity to fill and the name of the navigation property. For example:</p>
<pre class="brush: ruby;"># Without expanding the query
svc.Products(1)
prod1 = svc.execute.first
# Use load_property for lazy loading
svc.load_property(prod1, &quot;Category&quot;)</pre>
<h3>Reflection / Introspection</h3>
<p>Paul Gallagher (<a href="https://github.com/tardate" target="_blank">tardate</a>) had a <a href="https://github.com/visoft/ruby_odata/issues/11" target="_blank">great suggestion</a>: Why should you have to look at the EDMX metadata file directly when ruby_odata parses all that data? You can now use the <code>OData::Service</code> to access a list of the <code>collections</code> that the service exposes. There is also a <code>classes</code> method, which gives you a list of the classes generated by the OData::Service. A <code>function_imports</code> method, which will list function imports exposed by the service (we’ll get to those in a minute). On a class, you can call the class method, <code>properties</code>, which as you guessed will give you information about each property. Each of these methods return hashes where the keys are the name, and the values are hashes of the metadata for the member that you are introspecting.</p>
<h3>Function Imports</h3>
<p>Quite a while ago, I received an message from a user via this blog asking about the ability to call custom service methods. Within a WCF Data Service, you can expose your own custom methods, which get translated into the <a href="http://www.odata.org/media/6652/[mc-csdl][1].htm#_Toc246717555" target="_blank">EDMX as FunctionImports</a>. These aren’t to be confused with Entity Framework’s <code>FunctionImports</code>. These will be parsed and dynamically added as methods to the <code>OData::Service</code>. When you call one of the methods, they will return a result without you needing to make a call to <code>execute</code> or <code>save_changes</code>. There are different result types. You may get back a true if the <code>FunctionImport</code> doesn’t return any content (for example, a delete). You may get back a single entity, or a collection of entities. Finally, you may get back a single primitive value (e.g. Integer, String, etc), or a collection of primitive values. You can use the <code>function_imports</code> method on the Service to determine the type that will be returned.</p>
<h3>Namespaces</h3>
<p>In the same message as the request for the custom service methods (ok, it was actually a reply), the user mentioned that he received type conflicts with the generated classes if one by the same name already existed. If this is a problem for you, you now have the ability to tell the <code>OData::Service</code> to generate the models in a specific namespace. There is a new option that can be passed in to the constructor’s option hash, <code>:namespace</code>. If you use this option, there shouldn’t be any collisions. You can pass a namespace in either Ruby (with double colons, e.g. <code>RubyOData::Rocks</code>) or .NET style (with periods, e.g. <code>RubyOData.Rocks</code>) if there is more than one part to the namespace that you want to use. If you don’t provide a namespace, then ruby_odata will generate the classes without any namespace just as it has before.</p>
<h3>The Beginnings of Something Cool?</h3>
<p>As developers, the majority of the time we either retrieve collections or a single entity, usually by an ID. I didn’t really like the current steps to retrieve a single entity by ID:</p>
<pre class="brush: ruby;">svc.Categories(1)
category = svc.execute.first</pre>
<p>Sort of ugly, right? So inspired by Ruby on Rails, I added a class method for each created class so that you could just do this:</p>
<pre class="brush: ruby;">category = Category.first(1)</pre>
<p>Great, right? It’s a little nicer, but sadly it’s a one trick pony right now. There’s no filtering, eager loading, etc. My idea was to hopefully expand on the concept like Rails and ActiveRecord, but for now it’s just an easier, cleaner way to get an entity.</p>
<h2>Testing</h2>
<p>In addition to the new features, I’ve been busy working on the testing suite. </p>
<h3>No More Hardcoded URIs</h3>
<p>Having to rely on Windows for testing has made me stick to Windows and e-TextEditor for ruby_odata development. The key word there is actually testing. All that Windows is required for is hosting the WCF Data Service for the Cucumber integration tests, but Cucumber is just one part of it, RSpec is the other. It’s no denying that Ruby on Windows is slower than its *nix counterparts (not to knock the RubyInstaller.com team, if it wasn’t for them, Ruby on Windows would be non-existent). Where you really see a slowdown is when you are doing TDD/BDD testing. You need tests to run fast, and if you ran the command <code>time rake spec</code>, my Windows box is more than 4 times slower than my old MacBook (note, not a Pro), which has similar hardware. Now, multiply that by every spec I write and I want to throw my machine out a window. So, in an effort to migrate development, the URLs and ports required for the sample WCF service are now dynamic. Take a look at features/support/constants.rb for more information. Thanks to Sean Carpenter (<a href="https://github.com/scarpenter" target="_blank">scarpenter</a>) for his fork where he changed the static values in that file to be optionally set by environment variables.</p>
<h3>Hello New Technology</h3>
<p>I decided to change up the technologies used within the test service. First, no more SQL Express, hello SQL Compact 4. Why the change? SQL Compact 4 is simply DLL deployed, you don’t need to install anything, cool. Also, since SQL Compact 4 databases are file based, instead of having to truncate to clean the database for testing, the file could just be blown away and rebuilt easily.</p>
<p>So, a new database, how about a new ORM? Entity Framework 4.1, also known as “<a href="http://www.hanselman.com/blog/SimpleCodeFirstWithEntityFramework4MagicUnicornFeatureCTP4.aspx" target="_blank">magic unicorn edition</a>” is now being used. EF 4.1 “Code First” as it is called, is just awesome. Ditching <a href="http://msdn.microsoft.com/en-us/library/cc982042.aspx" target="_blank">Entity Framework’s EDMX</a> for pure code, now that is right up my alley.</p>
<p>Finally, since I switch to EF 4.1, the current released version of WCF Data Services, well, didn’t work right. You know what did? The <a href="http://blogs.msdn.com/b/astoriateam/archive/2011/10/13/announcing-wcf-data-services-oct-2011-ctp-for-net-4-and-silverlight-4.aspx" target="_blank">WCF Data Services October 2011 CTP</a>, w00t.</p>
<p>Everything you need should be in the new test project (now called RubyODataService, changed from SampleService, though that’s still in the test URLs) thanks to NuGet and my copying of the WCF DS CTP DLLs to the packages directory since there wasn’t a NuGet package for it). </p>
<h3>Pickle</h3>
<p>I love the <a href="https://github.com/ianwhite/pickle" target="_blank">pickle</a> gem. Aside from being authored by <a href="https://github.com/ianwhite" target="_blank">a guy with my last name</a> (no relation), pickle makes Cucumber features so much nicer to read. Throughout development of ruby_odata, I’ve written my own step definitions to do things, essentially cloning what pickle does out-of-the-box, e.g. creating models, asserting against models, etc. I had toyed with getting pickle to work around June of last year, but was having issues. As time passed and experience grew, I finally got it all working. I used it in a few places in new tests, but I hope to do a complete overhaul. My pickle adapter also needs a bit of work since I didn’t put it through all of its paces, and some things need to be added to ruby_odata before it will function as expected. All in all though, it is great to finally have pickle working.</p>
<h2>Conclusion</h2>
<p>I hope that you find the new version of ruby_odata to be useful. In the next version, I hope to further enhance the gem with more of the <a href="http://www.odata.org/developers/protocols/operations" target="_blank">different operations that OData can perform</a>. I’m sure I’ll perform some more housekeeping in the test suite removing my ugly Cucumber steps for nice, clean Pickle steps.</p>
<p>What would you like to see in the new version? Add your suggestions to the <a href="https://github.com/visoft/ruby_odata/issues" target="_blank">issues section on GitHub</a>. I’d also like to know what you think of the API as it stands right now. I’ve essentially been following the OData Silverlight client API syntax (e.g. AddTo&lt;Collection Name&gt; methods, add_link, etc). With the addition of the <code>:first</code> class method, it got me thinking of a bit of a different approach. Not necessarily giving up one for the other, but I think another more Ruby-esq style could co-exist. Anyway, that’s all for now, go forth and do cool things with <a href="https://rubygems.org/gems/ruby_odata" target="_blank">ruby_odata</a>. I’d love to know how you are using the gem. I was excited to find out that ruby_odata was being utilized by the <a href="http://rgovdata.com/" target="_blank">rgovdatablog</a> gem.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.visoftinc.com/2011/12/07/major-ruby-odata-update-v0-1-0/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Ruby OData Update v0.0.10</title>
		<link>http://blogs.visoftinc.com/2011/09/26/ruby-odata-update-v0-0-10/</link>
		<comments>http://blogs.visoftinc.com/2011/09/26/ruby-odata-update-v0-0-10/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 03:55:18 +0000</pubDate>
		<dc:creator>Damien White</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_odata]]></category>
		<category><![CDATA[WCF Data Services]]></category>
		<category><![CDATA[WCF]]></category>
		<guid isPermaLink="false">http://blogs.visoftinc.com/2011/09/26/ruby-odata-update-v0-0-10/</guid>
		<description><![CDATA[I’m happy to announce that today, ruby_odata has continued to move forward by adding additional features and fixing bugs. I skipped an update for v0.0.9, so let’s revisit what was added/fixed back then. The major change was support for self-signed SSL certificates. That addition was courtesy of J.D Mullin. I’m sure you remember his contributions [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.visoftinc.com/wp-content/uploads/2011/09/OData_logo_MS_small.png"><img style="background-image: none; border-right-width: 0px; margin: 0px 0px 10px 12px; padding-left: 0px; padding-right: 0px; display: inline; float: right; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="OData_logo_MS_small" border="0" alt="OData_logo_MS_small" align="right" src="http://blogs.visoftinc.com/wp-content/uploads/2011/09/OData_logo_MS_small_thumb.png" width="300" height="37" /></a>I’m happy to announce that today, <a href="http://github.com/visoft/ruby_odata" target="_blank">ruby_odata</a> has continued to move forward by adding additional features and fixing bugs. </p>
<p>I skipped an update for v0.0.9, so let’s revisit what was added/fixed back then. The major change was support for self-signed SSL certificates. That addition was courtesy of <a href="http://jdmullin.blogspot.com/" target="_blank">J.D Mullin</a>. I’m sure you remember his contributions <a href="http://bit.ly/ruby_odata008" target="_blank">back in v0.0.8</a> when he added Basic HTTP Authentication. Aside from J.D.’s contributions, the library was refactored to only make one call to the service for building classes and collections. Finally, a few bug fixes wrapped up the release.</p>
<p>Now onto v0.0.10. A lot of changes were implemented in this release that ended up allowing for wider support for ruby_odata. Thanks to input from Michael Koegel (<a href="http://twitter.com/#!/konfusius" target="_blank">@konfusius</a>), Alvaro Tejada (<a href="http://twitter.com/#!/blag" target="_blank">@Blag</a>), Ingo Sauerzapf (<a href="http://twitter.com/#!/IngoS11" target="_blank">@IngoS11</a>), and Juergen Schmerder (<a href="http://twitter.com/#!/schmerdy" target="_blank">@schmerdy</a>) (I apologize if I missed anyone!), ruby_odata now supports (at least basic functionality) for <a href="http://help.sap.com/saphelp_gateway20/helpdata/en/2f/d48687c1e14e87915d41e595a4285d/content.htm" target="_blank">SAP NetWeaver GateWay</a>.</p>
<p>Another big change is the initial support for <a href="http://www.odata.org/developers/protocols/atom-format#CustomizingtheRepresentationofanEntry" target="_blank">feed customizations</a>. Properties may not be represented within the &lt;m:properties&gt; collection of an entity. Currently ruby_odata supports SyndicationTitle and SyndicationSummary, but adding the other syndication options should be easy to support. If you can supply me with the metadata and a copy of the output that includes the additional feed customizations, I will be happy to add them (or feel free to fork the project and add them yourself).</p>
<p>Here’s are the complete list of changes for v0.0.10:</p>
<ul>
<li><strong>New Features</strong>
<ul>
<li>Added the ability to pass additional parameters that are appended to the query string for requests </li>
<li>Added initial support for feed customizations (SyndicationTitle and SyndicationSummary) </li>
<li>Enhanced ruby_odata’s awareness of classes based on the metadata instead of relying on results that are returned </li>
</ul>
</li>
<li><strong>Bug Fixes</strong>
<ul>
<li>Fixed issues with nested collections (eager loading) </li>
<li>Handled ArgumentError on the Time.parse for older versions of Ruby; used DateTime.parse instead if Time.parse fails </li>
<li>Removed the camelize method call when building the root URL for collections (reported by mkoegel, issue #3 on github) </li>
<li>Handled building results (classes) where the category element is missing but there is a title element instead (reported by mkoegel, issue #3 on github in the comments) </li>
</ul>
</li>
<li><strong>Other</strong>
<ul>
<li>Change HTTP port to 8989 since 8888 conflicts with the Intel AppStore </li>
<li>Refactored service step for HTTP calls where the service address is defined within the step making it easier to make changes in the future</li>
</ul>
</li>
</ul>
<p>For the next release, I hope to continue to fix issues, <a href="http://odetocode.com/Blogs/scott/archive/2010/07/11/odata-and-ruby.aspx" target="_blank">finally add support for inheritance</a>, add the ability to call a custom WebGet methods added to the service, and hopefully namespacing of entities to limit collisions. Do you have other requests? Add them to the <a href="https://github.com/visoft/ruby_odata/issues" target="_blank">issues list</a> on <a href="http://github.com/" target="_blank">GitHub</a>. The previous Lighthouse site for issues has been closed in favor of using GitHub.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.visoftinc.com/2011/09/26/ruby-odata-update-v0-0-10/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby OData Update v0.0.8</title>
		<link>http://blogs.visoftinc.com/2011/03/14/ruby-odata-update-v008/</link>
		<comments>http://blogs.visoftinc.com/2011/03/14/ruby-odata-update-v008/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 14:57:26 +0000</pubDate>
		<dc:creator>Damien White</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_odata]]></category>
		<category><![CDATA[WCF Data Services]]></category>
		<category><![CDATA[OData]]></category>
		<category><![CDATA[WCF]]></category>
		<guid isPermaLink="false">http://blogs.visoftinc.com/?p=164</guid>
		<description><![CDATA[It has been WAY too long since an update of ruby_odata was released.  I’m happy to announce that version 0.0.8 was released today.  The biggest change, thanks to J.D. Mullin, is support for Basic HTTP Authentication.  It’s an awesome enhancement and very easy to use.  All you need to do is pass in the username [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.odata.org"><img style="margin: 10px 0px 10px 20px; display: inline; float: right;" title="OData_logo_MS_small" src="http://blogs.visoftinc.com/wp-content/uploads/2011/03/OData_logo_MS_small.png" alt="OData_logo_MS_small" width="300" height="37" align="right" /></a>It has been WAY too long since an update of <a href="http://github.com/visoft/ruby_odata" target="_blank">ruby_odata</a> was released.  I’m happy to announce that version 0.0.8 was released today.  The biggest change, thanks to <a href="http://jdmullin.blogspot.com/" target="_blank">J.D. Mullin</a>, is support for Basic HTTP Authentication.  It’s an awesome enhancement and very easy to use.  All you need to do is pass in the username and password as constructor arguments when instantiating a service like so:</p>
<pre class="brush: ruby;">require 'lib/ruby_odata'
svc = OData::Service.new "http://127.0.0.1:8888/SampleService/Entities.svc", { :username =&gt; "bob", :password=&gt; "12345" }</pre>
<p>In addition to the big change by <a href="http://twitter.com/#!/jdmullin" target="_blank">@jdmullin</a>, the following changes are apart of the new version:</p>
<ul>
<li>Support for <a href="http://www.odata.org/developers/protocols/atom-format#PrimitiveTypes" target="_blank">nullable primitive types</a> being returned from an <a href="http://www.odata.org/" target="_blank">OData</a> service.</li>
<li>A change in ActiveSupport 3.0.x broke additions in ruby_odata when you associate a previously saved entity.  This has been corrected, and ActiveSupport 2.3.x (tested 2.3.11) and 3.0.x (tested 3.0.5) are now supported. </li>
<li>Ruby 1.9.2 is now supported.</li>
</ul>
<p>Other “backend” type enhancements were added:</p>
<ul>
<li>Removed Jeweler for releasing gems</li>
<li>Moved to bundler</li>
<li>Updated README to reflect new changes</li>
<li>Updated DB management so that testers aren’t required to move files around</li>
<li>Fixed gemspec to list the development gems</li>
<li>Developers can just do a “bundle install” to get all the required gems</li>
</ul>
<p>One interesting thing that I found while testing is that Ruby 1.9.2 is much faster when running <a href="http://cukes.info" target="_blank">Cucumber</a> tests on Windows.  I was using Ruby 1.8.7-p330 vs 1.9.2-p180 on Windows (<a href="http://rubyinstaller.org/" target="_blank">RubyInstaller</a> rocks!).  Here’s a snapshot:</p>
<p><a href="http://blogs.visoftinc.com/wp-content/uploads/2011/03/CucumberRubyVersionComparison.png"><img style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="CucumberRubyVersionComparison" src="http://blogs.visoftinc.com/wp-content/uploads/2011/03/CucumberRubyVersionComparison_thumb.png" border="0" alt="CucumberRubyVersionComparison" width="524" height="204" /></a></p>
<p>Note there is a bit of a problem using Ruby 1.9.2 w/ Cucumber on Windows.  The problem is that when using bundler or “gem install,” the <a href="http://rubygems.org/gems/json" target="_blank">json gem</a> gets installed as the x86-mingw32 version.  Running cucumber on Windows with Ruby 1.9.2 (using the incorrectly compiled json gem) yields a msvcrt-ruby18.dll error.  The way I fixed the error was to install the <a href="https://github.com/oneclick/rubyinstaller/wiki/Development-Kit" target="_blank">RubyInstaller DevKit</a>, and then reinstall the gem “correctly” using:</p>
<pre class="brush: bash;">gem uninstall json
gem install json --platform=ruby -v 1.4.6</pre>
<p>What we are doing is uninstalling the incorrect copy of the json gem and then installing v1.4.6 of json using the &#8211;platform=ruby flag which will involve the DevKit to compile the gem for us.  Note that the json gem version required by <a href="http://rubygems.org/gems/cucumber" target="_blank">Cucumber 0.10.0</a> is ~&gt; 1.4.6, and there is a new version out, so the -v 1.4.6 forces the correct one.  Found the <a href="http://stackoverflow.com/questions/2167992/problem-with-ruby-on-rails-on-windowsmsvcrt-ruby18-dll-error-newbie-questions/4777585#4777585" target="_blank">solution on StackOverflow</a>,  but it seems that there should be a better way to solve this, perhaps with <a href="http://gembundler.com/man/bundle-config.1.html" target="_blank">bundle-config</a>?</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.visoftinc.com/2011/03/14/ruby-odata-update-v008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby OData Update v0.0.7</title>
		<link>http://blogs.visoftinc.com/2010/07/06/ruby-odata-update-v007/</link>
		<comments>http://blogs.visoftinc.com/2010/07/06/ruby-odata-update-v007/#comments</comments>
		<pubDate>Wed, 07 Jul 2010 00:48:49 +0000</pubDate>
		<dc:creator>Damien White</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_odata]]></category>
		<category><![CDATA[WCF]]></category>
		<guid isPermaLink="false">/archive/2010/07/06/ruby-odata-update-v007.aspx</guid>
		<description><![CDATA[I  just wanted to give an update on the ruby_odata progress.  If you don’t know about ruby_odata or want a refresher, I blogged about it a few weeks ago.  Anyway, I just released a new version of the gem, v0.0.7.  With this new version, you can now perform batch saves (multiple adds, deletes, and updates) [...]]]></description>
			<content:encoded><![CDATA[<p><img style="margin: 10px 0px 10px 10px; display: inline; border-width: 0px;" title="OData_logo_MS_small" src="http://blogs.visoftinc.com/wp-content/uploads/OData_logo_MS_small_1.png" border="0" alt="OData_logo_MS_small" width="300" height="36" align="right" /> I  just wanted to give an update on the <a href="http://github.com/visoft/ruby_odata" target="_blank">ruby_odata</a> progress.  If you don’t know about ruby_odata or want a refresher, <a href="http://blogs.visoftinc.com/archive/2010/06/12/Introducing-a-Ruby-OData-Client-Library.aspx">I blogged about it a few weeks ago</a>.  Anyway, I just released a new version of the gem, v0.0.7.  With this new version, you can now perform batch saves (multiple adds, deletes, and updates) and types are being supported.  The library is getting more mature with each revision.  Below is the state of the current gem:</p>
<ul>
<li>&lt;Collection&gt; dynamic methods are available after you instantiate the service.  You can chain query operations like <strong>order_by</strong>, <strong>filter</strong>, <strong>expand</strong>, etc. on to the dynamic methods.<br />
 </li>
<li>For querying, <a href="http://www.odata.org/developers/protocols/uri-conventions#OrderBySystemQueryOption" target="_blank">$orderby</a>, <a href="http://www.odata.org/developers/protocols/uri-conventions#TopSystemQueryOption" target="_blank">$top</a>, <a href="http://www.odata.org/developers/protocols/uri-conventions#SkipSystemQueryOption" target="_blank">$skip</a>, <a href="http://www.odata.org/developers/protocols/uri-conventions#FilterSystemQueryOption" target="_blank">$filter</a>, and <a href="http://www.odata.org/developers/protocols/uri-conventions#ExpandSystemQueryOption" target="_blank">$expand</a> are supported.  These are represented by the methods <strong>order_by</strong>, <strong>top</strong>, <strong>skip</strong>, <strong>filter</strong>, and <strong>expand </strong>(respectively) on the OData::QueryBuilder class (which is returned from the dynamic collection methods), for example: <span style="font-family: Courier New;">svc.Products.top(10)</span>.<br />
 </li>
<li>The ability to add entities.  <strong>AddTo&lt;Collection&gt;</strong> dynamic methods are available after you instantiate the service, allowing you to pass new entities to the methods.<br />
 </li>
<li>The ability to update entities though the <strong>update_object</strong> method on the OData::Service.<br />
 </li>
<li>The ability to delete entities though the <strong>delete_object</strong> method on the OData::Service.<br />
 </li>
<li>The ability to batch saves, which allows you to pass multiple objects to be added, updated, or deleted and have them persisted as a batch when you call the <strong>save_changes</strong> method on the OData::Service.  Note that with batch saves, the changes either complete or fail as a batch.<br />
 </li>
<li>Explicit data type support for the following: (Everything outside of this list currently is represented as a string.)
<ul>
<li>Edm.Int16</li>
<li>Edm.Int32</li>
<li>Edm.Int64</li>
<li>Edm.Decimal</li>
<li>Edm.DateTime – Note that DateTime is a bit odd.  There’s no time zone data passed from <a href="http://www.odata.org/" target="_blank">OData</a> services (at least not with <a href="http://msdn.microsoft.com/en-us/library/cc668792(VS.100).aspx" target="_blank">WCF Data Services</a>), so it is assumed that the time zone is UTC for all DateTime types.<br />
 </li>
</ul>
</li>
<li>Support for Complex Types – From OData.org: “<strong><strong>Complex</strong> <strong>Types</strong></strong> are structured <strong>types</strong> also consisting of a list of properties but with no key, and thus can only exist as a property of a containing entity or as a temporary value.”  You’ll typically see these to logically group properties together.  For example, with the Netflix service, they expose a BoxArt complex type on a Title.  The BoxArt type consists of 3 properties, SmallUrl, MediumUrl, LargeUrl.  This makes accessing these clearer and cleaner, for example <span style="font-family: Courier New;">movie.BoxArt.MediumUrl</span>.<br />
 </li>
<li>Works with Ruby 1.8.7 and Ruby 1.9.1.  It also works with ActiveSupport 3.0.0.beta4.  These were tested on Windows due to using WCF Data Services for the test suite, although, if something Ruby works in Windows there is a good chance everything should be fine on Mac or Linux as well.  I could always change the test URLs to point at a remote machine to do my testing on a Mac, but I wish there was an OData producer like WCF Data Services that would work with <a href="http://rails.rubyonrails.org/classes/ActiveRecord/Base.html" target="_blank">ActiveRecord</a> (or similar).</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blogs.visoftinc.com/2010/07/06/ruby-odata-update-v007/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing a Ruby OData Client Library</title>
		<link>http://blogs.visoftinc.com/2010/06/12/introducing-a-ruby-odata-client-library/</link>
		<comments>http://blogs.visoftinc.com/2010/06/12/introducing-a-ruby-odata-client-library/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 04:37:28 +0000</pubDate>
		<dc:creator>Damien White</dc:creator>
				<category><![CDATA[OData]]></category>
		<category><![CDATA[REST]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[ruby_odata]]></category>
		<category><![CDATA[WCF]]></category>
		<category><![CDATA[WCF Data Services]]></category>
		<category><![CDATA[Web Services]]></category>
		<guid isPermaLink="false">/archive/2010/06/12/Introducing-a-Ruby-OData-Client-Library.aspx</guid>
		<description><![CDATA[Ever since the ADO.NET team started development on Astoria (pre-release), I have loved the concept.&#160; Since its release (it was called ADO.NET Data Services and is now WCF Data Services), I’ve used it a ton (you may remember the example from this post).&#160; Back at MIX10, Microsoft announced a commitment to the Open Data Protocol [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.odata.org/"><img style="border-right-width: 0px; margin: 20px 10px 20px 20px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="OData_logo_MS_small" border="0" alt="OData_logo_MS_small" align="right" src="http://blogs.visoftinc.com/wp-content/uploads/OData_logo_MS_small.png" width="240" height="29" /></a> Ever since the ADO.NET team started development on Astoria (pre-release), I have loved the concept.&#160; Since its release (it was called ADO.NET Data Services and is now WCF Data Services), I’ve used it a ton (you may remember the example from <a href="http://blogs.visoftinc.com/archive/2009/05/27/ASP.NET-4.0-AJAX-Preview-4-Data-Binding.aspx">this post</a>).&#160; Back at MIX10, Microsoft announced a commitment to the <a href="http://www.odata.org/" target="_blank">Open Data Protocol</a> (<a href="http://www.odata.org/" target="_blank">OData</a>).&#160; <a href="http://msdn.microsoft.com/en-us/library/cc668792(VS.100).aspx" target="_blank">WCF Data Services</a> enables you to create services that use OData to expose and consume data, both with .NET 4 and .NET 3.5 SP1.&#160; OData services are very powerful and there are quite a few <a href="http://www.odata.org/producers" target="_blank">live producers</a> such as <a href="http://odata.netflix.com/Catalog/" target="_blank">Netflix</a> and <a href="http://www.nerddinner.com/Services/OData.svc/" target="_blank">Nerd Dinner</a>.</p>
<p>OData is so powerful because it’s REST based and you can access the services from just about everywhere, including just a simple URL.&#160; For example, using the Netflix OData service to access the best movie ever made by title: <a href="http://odata.netflix.com/Catalog/Titles?$filter=Name eq 'Office Space'">http://odata.netflix.com/Catalog/Titles?$filter=Name eq &#8216;Office Space&#8217;</a>.&#160; Pretty simple.&#160; Of course accessing things solely based on URLs in code isn’t the best, and hence the reason for my post.</p>
<h2>Client Libraries</h2>
<p>When using OData, it’s convenient to utilize an SDK to access the services.&#160; For example, in <a href="http://msdn.microsoft.com/en-us/library/cc838234(VS.96).aspx" target="_blank">Silverlight</a> you can access <a href="http://msdn.microsoft.com/en-us/library/ff650916(v=VS.96).aspx" target="_blank">OData services using LINQ</a>.&#160; There’s also a fantastic <a href="http://www.asp.net/ajaxLibrary/odata.ashx" target="_blank">AJAX Library</a> (which I used in a <a href="http://blogs.visoftinc.com/archive/2009/05/27/ASP.NET-4.0-AJAX-Preview-4-Data-Binding.aspx" target="_blank">previous post</a>).&#160; There are SDKs for <a href="http://odataphp.codeplex.com/" target="_blank">PHP</a>, <a href="http://odataobjc.codeplex.com/" target="_blank">Objective-C</a>, and many others, but there was one missing that I wanted to use… Ruby.&#160; I am assuming this comes as no surprise given my new found <a href="http://blogs.visoftinc.com/category/Ruby.aspx">love for Ruby</a>.</p>
<p><span id="more-71"></span><br />
<h2>Introducing ruby_odata</h2>
<p>I’ve been messing around with Ruby enough to start working on my first Ruby open-source project.&#160; It’s always good to contribute to the open-source community.&#160; While I’m not a seasoned Ruby developer, I figure this is a good project to start on.&#160; Now I can code stuff in Ruby and consume WCF services I have written in the past and will continue to write in the future (that is until there is “OData on <a href="http://rubyonrails.org/" target="_blank">Rails</a>,” perhaps an idea for a new project?).</p>
<p>The source code, like all good Ruby code, is <a href="http://github.com/visoft/ruby_odata" target="_blank">hosted on GitHub</a>.&#160; The <a href="http://github.com/visoft/ruby_odata/blob/master/README.rdoc" target="_blank">README</a> will give you a good idea of how to use the library.&#160; Currently (as of 06/12/2010) there are limitations, such as not being able to batch changes (like multiple Adds), but no worries, I’m working on adding them (actually, I cut three releases today, adding extra querying abilities).&#160; That said, it is functional enough to use for most operations right now.&#160; Once it’s been better tested in the real world and I’ve been able to incorporate most if not all of the OData functionality, I will be versioning more responsibly.&#160; Right now, because I’m adding functionality quickly and I want others to be able to use it, you’ll be seeing lots of updates so the version number will be a bit jumpy for a while.</p>
<h2>The Genesis of ruby_odata</h2>
<p>I started writing ruby_odata in order to interface with my database via services so I could do testing in Ruby and create objects from within the tests that I could use in my ASP.NET MVC application.&#160; I wrote about BDD testing in <a href="http://blogs.visoftinc.com/archive/2010/06/10/Behavior-Driven-Development-(BDD)-with-Cucumber-and-ASP.NET-MVC.aspx">an earlier post</a> where I fixed the speed of running the tests using Cucumber with <a href="http://github.com/tenderlove/mechanize" target="_blank">Mechanize</a>.&#160; Another area missing in .NET is the ability to automatically generate objects to test against like you can with <a href="http://github.com/ianwhite/pickle" target="_blank">Ian White’s Pickle</a>.&#160;&#160; <a href="http://github.com/ianwhite/pickle" target="_blank">Pickle</a> interacts nicely with factories and your database to create objects for tests.&#160; For example, a step like: <span style="font-family: courier new">Given a user exists with name: &quot;Damien&quot; </span>will automatically create a new user in the test database.&#160; This works dandy in the Ruby world (with <a href="http://rails.rubyonrails.org/classes/ActiveRecord/Base.html" target="_blank">ActiveRecord</a> for example), but against something like Entity Framework, not so much.&#160; With <a href="http://github.com/visoft/ruby_odata" target="_blank">ruby_odata</a> however, this is something that could work in a similar way. (Yet another idea for a project, a Pickle adapter that utilizes ruby_odata.&#160; Man, so many ideas, so little time.)</p>
<h2>Usage Overview</h2>
<p>The library is pretty straightforward to use.&#160; At the heart is the <strong>OData::Service</strong>.&#160; This is the root object that drives all of your operations against the services.&#160;&#160; Once you instantiate the <strong>OData::Service</strong>, dynamic methods based on the OData service’s collections are available to call.&#160; For example, using the <a href="http://odata.netflix.com/Catalog/" target="_blank">Netflix OData service</a>, we can see there is a collection called “Titles.”&#160; Within ruby_odata, the <strong>OData::Service </strong>will respond to a “Titles” method:</p>
<pre class="brush: ruby;">svc = OData::Service.new &quot;http://odata.netflix.com/Catalog/&quot;
puts &quot;Responds to Titles? #{svc.respond_to? :Titles}&quot; # =&gt; Responds to Titles? true</pre>
<p>
  <br />So, just by looking at the collections on the <a href="http://odata.netflix.com/Catalog/" target="_blank">main service page</a>, or <a href="http://odata.netflix.com/Catalog/$metadata" target="_blank">metadata page</a>, you can see what you can query.&#160; Here’s an example of querying for a movie (like we did earlier with a straight up URL):</p>
<p></p>
<pre class="brush: ruby;">svc.Titles.filter(&quot;Name eq 'Office Space'&quot;)
movie = svc.execute
# Now we can access properties of the Title (defined in the service metadata)
puts &quot;Average Rating: #{movie.AverageRating}&quot;
puts &quot;Release Year: #{movie.ReleaseYear}&quot;
puts &quot;URL: #{movie.Url}&quot;
# =&gt; Average Rating: 4.2
# =&gt; Release Year: 1999
# =&gt; URL: http://www.netflix.com/Movie/Office_Space/20358351</pre>
<p>Pretty cool, huh?</p>
<h2>The Basics</h2>
<p>There is a simple pattern for using the library.&#160; For queries, you call a collection on the service (like you saw with <strong>Titles</strong> in the Netflix example above), and that returns an <strong>OData::QueryBuilder</strong> object to you in which you can fluently add options like <strong>filter</strong> or <strong>expand</strong>.&#160; If you use multiple calls to filter, it will perform an “AND” query against the service, and multiple expand calls will yield multiple items being expanded.&#160; You can also mix the calls, like <strong>.filter(…).expand(…)</strong>.&#160; Once you are done building a query, you call the <strong>execute</strong> method on the service.&#160; The result of the execute is either a single entity or a collection of the entities based on your query.</p>
<p>In order to add, update, or delete, you need to call the appropriate method on the <strong>OData::Service</strong>.&#160; To add, you would use the dynamic method <strong>AddTo&lt;Collection Name&gt;</strong>, where the &lt;Collection Name&gt; is the name of the collection on the service (as defined by the metadata).&#160; To update, you would use <strong>update_object,</strong> passing in the updated version of the object.&#160; Finally, to delete, you would use <strong>delete_object</strong>, passing the object to delete.&#160; Once you do one of these operations, you need to persist the change using the <strong>save_changes</strong> method on the <strong>OData::Service</strong>.&#160; Currently, you need to call save_changes after each operation in order to persist the data.&#160; In the future you will be able to batch operations instead of persisting them one at a time.</p>
<h2>More Examples</h2>
<p>For more examples, download the <a href="http://github.com/visoft/ruby_odata" target="_blank">source code</a> from GitHub and setup the testing environment (instructions for setting up the test environment are located in the <a href="http://github.com/visoft/ruby_odata/blob/master/README.rdoc" target="_blank">README</a>).&#160; When you setup the test environment, you can follow along with the samples as shown in the <a href="http://github.com/visoft/ruby_odata/blob/master/README.rdoc" target="_blank">README</a>.&#160; There are examples for all the CRUD operations.</p>
<h2>Conclusion</h2>
<p>There you have it, an OData library for Ruby.&#160; I am very excited by the potential of <a href="http://www.odata.org/" target="_blank">OData</a>, and having the ability to consume the services easily within Ruby is extremely useful.&#160; I hope you find the library helpful.&#160; The current version is a bit of a work in progress since everything isn’t fully supported yet, but I will continue to work on the project.&#160; You can get involved by checking out the resources for the project:</p>
<ul>
<li>Source Code (hosted on GitHub): <a title="http://github.com/visoft/ruby_odata" href="http://github.com/visoft/ruby_odata">http://github.com/visoft/ruby_odata</a> </li>
<li>Documentation (hosted on rdoc.info): <a title="http://rdoc.info/projects/visoft/ruby_odata" href="http://rdoc.info/projects/visoft/ruby_odata">http://rdoc.info/projects/visoft/ruby_odata</a> </li>
<li>Issue tracking (hosted on GitHub): <a title="https://github.com/visoft/ruby_odata/issues" href="https://github.com/visoft/ruby_odata/issues">https://github.com/visoft/ruby_odata/issues</a></li>
<li>Wiki (hosted on GitHub): <a title="http://wiki.github.com/visoft/ruby_odata/" href="http://wiki.github.com/visoft/ruby_odata/">http://wiki.github.com/visoft/ruby_odata/</a> </li>
</ul>
<p>If you just want to start using it without the source code, you can install ruby_odata as a <a href="http://rubygems.org/gems/ruby_odata" target="_blank">gem from RubyGems.org</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.visoftinc.com/2010/06/12/introducing-a-ruby-odata-client-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

