-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
retitle 459882 libgemplugin-ruby1.8: should support packaged gems
thanks
Attached is a more interesting patch: it add supports for packaged gem
plugins. This patch just needs to be dropped into 'debian/patches', and
we need to add 'debian/libgemplugin-ruby1.8.dirs' containing:
usr/share/gemplugins/1.8
Packaged gem plugins (e.g. mongrel_cluster) should install their files
as following:
* 'lib/<package>/*.rb' gets installed like a normal ruby module:
/usr/lib/ruby/<ruby_version>/<package>
* '<package>.gemspec' gets installed (no changes needed) as :
/usr/share/gemplugins/<ruby_version>/<package>.gemspec
* 'resources' gets installed as:
/usr/share/gemplugins/<ruby_version>/<package>/resources
For instance, the contents of the "mongrel-cluster" package would be:
/usr/lib/ruby/1.8/mongrel_cluster/init.rb
/usr/lib/ruby/1.8/mongrel_cluster/recipes.rb
/usr/lib/ruby/1.8/mongrel_cluster/recipes_1.rb
/usr/lib/ruby/1.8/mongrel_cluster/recipes_2.rb
/usr/share/gemplugins/1.8/mongrel_cluster.gemspec
/usr/share/gemplugins/1.8/mongrel_cluster/resources/defaults.yaml
What do you think?
Cheers,
Jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFHhVrf4mJJZqJp2ScRAq6IAJ4vaW/hj+CTAQq/W79wjxh1wh+LLQCcDBRI
vji6OcD4cXllrswT2Gf7BgE=
=IvQF
-----END PGP SIGNATURE-----
diff -urN libgemplugin-ruby-0.2.2.orig/lib/gem_plugin.rb libgemplugin-ruby-0.2.2/lib/gem_plugin.rb
--- libgemplugin-ruby-0.2.2.orig/lib/gem_plugin.rb 2007-05-12 22:21:38.000000000 +0200
+++ libgemplugin-ruby-0.2.2/lib/gem_plugin.rb 2008-01-10 00:18:37.000000000 +0100
@@ -51,6 +51,7 @@
EXCLUDE = true
INCLUDE = false
+ SITE_GEMPLUGINS = '/usr/share/gemplugins/' + Config::CONFIG['ruby_version']
class PluginNotLoaded < StandardError; end
@@ -105,9 +106,24 @@
# To prevent this load requires the full path to the "init.rb" file, which
# avoids the RubyGems autorequire magic.
def load(needs = {})
- sdir = File.join(Gem.dir, "specifications")
- gems = Gem::SourceIndex.from_installed_gems(sdir)
+ gems = Gem::SourceIndex.from_installed_gems
needs = needs.merge({"gem_plugin" => INCLUDE})
+
+ # add packaged gem plugins
+ Dir.glob(File.join(SITE_GEMPLUGINS, "*.gemspec")).each do |file_name|
+ gemspec = Gem::SourceIndex.load_specification(file_name.untaint)
+ if gemspec
+ class << gemspec
+ def full_gem_path
+ File.join(File::dirname(@loaded_from), name)
+ end
+ def full_init_path
+ File.join(Config::CONFIG['rubylibdir'], name, "init.rb")
+ end
+ end
+ gems.add_spec(gemspec)
+ end
+ end
gems.each do |path, gem|
# don't load gems more than once
@@ -129,9 +145,16 @@
# Previously was set wrong, we already have the correct gem path!
#gem_dir = File.join(Gem.dir, "gems", "#{gem.name}-#{gem.version}")
- gem_dir = File.join(Gem.dir, "gems", path)
+ gem_dir = gem.full_gem_path
+
+ #Â Load correct init.rb, according to whether this is a
+ # packaged gem plugin or not
+ if gem.respond_to?("full_init_path")
+ require gem.full_init_path
+ else
+ require File.join(gem_dir, "lib", gem.name, "init.rb")
+ end
- require File.join(gem_dir, "lib", gem.name, "init.rb")
@gems[gem.name] = gem_dir
end
end