home  |  articles  |  quotes   ::   website  |  profile

RPoint

RPoint – Why Ruby? What about XML?

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’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.

This is very true – and in fact I have written tools like this in the past. But here’s the problem I’ve encountered with XML. You end up trying to build a programming language out of XML. That’s basically where CAML has ended up. And I don’t know a single person who actually enjoys looking at, much less creating, CAML.

Here’s what I like about the ruby approach. It let’s you write something like this:

site_names = ["Site One", "Site Two", "Site Three"]
at "http://localhost" do
  site_names.each do |name|
    create_web name, TeamSite
  end
end

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 – 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.

Want to create 50 test sites? Here you go.

at "http://localhost" do
  50.times do |i|
    create_web "Site #{i}", BlankSite
  end
end

’nuff said.

RPoint
Ruby
SharePoint

Comments (4)

Permalink

RPoint – Hopes and Dreams

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 I want RPoint to be able to support.

Creating a List Template

This script would create a list template.

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

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:

at "http://localhost" do
  create_list "My Milestones", Milestones
end

Second, and possibly cooler, you could generate a list definition:

>ir generate.rb list_definition --source MilestoneTemplate.rb

Migrations

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’s all managed within source control as an ordered list of steps to execute.

I want to be able to do something similar with RPoint.

# 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

Okay – that’s enough dreaming for now. Just incase anyone missed the intro THIS CODE DOES NOT WORK. It is completely imaginary. I am hoping 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.

RPoint
Ruby
SharePoint

Comments (0)

Permalink

RPoint – a DSL for SharePoint

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’m going to keep this post short so I won’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 rspec, rake, and datamapper.

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?

Anyway, this weekend I started working on an IronRuby-based DSL for SharePoint scripting. I’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’t set up today as nicely as they should be long term, but I’ve been really excited by the progress and the possibilities.

RPoint will allow you to write code like this to create SharePoint sites:

# 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 => "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

I think that’s pretty cool. Beyond simply creating sites, RPoint will allow you to create lists, views and probably upload resources like images and documents.

My goals for RPoint are to be able to do the following:

  • Easily write scripts to create site structures and lists
  • Rails-like “Migrations” for applying changes to existing sites
  • Custom site template and list definitions in ruby as opposed to XML
  • Ability to run template/list definitions against a live site or generate schema.xml/onet.xml files for production deployment
  • Support web-services automation as well as object model automation (this will be tough)

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.

To get RPoint in its current form, you can download it from GitHub.

RPoint
Ruby
SharePoint

Comments (2)

Permalink