- Create a RubyGems Account
- Install RVM (Ruby Version Manager) : RVM
- Install Bundler:
gem install bundler
- Navigate to the parent directory you want to create your gem repository directory in.
- Create Gemset:
rvm gemset create yourGemName
- Use Gemset:
rvm gemset use yourGemName
- Bundle Gem:
bundle gem yourGemName
- Open the app's parent file located at
lib/yourGemName.rb
- Create a
Hello World
output
require "yourGemName/version"
module yourGemName
class Test
def say_hello
puts "Hello World!"
end
end
end
- Create an executable file at
bin/yourGemName
(no file extension) - Add Shebang
#!/usr/bin/env ruby
and code to call yourHello World
output
#!/usr/bin/env ruby
require 'yourGemName'
test = yourGemName::Test.new
test.say_hello
- Create a
CHANGELOG.md
file in the project directory - Create repository on Github
- Make initial commit:
git commit -m "Initial commit"
- Push code to repository on Github:
git remote add origin [email protected]:yourusername/yourGemRepo.git
git push -u origin master
- Open
gemspec
-/yourGemName.gemspec
- Update todo lines:
- Update
spec.summary
- Update
spec.descriptions
- Update
spec.homepage
- Update
spec.metadata["source_code_uri"]
(Github Repo Page) - Update
spec.metadata["changelog_uri"]
(Github CHANGELOG.md link) - Update
spec.bindir
tobin
- Update
spec.executeables
toyourGemName
(the file in/bin
)
- Update
- Run Bundle Install:
bundle install
- Build Binary:
rake install
- Test output:
yourGemName
--> "Hello World"
- Commit Changes to Github
- Build Gem:
gem build yourGemName
- Push Gem to RubyGems.org:
gem push yourGemName-0.1.0.gem