Skip to content

Instantly share code, notes, and snippets.

@prepor
Created February 18, 2009 06:12
Show Gist options
  • Save prepor/66224 to your computer and use it in GitHub Desktop.
Save prepor/66224 to your computer and use it in GitHub Desktop.
Autogit for Rails and plugins
# In boot.rb
require File.join RAILS_ROOT, 'config/autogit_libs.rb'
require "railties/lib/initializer"
Rails::Initializer.run(:set_load_path)
# Rails.boot!
class AutogitPluginLocator < Rails::Plugin::Locator
def plugins
AutogitPlugins.map {|path, commit| Rails::Plugin.new(File.join(autogit(AutogitSources.map{|s| s + path }, commit), '..')) }
end
end
# environment.rb
config.plugin_locators << AutogitPluginLocator
# autogit_libs.rb
require File.join RAILS_ROOT, 'lib/autogit.rb'
AutogitSources = %w{
git://github.com/
}
AutogitLibs = {
"marcel/aws-s3" => "ac97d4715c859500d03970d802eafaf2166f5f1a",
"rails/rails" => "v2.2.2",
"jgarber/redcloth" => "RELEASE_4_1_1",
"jamis/capistrano" => "v2.5.4",
"cpjolicoeur/bb-ruby" => "REL-0.8.4",
"jamis/capistrano-ext" => "a76b7f6e1d114c89a0e97a75f7f04c1fc9b308df",
"tenderlove/mechanize" => "REL_0.8.5"
}
AutogitPlugins = {
"mislav/will_paginate" => "v2.3.7",
"paladiy/acts_as_taggable_on_steroids" => "e91472fb7e30e11ecfca8cb08d9618fb115d82c4",
"thoughtbot/paperclip" => "v2.2.5",
}
AutogitPaths = {}
AutogitLibs.each do |path, commit|
AutogitPaths[path] = autogit(AutogitSources.map{|s| s + path }, commit)
end
# and rewrite autogit method for Rails repo
def set_load_path!(path)
Dir.new(path).select {|v| v != '.' && v != '..' }.each do |sub_path|
lib_path = File.join(path, sub_path, "lib")
$LOAD_PATH.push(lib_path) if File.exists?(lib_path)
end
with_lib = File.join(path, "lib")
path = File.exists?(with_lib) ? with_lib : path
$LOAD_PATH.push(path)
path
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment