Git_tools
How to use
Create a yaml file in your config/ directory and name it submodules.yml.
Add the git submodules that you want to want to use in your application like so:
submodules:
rspec: git://github.com/dchelimsky/rspec.git
rspec_rails: git://github.com/dchelimsky/rspec-rails.git
geokit: git://github.com/ptb/geokit.git
asset_packager: git://github.com/sbecker/asset_packager.git
paperclip: git://github.com/thoughtbot/paperclip.git
will_paginate: git://github.com/mislav/will_paginate.git
exception_notification: git://github.com/rails/exception_notification.git
cucumber: git://github.com/aslakhellesoy/cucumber.git
ssl_requirement: git://github.com/rails/ssl_requirement.git
rails: git://github.com/rails/rails.git
active_merchant: git://github.com/Shopify/active_merchant.git
A couple of things, it needs to follow the structure above with the name submodules and defining each below it. Use the name that you want the plugin to be named when checking out. Put the git location as the value.
Now, create a new Rake task in lib/tasks directory. I call mine submodules.rake. Here is what my file looks like:
require 'git_tools'
@configration = File.join(RAILS_ROOT, "config/submodules.yml")
namespace :git do
namespace :submodule do
desc "Setup Submodules on checkout"
task :setup do
GitTools::Submodule.checkout
end
desc "Remove Submodule cache"
task :remove, :submodule do |task, args|
GitTools::Submodule.remove(args.submodule)
end
end
namespace :update do
desc "Update all Submodules"
task :all => :environment do
GitTools::Submodule.update_all(@configration)
end
GitTools::Submodule.individual_tasks(@configration) do |name|
desc "Update #{name} submodule"
task name.to_sym => :environment do
GitTools::Submodule.submodule_update("#{name}")
end
end
end
end
Command Line
When creating a new project, it would be nice to just write your submodule.yml file and then shoot a command off in the terminal and have all your submodules installed for you. Well, now you can! Just do:
gitools all
That will install all the submodules from your config/submodule.yml file. I'll be adding individual submodule adds via command line next as well as other command line tools.