<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>examples/ruby-committers-generator.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -19,3 +19,5 @@ spec/data/(w3ctests|rdfatests)
 spec/data/latest_All\.zip$
 spec/data/rdfa-xhtml1-test-manifest\.rdf$
 spec/w3c_(entailment|miscellaneous|parser|rdfa)_spec\.rb$
+^pkg/
+^ruby\-committers\.yml$</diff>
      <filename>.hgignore</filename>
    </modified>
    <modified>
      <diff>@@ -208,13 +208,6 @@ h4(#describe-queries). @DESCRIBE@
 
 Returns a &lt;?api Redleaf::SyntaxQueryResult ?&gt;
 
-- @SELECT@ := Returns a &lt;?api Redleaf::BindingQueryResult ?&gt;
-- @CONSTRUCT@ := Returns a &lt;?api Redleaf::GraphQueryResult ?&gt;
-- @ASK@ := Returns a &lt;?api Redleaf::BooleanQueryResult ?&gt;
-- @DESCRIBE@ := Returns a &lt;?api Redleaf::SyntaxQueryResult ?&gt;
-
-These four result types have different result data (e.g., @BindingQueryResult@ objects have _bindings_ which map to keywords in the query, whereas @BooleanQueryResult@ objects just contain @true@ or @false@). All of them support the @Enumerable@ interface, however. See the individual API documentation for more on how to use the result type you're expecting.
-
 h4(#query-result-formatters). Formatting Query Results
 
 Query results also support convenient exporting in a few different formats, which makes it easy to set up a SPARQL service that can return results formatted appropriately via content negotiation.</diff>
      <filename>docs/manual/src/tour/graphs.page</filename>
    </modified>
    <modified>
      <diff>@@ -44,6 +44,8 @@
 VALUE rleaf_cRedleafGraph;
 librdf_uri *rleaf_contexts_feature;
 
+static VALUE rleaf_set_serializer_ns( VALUE, VALUE );
+
 
 /* --------------------------------------------------
  *	Memory-management functions
@@ -754,19 +756,39 @@ rleaf_redleaf_graph_contexts( VALUE self ) {
 
 /*
  *  call-seq:
- *     graph.serialized_as( format )   -&gt; string
+ *     graph.serialized_as( format, nshash={} )  -&gt; string
  *
  *  Return the graph serialized to a String in the specified +format+. Valid +format+s are keys
  *  of the Hash returned by ::serializers.
+ * 
+ *  The +nshash+ argument can be used to set namespaces in the output (for serializers that
+ *  support them). It should be of the form:
+ * 
+ *    { :nsname =&gt; &lt;namespace URI&gt; }
+ * 
+ *  Examples:
+ *     turtle = graph.serialized_as( 'turtle' )
+ *     xml = graph.serialized_as( 'rdfxml-abbrev', :foaf =&gt; 'http://xmlns.com/foaf/0.1/' )
  *
  */
 static VALUE
-rleaf_redleaf_graph_serialized_as( VALUE self, VALUE format ) {
+rleaf_redleaf_graph_serialized_as( int argc, VALUE *argv, VALUE self ) {
 	rleaf_GRAPH *ptr = rleaf_get_graph( self );
 	librdf_serializer *serializer;
 	size_t length = 0;
 	const char *formatname;
 	unsigned char *serialized;
+	VALUE format = Qnil;
+	VALUE nshash = Qnil;
+
+	rb_scan_args( argc, argv, &quot;11&quot;, &amp;format, &amp;nshash );
+	rleaf_log_with_context(
+		self,
+		&quot;debug&quot;,
+		&quot;Serializing as %s. Namespace hash is: %s&quot;,
+		RSTRING_PTR(rb_inspect( format )),
+		RSTRING_PTR(rb_inspect( nshash ))
+	  );
 	
 	formatname = StringValuePtr( format );
 	rleaf_log_with_context( self, &quot;debug&quot;, &quot;trying to serialize as '%s'&quot;, formatname );
@@ -779,6 +801,10 @@ rleaf_redleaf_graph_serialized_as( VALUE self, VALUE format ) {
 	if ( !serializer )
 		rb_raise( rleaf_eRedleafError, &quot;could not create a '%s' serializer&quot;, formatname );
 
+	/* Set namespaces in the serializer for entries in the argshash */
+	if ( RTEST(nshash) )
+		rb_iterate( rb_each, nshash, rleaf_set_serializer_ns, (VALUE)serializer );
+
 	/* :TODO: Support for the 'baseuri' argument? */
 	serialized = librdf_serializer_serialize_model_to_counted_string( serializer, NULL, ptr-&gt;model, &amp;length );
 	librdf_free_serializer( serializer );
@@ -792,6 +818,29 @@ rleaf_redleaf_graph_serialized_as( VALUE self, VALUE format ) {
 
 
 /*
+ * Iterator function: map a [namespace, uri] tuple into a namespace registered with
+ * the serializer_value, which is a librdf_serializer pointer cast as a VALUE.
+ */
+static VALUE
+rleaf_set_serializer_ns( VALUE nspair, VALUE serializer_value ) {
+	librdf_serializer *serializer = (librdf_serializer *)serializer_value;
+	VALUE ns = Qnil;
+	librdf_uri *nsuri;
+	
+	Check_Type( nspair, T_ARRAY );
+	if ( RARRAY_LEN(nspair) != 2 )
+		rb_raise( rb_eArgError, &quot;namespace pair must be [key, value]&quot; );
+
+	ns    = rb_obj_as_string( rb_ary_entry(nspair, 0) );
+	nsuri = rleaf_object_to_librdf_uri( rb_ary_entry(nspair, 1) );
+	
+	librdf_serializer_set_namespace( serializer, nsuri, (const char *)RSTRING_PTR(ns) );
+
+	return Qnil;
+}
+
+
+/*
  *  call-seq:
  *     graph.execute_query( qstring, language=:sparql, limit=nil, offset=nil ) -&gt; queryresult
  *
@@ -1383,7 +1432,7 @@ rleaf_init_redleaf_graph( void ) {
 
 	rb_define_method( rleaf_cRedleafGraph, &quot;contexts&quot;, rleaf_redleaf_graph_contexts, 0 );
 
-	rb_define_method( rleaf_cRedleafGraph, &quot;serialized_as&quot;, rleaf_redleaf_graph_serialized_as, 1 );
+	rb_define_method( rleaf_cRedleafGraph, &quot;serialized_as&quot;, rleaf_redleaf_graph_serialized_as, -1 );
 
 	rb_define_method( rleaf_cRedleafGraph, &quot;execute_query&quot;, rleaf_redleaf_graph_execute_query, -1 );
 	</diff>
      <filename>ext/graph.c</filename>
    </modified>
    <modified>
      <diff>@@ -397,6 +397,28 @@ describe Redleaf::Graph do
 				%r{&lt;\?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;\?&gt;\n&lt;rdf:RDF}
 		end
 
+		it &quot;can be serialized with namespaces&quot; do
+			@graph.serialized_as( 'rdfxml', :foaf =&gt; FOAF ).should =~
+				%r{xmlns:foaf=&quot;#{FOAF}&quot;}
+		end
+
+		it &quot;allows an Array of tuples to set namespaces&quot; do
+			@graph.serialized_as( 'rdfxml', [['foaf', FOAF]] ).should =~
+				%r{xmlns:foaf=&quot;#{FOAF}&quot;}
+		end
+
+		it &quot;raises an exception if its passed a Symbol instead of a namespace hash&quot; do
+			expect {
+				@graph.serialized_as( 'rdfxml', :foaf )
+			}.to raise_error( NoMethodError, /undefined method `each'/i )
+		end
+
+		it &quot;raises an exception if its passed a single-element Array instead of a namespace hash&quot; do
+			expect {
+				@graph.serialized_as( 'rdfxml', [:foaf] )
+			}.to raise_error( TypeError, /wrong argument type symbol/i )
+		end
+
 		it &quot;can sync itself to the underlying store&quot; do
 			@graph.sync.should be_true()
 		end</diff>
      <filename>spec/redleaf/graph_spec.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>1cf4f135d64d7ceb48ea04f872e7441aa92d18c3</id>
    </parent>
  </parents>
  <author>
    <name>Michael Granger</name>
    <email>ged@FaerieMUD.org</email>
  </author>
  <url>http://github.com/ged/redleaf/commit/68a9011a03374fc8425193990379bc35367aa0e6</url>
  <id>68a9011a03374fc8425193990379bc35367aa0e6</id>
  <committed-date>2009-09-16T18:58:50-07:00</committed-date>
  <authored-date>2009-09-16T18:58:50-07:00</authored-date>
  <message> * Added an example port of Yuki Sonoda's ruby-committers RDF generator
 * Added an optional namespace hash to Redleaf::Graph#serialized_as to allow one to
   set namespaces for generated output.</message>
  <tree>3b3e9a46ad3369c222f9fe1a73fc0d55010a7eb9</tree>
  <committer>
    <name>Michael Granger</name>
    <email>ged@FaerieMUD.org</email>
  </committer>
</commit>
