Building a gem
Backlinks
The basics
Your ruby gems needs the following files:
.
āāā yourgem.gemspec
āāā lib
āāā yourgem.rb
Convention is to have one file in lib/
which is named the same as your file - this
is what you load when you require 'gemname'
.
The gemspec defines stuff about the gem - who made it, website, etc. Example gemspec:
Gem::Specification.new do |s|
s.name = "hola"
s.version = "0.0.0"
s.summary = "Hola!"
s.description = "A simple hello world gem"
s.authors = ["Nick Quaranto"]
s.email = "nick@quaran.to"
s.files = ["lib/hola.rb"]
s.homepage =
"https://rubygems.org/gems/hola"
s.license = "MIT"
end
This is in ruby.
Once you have the gem set out, you can build and then install it:
gem build yourgem.gemspec # will create yourgem.gem
gem install ./yourgem.gem # will install locally
And then you can use it locally. Good enough for now!
External links
Make your own gem - rubygems
Official guidance