myrev 发表于 2013-1-16 18:20:54

Make Ruby Gem

How to make gem

 
1. Install echoe gem

$ gem install echoe
2. make gem


$ mkdir hello_world
$ vi hello_world/Rakefile
require 'rubygems'require 'rake'require 'echoe'Echoe.new('wkhtmltopdf_32_amd64', '0.0.1') do |p|p.description    = "wkhtmltopdf support linux 32,64 and OSX 32"p.url            = "http://github.com/sloanwu/wkhtmltopdf_32_amd64.git"p.author         = "Sloan Wu"p.email          = "sloanwu@gmail.com"p.ignore_pattern = ["tmp/*", "script/*"]p.development_dependencies = []endDir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext } save file



:~/hello_world$ rake manifest

:~/hello_world$ rake -T

get a bunch of tasks to help you manage your gem.


:~/hello_world$ rake gemspec

You can modify the project.gemspec

eg:
Gem::Specification.new do |s|s.name = %q{wkhtmltopdf_32_amd64}s.version = "0.0.1"s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=s.authors = ["Sloan Wu"]s.date = %q{2010-09-09}s.description = %q{wkhtmltopdf support linux 32,64 and OSX 32}s.email = %q{sloanwu@gmail.com}s.executables = ["wkhtmltopdf"]s.extra_rdoc_files = ["bin/test.rb", "bin/wkhtmltopdf", "bin/wkhtmltopdf_darwin_386", "bin/wkhtmltopdf_linux_386", "bin/wkhtmltopdf_linux_amd64"]s.files = ["Rakefile", "bin/test.rb", "bin/wkhtmltopdf", "bin/wkhtmltopdf_darwin_386", "bin/wkhtmltopdf_linux_386", "bin/wkhtmltopdf_linux_amd64", "Manifest", "wkhtmltopdf_32_amd64.gemspec"]s.homepage = %q{http://github.com/sloanwu/wkhtmltopdf_32_amd64.git}s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Wkhtmltopdf_32_amd64"]s.require_paths = ["lib"]s.rubyforge_project = %q{wkhtmltopdf_32_amd64}s.rubygems_version = %q{1.3.7}s.summary = %q{wkhtmltopdf support linux 32,64 and OSX 32}if s.respond_to? :specification_version then    current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION    s.specification_version = 3    if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then    else    endelseendend 

package to a gem

:~/hello_world$ gem build wkhtmltopdf_32_amd64.gemspec
 
 
3. pushlish on github


1) you need sign up a github user.

2) you need set the github user with a ssh key.

you can get help from http://help.github.com/linux-key-setup/


Global setup:

Download and install Git

$ git config --global user.name "sloanwu"

$ git config --global user.email sloanwu@gmail.com
 

Next steps:

  $ mkdir wkhtmltopdf_32_amd64
  $ cd wkhtmltopdf_32_amd64
  $ git init
  $ touch README
  $ git add README
  $ git commit -m 'first commit'
  $ git remote add origin git@github.com:sloanwu/wkhtmltopdf_32_amd64.git
  $ git push origin master
     

Existing Git Repo?

  $ cd existing_git_repo
  $ git remote add origin git@github.com:sloanwu/wkhtmltopdf_32_amd64.git
  $ git push origin master

4. publish on Rubygems.org


$ gem update --system

    Update to the latest RubyGems version

$ gem build foo.gemspec

    Build your gem

$ gem push foo-1.0.0.gem
 
页: [1]
查看完整版本: Make Ruby Gem