---
title: "Make Ruby Gem"
author: "myrev"
date: "2010-09-09T21:41:12Z"
tags: ["Git", "Linux", "OSX", "Ruby", "rubygems"]
categories: ["编程语言"]
slug: "make-ruby-gem"
draft: false
lastmod: "2010-09-09T22:20:14Z"
id: 759800
url: "https://myrev.iteye.com/blog/759800"
---

# 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 = []
end

Dir["#{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
    end
  else
  end
end
```

 

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