My first Ruby CLI gem! travel_inspiration

Lonely Planet’s Travel Inspirations

I decided to name my Ruby CLI Gem: travel_inspiration

Walkthrough of my code

My Ruby Gem provides:

How do I create a Ruby Gem?

bundle gem travel_inspiration
- bin
- lib
.gitignore
travel-inspiration.gemspec
Gemfile
License.txt
Rakefile
README.md
/bin directory

/lib directory

module TravelInspiration
VERSION = “0.1.3”
end
#OpenURI is a wrapper for Net::HTTP, Net::HTTPS and Net::FTP
#Nokogiri parses and searches XML/HTML
require ‘open-uri’
require ‘nokogiri’
#all other file dependenciesrequire “travel_inspiration/version”
require “travel_inspiration/themes”
require “travel_inspiration/cli”

Other pre-populated files

source “https://rubygems.org"# Specify your gem’s dependencies in travel_inspiration.gemspec
gemspec
travel_inspiration.gemspec

Time to create my Ruby CLI gem

Themes.rb

themes.rb

Destinations.rb

destinations.rb

Country.rb

country.rb

CLI.rb

cli.rb

How to publish a gem on RubyGems.org

gem push travel-inspiration-0.1.0.gem

bin/inspire_me

inspire_me
#!/usr/bin/env rubyrequire “bundler/setup”
require “travel_inspiration”
TravelInspiration::CLI.new.start
spec.bindir = “bin”
spec.executables = [“inspire_me”]
spec.require_paths = [“lib”]

Travel_inspiration Ruby Gem!

gem install travel_inspiration

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Lisa Huang

Lisa Huang

570 Followers

Product Lead at Planet | 2x Founder, dabbling in TypeScript | My @TEDx talk: bit.ly/LisaHuangTEDx