Manasi Salvi

Building a Ruby gem

This post refers to exercise 46 in the book Learn Ruby the Hard Way. Here is the work flow for building a simple Ruby gem:

Rakefile	data		ext		hello.gemspec	tests
bin		doc		hello-1.0.gem	lib

./bin:
hello

./data:

./doc:

./ext:

./lib:
hello.rb

./tests:
test_hello.rb

wickinot:ex46-scriptexercise wickinot$ gem build hello.gemspec
  Successfully built RubyGem
  Name: hello
  Version: 1.0
  File: hello-1.0.gem
wickinot:ex46-scriptexercise wickinot$ gem install ./hello-1.0.gem
Successfully installed hello-1.0
Parsing documentation for hello-1.0
Installing ri documentation for hello-1.0
Done installing documentation for hello after 0 seconds
1 gem installed
wickinot:ex46-scriptexercise wickinot$ irb
2.5.1 :001 > require 'hello'
 => true 
2.5.1 :002 > Hello.hi
Hello, World!
 => nil 
2.5.1 :003 > 

References I found helpful for this exercise are: https://commandercoriander.net/blog/2013/02/16/making-a-ruby-script-executable/ https://guides.rubygems.org/make-your-own-gem/