Creating ruby ​​stones meets terminal commands

I am extremely new to ruby, as well as creating gems. I made a simple stone that webscrapes some information depending on the input. However, to use my gem, I need to go to the interpreter (irb) and request my gem, and then call the method with some parameters.

Suppose a gem is called foo. Suppose the method is called print_website(x) # where x is a string.

I want to be able to do something like:

$ foo test.com

and it should automatically call the method and execute it.

Thanks in advance! Please ask me if I do not understand !: D

+5
source share
2 answers

Try

$ mkdir bin
$ touch bin/foo
$ chmod a+x bin/foo

bin/foo

#!/usr/bin/env ruby

require 'foo'
#Anything you want.......

Gemfile

 s.executables << 'foo'

gem.

+5

, bundle gem mygem -b .

0

All Articles