Create and Deploy a RubyGem from Scratch

1
1340

Taking a different approach than normal, in this coding exercise 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         = ["[email protected]"]

  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

1 COMMENT

  1. This is not what your repo has for january 23.rb It’s the next one.
    Also Rubocop prefers that you don’t do this test_8. test8 is okay. Snake casing variables and methods is good but not with numbers. I use VSCode with the Rubocop linter extension and I see green squiggly underlines for all these kinds of things. One most never worry about is # doc at the top of modules and classes. Single quotes are always preferred over double quotes without any interpolation. Methods get 10 lines or less recommended and classes and modules 100 or less lines. It really makes you think about how to simplify your code. Much like you did when you refactored this in the previous coding exercise. Thanks Jordan.

LEAVE A REPLY

Please enter your comment!
Please enter your name here