Created
February 18, 2009 06:12
-
-
Save prepor/66224 to your computer and use it in GitHub Desktop.
Autogit for Rails and plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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