Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Where do i put my rubygems lib file?


Asked by Darren Farmer on Dec 11, 2021 FAQ



Once you’ve required ap, RubyGems automatically places its lib directory on the $LOAD_PATH. That’s basically it for what’s in a gem. Drop Ruby code into lib, name a Ruby file the same as your gem (for the gem “freewill” the file should be freewill.rb, see also name your gem) and it’s loadable by RubyGems.
Next,
Drop Ruby code into lib, name a Ruby file the same as your gem (for the gem “freewill” the file should be freewill.rb, see also name your gem) and it’s loadable by RubyGems. The lib directory itself normally contains only one.rb file and a directory with the same name as the gem which contains the rest of the files.
Consequently, At the bare minimum, a gem includes a Ruby file and a gemspec. The gemspec (gem specification) describes the gem and is used by the RubyGems package manager to install the gem. The RubyGems package manager can download and install gems to your system and allows you to use the gems in other Ruby programs.
Similarly,
As mentioned before, the gem’s root file is in charge of loading code for the gem. The other files for a gem are usually placed in a directory of the same name of the gem inside of lib. We can split this gem out like so: The Translator is now in lib/hola, which can easily be picked up with a require statement from lib/hola.rb.
Besides,
RubyGems modifies your Ruby load path, which controls how your Ruby code is found by the require statement. When you require a gem, really you’re just placing that gem’s lib directory onto your $LOAD_PATH. Let’s try this out in irb and get some help from the pretty_print library included with Ruby.