I am extremely new to ruby as well as gem making. I made a simple gem that webscrapes some information depending on the input. However, to use my gem I need to go into the interpreter (irb) and require my gem and then call the method with some parameters.
Suppose the 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 for clarification if i was unclear! :D
Press Ctrl+Space to show the available gem executables. In this field, type the command line arguments of the script. Specify the working directory used by the running task. For example, this option is in effect when the running script loads other scripts by relative paths.
The interface for RubyGems is a command-line tool called gem which can install and manage libraries (the gems). RubyGems integrates with Ruby run-time loader to help find and load installed gems from standardized library folders.
Note that you need an account at RubyGems.org to do this. From the main menu, select Tools | Gem | Push Gem. In the Run tool window, specify your RubyGems credentials. Your gem will be published to RubyGems.org.
Gems can be used to extend or modify functionality in Ruby applications. Commonly they're used to distribute reusable functionality that is shared with other Rubyists for use in their applications and libraries. Some gems provide command line utilities to help automate tasks and speed up your work.
Try it
$ mkdir bin
$ touch bin/foo
$ chmod a+x bin/foo
Edit bin/foo
#!/usr/bin/env ruby
require 'foo'
#Anything you want.......
Add following to Gemfile
s.executables << 'foo'
Push gem. Now you published command line utility
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With