Build and Deploy a RubyGem From Scratch

In this guide we’re going to create and a deploy a RubyGem to rubygems.org.

Ruby FizzBuzz

Video Guide

Summary

In this guide we’re going to create and a deploy a RubyGem to rubygems.org.

Process

Generate the Gem

bundle gem tippy

Edit the Gemspec File

# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'tippy/version'

Gem::Specification.new do |spec|
  spec.name          = "tippy"
  spec.version       = Tippy::VERSION
  spec.authors       = ["Jordan Hudgens"]
  spec.email         = ["jordan@wow.com"]

  spec.summary       = %q{A gem for generating tip values based on a number of inputs.}
  spec.homepage      = "https://github.com/jordanhudgens/tippy"
  spec.license       = "MIT"

  spec.files         = `git ls-files -z`.split("\x0").reject do |f|
    f.match(%r{^(test|spec|features)/})
  end
  spec.bindir        = "exe"
  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
  spec.require_paths = ["lib"]

  spec.add_development_dependency "bundler", "~> 1.13"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency "rspec", "~> 3.0"
end

Update the .gitignore File

/.bundle/
/.yardoc
/Gemfile.lock
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.gem

Add Code

GitHub Link

Deploy to GitHub

Bundle Local Gemfile

bundle install

Generate and Deploy to RubyGems.org

bundle exec rake release

Resources

Jordan Hudgens

Jordan Hudgens

I've been a software engineer for the past decade and have traveled the world building applications and training individuals on a wide variety of topics.


View All Posts