I have written a ruby gem and I would like to have a rake task for publishing the gem to my own GemInABox repository : http://my-gem-repo.com.

What is the simplest way of achieving this goal?

Also, I would like to prevent the default publishing to Rubygems.org.

有帮助吗?

解决方案

Information on hosting your own gem can be found at http://guides.rubygems.org/run-your-own-gem-server/

Setup the server according to that site and the README on https://github.com/cwninja/geminabox

To release your gem:

gem build my_ruby_gem.gemspec
#push all versions to the gem server
gem inabox 

The first time you run gem inabox, you will configure the destination.

For rake tasks, you could put this Rakefile in your gem source:

#!/usr/bin/env rake
desc "build the gem"
task :build do
  system("gem build *.gemspec")
end

desc "push the gem to the gem inabox server"
task :release do
  system("gem inabox")
end

desc "build and release the gem"
task :build_and_release => [:build,:release]

The system calls are definitely hacks, but they are a simple way to make it work. Better rake tasks are requested in: https://github.com/cwninja/geminabox/issues/59

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top