Please note this is highly theoretical so don't slam me too hard for missing functionality. :)
I have plans for a couple of applications that will share some of the same functionality. One of the applications will be open source while others will be service offerings incorporating some of the features of the open source project.
What I want to do is to have the commercial projects include the parts of the open source project and get the relevant updates. Essentially I want them fused. I don't want to add specialized directories for this and I don't want everything pushed into the plugin. I want the open source application to be a part of the commercial application.
So enter the idea of Fusion. Fusion will be a rake task that will feed of off a yml file detailing the application you want fused into your own.
Here's a sample yml file:
address_book:
repo: https://stonean.googlecode.com/svn/address_book/trunk
models: address.rb
controllers: address_controller.rb
migrations: _create_addresses.rb, _add_county_to_addresses.rb
books_repo:
repo: https://stonean.googlecode.com/svn/book_repo/trunk
models: book.rb, author.rb
controllers: books_controller.rb, authors_controller.rb
migrations: _create_books.rb, _create_authors.rb
#Grab all models,views,controllers,migrations
shopping_cart:
The rake task will export the code into a temp dir and then merge them into your directory. It will need to warn for collisions on resources so that means some sort of inventory mechanism, but I don't think that's a big deal.
The views would feed off of the controller names (Rails convention stuff) and fuse the directory contents.
Some rake tasks could look like:
#Sync with all applications defined in the fusion.yml
rake fuse:all
#Show what files would be updated
rake fuse:all --show
#Sync with specific applications
rake fuse:application addresses
Well, that's the basic idea. I'm still fleshing out the details.

4 comments:
Interesting idea, but you should have a way to deal with the collisions up-front. What about adding a prefix and/or renaming option to the yaml
:
address_book:
repo: ...
prefix: ab_
models: address.rb
controllers: address_controller.rb
migrations: _create_addresses.rb, _add_county_to_addresses.rb
or
address_book:
repo: ...
models: address.rb => ab_address.rb
controllers: address_controller.rb => ab_address_controller.rb
migrations: _create_addresses.rb, _add_county_to_addresses.rb
Ahh, That makes a lot of sense. I like the prefix value that would do this automatically for all resources. But being able to selectively prefix would be a nice, flexible combination.
Thanks!
On further thought, that won't work. Prefixing or even namespacing the models and/or controllers will break a lot of stuff. I don't want to try and cover all the things this will break in Fusion code.
I would rather put the responsibility on the composite application to be architected for the inclusion of these components and keep Fusion simple.
Andrew, this is very interesting. I previously tried importing a complete application as a Pistonized directory. It worked rather well. Why not wrap Piston inside Fuse ? The only problem would be the merging: Piston currently can't have more than one set of properties on a directory.
The only solution I see at the moment for that would be to checkout the code to tmp/, and merge/symlink to the main application afterwards.
Post a Comment