<?xml version="1.0" encoding="UTF-8"?>
<posts type="array">
  <post>
    <body>Considering it's such a fundamental task when sharing code with the wider web, there are "many examples":http://stackoverflow.com/questions/151677/tool-for-adding-license-headers-to-source-files of how to add licence / license headers to source code files.

However I needed a reason to start learning a little bit of Ruby, so I used Todd Werth's "app skeleton":http://blog.infinitered.com/entries/show/5 and took Xavier Hanin's "example":http://xhab.blogspot.com/2007/03/adding-license-header-to-whole-code.html to work up a little app called _Sourcify_.

Sourcify is a simple Ruby program (one script + licence template files) which adds and removes licences to source code. It includes licence file templates for the mit, bsd, apache, lgpl, agpl, and gpl licences.

Using it is as simple as @./sourcify.rb mit "John Smith" my-project/@. Help is available via @./sourcify.rb -h@ which will describe all the command line options currently available. *NOTE:* The default behaviour is to make modifications to a copy of the project, leaving the originals untouched.

It'll be a nice toy project to learn some more Ruby: on the todo list would be: adding all popular licence files in multiple languages, adding in interactive prompts to fill out required details for some licences (like the Mozilla Public Licence), adding in actual licence files to the root of a project, accepting file types as arguments, adding in support for more programming languages, and packaging Sourcify as a Ruby gem.

I wouldn't say it's the sexiest project to obsess over, but if it had templates for most popular open source licences, as well as information on how to select the right licence, it could be a nice one-stop licence shop for developers.

Once I've done a bit more work I'll open up a public git repository, but for now it's available right "here":http://www.experimeme.net/sourcify.zip.</body>
    <created-at type="datetime">2008-12-15T19:25:06Z</created-at>
    <ham-comments-count type="integer">0</ham-comments-count>
    <id type="integer">30</id>
    <permalink>sourcify-add-licence-headers-to-source-files</permalink>
    <title>Sourcify: Add licence headers to source files</title>
    <updated-at type="datetime">2009-05-10T22:37:49Z</updated-at>
  </post>
  <post>
    <body>As I've "previously mentioned":http://www.experimeme.net/rubyamf-currently-breaks-rspec-tests, RubyAMF gives you @render:amf@ so you can send controller responses as binary AMF streams to Flash / Flex applications (also known as Flash remoting).

Setting it up for rails is reasonably straightforward. You just need to @script/install http://rubyamf.googlecode.com/svn/trunk/rubyamf@ to install the plugin. If you're developing locally you'll want to restart your webserver, and then you should be able to browse to http://localhost:3000/rubyamf_gateway/ which will return an http response with a logo of RubyAMF.

Once that's done the class mappings need to be specified, so that (for instance) a Tag class in ActionScript returned by a client swf is automatically deserialised into the appropriate Tag class within the Rails application.

Over a few posts I'm going to demonstrate putting together a Flex-based tag cloud which uses RubyAMF, so the mapping (which is defined in @config/rubyamf_config.rb@) would be this:

&lt;code lang="ruby"&gt;
ClassMappings.register(:actionscript =&gt; 'Tag', :ruby =&gt; 'Tag', :type =&gt; 'active_record',
:attributes =&gt; ["id", "name", "count"])
&lt;/code&gt;

(There's plenty of examples in the config file along with other options worth looking at.)

Once that's defined you'll want to specify a controller method which returns your tag cloud data and also responds to AMF requests. As I "mentioned earlier":http://www.experimeme.net/adding-tagging I'm using "acts_as_taggable_on_steroids":http://agilewebdevelopment.com/plugins/acts_as_taggable_on_steroids at the moment, and this plugin gives me a method which returns all tags and their counts, so the method (defined in my @posts_controller.rb@ file) is as simple as this:
&lt;code lang="ruby"&gt;
def tag_counts
	@tags = Post.tag_counts
	respond to do |format|
		format.html # If you'd like to do something in html
		format.amf { render:amf =&gt; @tags }
	end
end
&lt;/code&gt;

At this point you'll have an AMF gateway and a method which will return a complex datatype serialised as AMF. The next step is to build a Rich Client in Flex to consume this service.</body>
    <created-at type="datetime">2008-11-30T17:31:46Z</created-at>
    <ham-comments-count type="integer">0</ham-comments-count>
    <id type="integer">26</id>
    <permalink>setting-up-rubyamf-for-flash-and-flex</permalink>
    <title>Setting up RubyAMF for Flash and Flex</title>
    <updated-at type="datetime">2008-12-08T00:06:08Z</updated-at>
  </post>
</posts>
