Creating your own ruby gems
It’s very easy to create a gem from your own rails plugin. Thanks to http://blogs.cocoondev.org/crafterm/archives/004653.html for getting me started down this path. Here’s how I did it with the memcache_fragments plugin.
Put this into your plugin’s Rakefile:
require ‘rubygems’
require ‘rake/gempackagetask’
spec = Gem::Specification.new do |s|
s.name = “memcache_fragments”
s.version = “0.0.1″
s.author = “Yan Pritzker”
s.email = “yan@fifteenreasons.com”
s.homepage = “http://skwp.wordpress.com/memcache_fragments/”
s.platform = Gem::Platform::RUBY
s.summary = “Makes rails fragment cache play nicely with memcache-client and gives it a time-based expiry parameter”
s.files = FileList["lib/**/*"].to_a
s.require_path = “lib”
s.autorequire = “memcache_fragments”
s.test_files = FileList["{test}/**/*test.rb"].to_a
s.has_rdoc = true
s.extra_rdoc_files = ["README"]
s.add_dependency(”memcache-client”, “>= 1.0.3″)
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_tar = true
end
Now, just rake gem and you’re done!
Don’t forget, if you install your plugin as a gem you will have to require it in your code.










No Comments Yet