| Start |
|---|
| Installing ruby gems This guide assumes you already have Ruby installed.
If you're using Ruby < To install a ruby gem, enter the command: If you are working on a project with a list of gem dependencies, then these will be listed in a file named This Save the file, and then run the command: Specifying versionsThe version number can be specified on the command live, with the When specifying version numbers in a
As a best practice: You might want to use one of the Ruby version management libraries like rbenv (opens new window) or rvm (opens new window). Through these libraries, you can install different versions of Ruby runtimes and gems accordingly. So, when working in a project, this will be especially handy because most of the projects are coded against a known Ruby version. |
| Gem installation from github/filesystem You can install a gem from github or filesystem. If the gem has been checked out from git or somehow already on the file system, you could install it using Installing gem from github. Download the sources from github Build the gem |
| Checking if a required gem is installed from within code To check if a required gem is installed, from within your code, you can use the following (using nokogiri as an example): However, this can be further extended to a function that can be used in setting up functionality within your code. Now you can check if the required gem is installed, and print an error message. or |
| Using a Gemfile and Bundler A You can specify the versions of the gem you want as follows: You can also pull gems straight from a git repo: You can also group gems depending on what they are used for. For example: You can specify which platform certain gems should run on if you application needs to be able to run on multiple platforms. For example: To install all the gems from a Gemfile do: |
| Bundler/inline (bundler v1.10 and later) Sometimes you need to make a script for someone but you are not sure what he has on his machine. Is there everything that your script needs? Not to worry. Bundler has a great function called in line. It provides a |
Read Article
https://develop.horje.com/learn/1434/reference