gems:unpack for gems that don’t unpack

I couldn't figure out why my gems wouldn't unpack until I ran across this: http://metaclass.org/2009/4/13/rake-gems-unpack. My gems have rake tasks and I have to include them in the app's rakefile to make them available so Rails won't unpack them.

I did this instead:

  def muck_gems
    ['cms-lite', 'disguise', 'uploader', 'muck-solr', 'muck-raker', 'muck-engine',
    'muck-users', 'muck-activities', 'muck-comments', 'muck-profiles', 'muck-friends',
    'muck-contents', 'muck-blogs', 'muck-shares'] #'muck-invites'
  end

  # execute commands in a different directory
  def inside(dir, &block)
    FileUtils.cd(dir) { block.arity == 1 ? yield(dir) : yield }
  end

  desc "unpacks all muck gems into vendor/gems using versions installed on the local machine."
  task :unpack do
    gem_path = File.join(File.dirname(__FILE__), '..', '..', 'vendor', 'gems')
    FileUtils.mkdir_p(gem_path) unless File.exists?(gem_path)
    inside gem_path do
      muck_gems.each do |gem_name|
        system("gem unpack #{gem_name}")
        system("gem specification #{gem_name} > .specification")
      end
    end
  end

Comments

blog comments powered by Disqus