### Bundle Install Output Source: https://guides.rubygems.org/bundler_workflow Example output showing the resolution and installation of dependencies. ```text $ bundle install Fetching gem metadata from https://rubygems.org/.......... Fetching version metadata from https://rubygems.org/.. Fetching dependency metadata from https://rubygems.org/. Resolving dependencies... Installing rake 11.3.0 Using concurrent-ruby 1.0.2 Using i18n 0.7.0 Installing minitest 5.9.1 Using thread_safe 0.3.5 Using builder 3.2.2 Using erubis 2.7.0 Using mini_portile2 2.1.0 Using rack 2.2.4 Using nio4r 1.2.1 Using websocket-extensions 0.1.2 Installing mime-types-data 3.2016.0521 Installing arel 7.1.4 Using bundler 1.13.1 Using method_source 0.8.2 Using thor 0.19.1 Using tzinfo 1.2.2 Installing nokogiri 1.6.8.1 with native extensions Using rack-test 0.6.3 Using sprockets 3.7.0 Installing websocket-driver 0.6.4 with native extensions Installing mime-types 3.1 Using activesupport 5.0.0.1 Using loofah 2.0.3 Using mail 2.6.4 Using rails-dom-testing 2.0.1 Using globalid 0.3.7 Using activemodel 5.0.0.1 Using rails-html-sanitizer 1.0.3 Using activejob 5.0.0.1 Using activerecord 5.0.0.1 Using actionview 5.0.0.1 Using actionpack 5.0.0.1 Using actioncable 5.0.0.1 Using actionmailer 5.0.0.1 Using railties 5.0.0.1 Installing sprockets-rails 3.2.0 Using rails 5.0.0.1 Bundle complete! 1 Gemfile dependency, 38 gems now installed. Use `bundle show [gemname]` to see where a bundled gem is installed. ``` -------------------------------- ### Setup and run Gem in a Box Source: https://guides.rubygems.org/run-your-own-gem-server Installation, directory setup, and server configuration for Gem in a Box. ```bash [~/dev/geminabox] gem install geminabox ``` ```bash [~/dev/geminabox] mkdir data ``` ```ruby require "rubygems" require "geminabox" Geminabox.data = "./data" run Geminabox::Server ``` ```bash [~/dev/geminabox] rackup [2011-05-19 12:09:40] INFO WEBrick 1.3.1 [2011-05-19 12:09:40] INFO ruby 1.9.2 (2011-02-18) [x86_64-darwin10.5.0] [2011-05-19 12:09:40] INFO WEBrick::HTTPServer#start: pid=60941 port=9292 ``` -------------------------------- ### Example .gemrc configuration file Source: https://guides.rubygems.org/command-reference A sample configuration file demonstrating how to set verbosity, install flags, and server settings. ```yaml :verbose: false install: --no-wrappers update: --no-wrappers :disable_default_gem_server: true ``` -------------------------------- ### Install signed gem from remote source Source: https://guides.rubygems.org/security Example of adding a remote public key and installing a gem with MediumSecurity verification. ```bash gem cert --add <(curl -Ls https://raw.github.com/metricfu/metric_fu/master/certs/bf4.pem) gem install metric_fu -P MediumSecurity ``` -------------------------------- ### Install and start Gemstash Source: https://guides.rubygems.org/run-your-own-gem-server Commands to install the gemstash gem and launch the server on the default port 9292. ```bash $ gem install gemstash ``` ```bash $ gemstash start ``` -------------------------------- ### Start gem server Source: https://guides.rubygems.org/command-reference Starts a web server to host RDoc documentation. Requires the rubygems-server gem. ```bash gem server [options] ``` -------------------------------- ### Dependency format examples Source: https://guides.rubygems.org/rubygems-org-compact-index-api Examples of gem dependencies with version constraints. ```text actionmailer:= 2.2.2 parser:>= 3.2.2.3 rainbow:< 4.0 unicode-display_width:< 3.0&>= 2.4.0 rack:~> 1.0 tilt:!= 1.3.0&~> 1.1 ``` -------------------------------- ### Install a gem from a custom source Source: https://guides.rubygems.org/run-your-own-gem-server Install gems from the configured source using the standard gem install command. ```bash [~] gem install secretgem Successfully installed secretgem-0.0.1 1 gem installed ``` -------------------------------- ### Install gems and dependencies Source: https://guides.rubygems.org/rubygems-basics The install command fetches the specified gem, resolves dependencies, builds native extensions, and generates documentation. ```bash $ gem install drip Fetching drip-0.1.1.gem Fetching rbtree-0.4.5.gem Building native extensions. This could take a while... Successfully installed rbtree-0.4.5 Successfully installed drip-0.1.1 Parsing documentation for rbtree-0.4.5 Installing ri documentation for rbtree-0.4.5 Parsing documentation for drip-0.1.1 Installing ri documentation for drip-0.1.1 Done installing documentation for rbtree, drip after 0 seconds 2 gems installed ``` -------------------------------- ### Run a specific gem version Source: https://guides.rubygems.org/command-reference Example of executing a specific version of a gem when multiple versions are installed. ```bash rake _0.7.3_ --version ``` -------------------------------- ### Install a gem Source: https://guides.rubygems.org/command-reference Basic syntax for installing one or more gems with optional build flags. ```bash gem install [options] GEMNAME [GEMNAME ...] -- --build-flags [options] ``` -------------------------------- ### Environment-Specific Gemfile Example Source: https://guides.rubygems.org/groups A complete Gemfile example demonstrating how to separate development and production dependencies. ```ruby source 'https://rubygems.org' gem 'rails', '3.2.2' gem 'rack-cache', require: 'rack/cache' gem 'nokogiri', '~> 1.4.2' group :development do gem 'sqlite3' end group :production do gem 'pg' end ``` -------------------------------- ### Build and install the gem Source: https://guides.rubygems.org/make-your-own-gem Commands to package the gem from the gemspec and install it locally for testing. ```bash $ gem build hola.gemspec Successfully built RubyGem Name: hola Version: 0.0.0 File: hola-0.0.0.gem $ gem install ./hola-0.0.0.gem Successfully installed hola-0.0.0 Parsing documentation for hola-0.0.0 Installing ri documentation for hola-0.0.0 Done installing documentation for hola after 0 seconds 1 gem installed ``` -------------------------------- ### Install Dependencies Source: https://guides.rubygems.org/bundler_workflow Install gems defined in the Gemfile. ```bash $ bundle install ``` -------------------------------- ### Install dependencies with Bundler Source: https://guides.rubygems.org/dependency_management Execute the install command to resolve and download dependencies based on the Gemfile. ```bash $ bundle install ``` -------------------------------- ### Install gems with custom build options Source: https://guides.rubygems.org/command-reference Use a double dash to pass specific library paths to an extension's build process when standard installation fails. ```bash $ gem install some_extension_gem [build fails] Gem files will remain installed in \ /path/to/gems/some_extension_gem-1.0 for inspection. Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out $ gem install some_extension_gem -- --with-extension-lib=/path/to/lib [build succeeds] $ gem list some_extension_gem *** LOCAL GEMS *** some_extension_gem (1.0) $ ``` -------------------------------- ### Install Rails Source: https://guides.rubygems.org/rails Install the Rails gem using the standard gem command. ```bash $ gem install rails ``` -------------------------------- ### Requirement format examples Source: https://guides.rubygems.org/rubygems-org-compact-index-api Examples of requirement chunks including checksums and environment constraints. ```text checksum:2c4af8d4a65ac5290445bfe7582be4490162d6934f49d76858b55647b4c4428d ruby:< 3.3.dev&>= 2.7 rubygems:>= 1.8.11 ``` -------------------------------- ### Install Gem via Alias Source: https://guides.rubygems.org/command-reference Use the 'i' alias as a shorthand for the 'install' command. ```bash $ gem i GEMNAME ``` -------------------------------- ### Install dependencies and track changes Source: https://guides.rubygems.org/getting_started Use bundle install to resolve dependencies and commit the resulting lockfile to version control. ```bash $ bundle install $ git add Gemfile Gemfile.lock ``` -------------------------------- ### Install Bundler Source: https://guides.rubygems.org/bundler_workflow Install the Bundler gem via terminal. ```bash $ gem install bundler ``` -------------------------------- ### Install Gemirro Source: https://guides.rubygems.org/run-your-own-gem-server Install the gemirro gem via the command line. ```bash $ gem install gemirro ``` -------------------------------- ### gem install Source: https://guides.rubygems.org/command-reference Installs a gem into the local repository. Supports various options for versioning, platform specification, and installation directory configuration. ```APIDOC ## gem install ### Description Installs a local or remote gem into a gem repository. For gems with executables, Ruby installs a wrapper file into the executable directory by default. ### Usage `gem install [options] GEMNAME [GEMNAME ...] -- --build-flags [options]` ### Arguments - **GEMNAME** - Name of the gem to install ### Options - **--platform PLATFORM** - Specify the platform of gem to install - **-v, --version VERSION** - Specify version of gem to install - **--[no-]prerelease** - Allow prerelease versions of a gem to be installed - **-i, --install-dir DIR** - Gem repository directory to get installed gems - **-n, --bindir DIR** - Directory where executables will be placed - **-l, --local** - Restrict operations to the LOCAL domain - **-r, --remote** - Restrict operations to the REMOTE domain - **-s, --source URL** - Append URL to list of remote gem sources ``` -------------------------------- ### Build and install the gem Source: https://guides.rubygems.org/make-your-own-gem Use these Rake tasks to build the gem package or install it locally to your system. ```bash $ rake build # Build the gem into the pkg directory $ rake install # Build and install the gem to your system ``` -------------------------------- ### Install rake-compiler Source: https://guides.rubygems.org/gems-with-extensions Command to install the rake-compiler gem. ```bash $ gem install rake-compiler ``` -------------------------------- ### Running a rails command via gem exec Source: https://guides.rubygems.org/command-reference Example of using gem exec to run a rails command without manual installation. ```bash gem exec rails new . ``` -------------------------------- ### Example Gemfile.lock content Source: https://guides.rubygems.org/using_bundler_in_applications The structure of a generated Gemfile.lock file showing remote sources, installed gem specifications, and platform details. ```text GEM remote: https://rubygems.org/ specs: mini_portile2 (2.1.0) nokogiri (1.6.8) mini_portile2 (~> 2.1.0) pkg-config (~> 1.1.7) pkg-config (1.1.7) PLATFORMS ruby DEPENDENCIES nokogiri (>= 1.4.0) BUNDLED WITH 1.12.5 ``` -------------------------------- ### Start the Rails Server Source: https://guides.rubygems.org/rails Launch the Rails server with Bundler managing dependencies automatically. ```bash $ rails server ``` -------------------------------- ### Install the Gems Ruby Library Source: https://guides.rubygems.org/rubygems-org-api Install the official Ruby client library to interact with RubyGems.org resources. ```bash gem install gems ``` -------------------------------- ### Verifying and installing a remote gem Source: https://guides.rubygems.org/make-your-own-gem Check for the existence of a gem on the remote server and install it locally. ```bash $ gem list -r hola *** REMOTE GEMS *** hola (0.1.3) $ gem install hola Fetching hola-0.1.3.gem Successfully installed hola-0.1.3 Parsing documentation for hola-0.1.3 Installing ri documentation for hola-0.1.3 Done installing documentation for hola after 0 seconds 1 gem installed ``` -------------------------------- ### Build and install signed gem Source: https://guides.rubygems.org/security Builds the gem and installs it using a specific security trust profile. ```bash gem build gemname.gemspec gem install gemname-version.gem -P HighSecurity # or -P MediumSecurity if your gem depends on unsigned gems ``` -------------------------------- ### List installed gem information Source: https://guides.rubygems.org/default-gems-and-bundled-gems Use this command to display details about a specific installed gem. ```bash $ gem info json ``` -------------------------------- ### Install and list prerelease gems Source: https://guides.rubygems.org/patterns Use the --pre flag with gem commands to interact with prerelease versions. ```bash % gem list factory_bot -r --pre *** REMOTE GEMS *** factory_bot (2.0.0.beta2, 2.0.0.beta1) factory_bot_rails (1.1.beta1) % gem install factory_bot --pre Successfully installed factory_bot-2.0.0.beta2 1 gem installed ``` -------------------------------- ### Implement a pre-install hook Source: https://guides.rubygems.org/plugins Uses the pre_install hook to interactively confirm gem installations against a whitelist. Returning false from the block aborts the installation. ```ruby % cat lib/rubygems_plugin.rb WHITELIST_PATH = "#{ENV['HOME']}/.gem/install_audit/whitelist" Gem.pre_install do |installer| gem_name = installer.spec.name whitelist = if File.exist? WHITELIST_PATH File.read(WHITELIST_PATH).split else [] end unless whitelist.include? gem_name print "`#{gem_name}' is not whitelisted, install? (y/n): " case choice = $stdin.gets.chomp when /\Ay/i when /\An/i then next false else fail "cannot understand `#{choice}'" end end end % echo rake > ~/.gem/install_audit/whitelist % RUBYOPT=-Ilib gem install hoe Fetching: rake-12.3.0.gem (100%) Successfully installed rake-12.3.0 Fetching: hoe-3.16.2.gem (100%) `hoe' is not whitelisted, install? (y/n): y Successfully installed hoe-3.16.2 2 gems installed % RUBYOPT=-Ilib gem install pry Fetching: coderay-1.1.2.gem (100%) `coderay' is not whitelisted, install? (y/n): n ERROR: Error installing pry: pre-install hook at /…/lib/rubygems_plugin.rb:3 failed for coderay-1.1.2 ``` -------------------------------- ### List installed gems Source: https://guides.rubygems.org/rubygems-basics Displays all locally installed gems, including default and bundled gems. ```bash $ gem list *** LOCAL GEMS *** abbrev (default: 0.1.0) awesome_print (1.9.2) base64 (default: 0.1.1) benchmark (default: 0.2.0) bigdecimal (default: 3.1.1) bundler (default: 2.3.7) cgi (default: 0.3.1) csv (default: 3.2.2) date (default: 3.2.2) debug (1.4.0) delegate (default: 0.2.0) did_you_mean (default: 1.6.1) digest (default: 3.1.0) drb (default: 2.1.0) drip (0.1.1) english (default: 0.7.1) [...] ``` -------------------------------- ### Install a gem from a git repository Source: https://guides.rubygems.org/publishing Use this syntax in a Gemfile to install a gem directly from a public git repository via Bundler. ```ruby gem "wicked_pdf", :git => "https://github.com/mileszs/wicked_pdf.git" ``` -------------------------------- ### Install Dependencies for Deployment Source: https://guides.rubygems.org/deploying Use the --deployment flag to install gems into the vendor/bundle directory, ensuring isolation from system-wide gems. ```bash $ bundle install --deployment ``` -------------------------------- ### Install gems with trust policies Source: https://guides.rubygems.org/security Use these commands to enforce security policies during gem installation. Note that certificates are trusted globally once added. ```bash gem install gemname -P HighSecurity ``` ```bash gem install gemname -P MediumSecurity ``` ```bash bundle --trust-policy MediumSecurity ``` -------------------------------- ### Example of an existing gem executable Source: https://guides.rubygems.org/make-your-own-gem Demonstrates the usage of the Nokogiri gem's command-line interface. ```bash $ gem install -N nokogiri [...] $ nokogiri https://www.ruby-lang.org/ Your document is stored in @doc... 3.1.2 :001 > @doc.title => "Ruby Programming Language" ``` -------------------------------- ### Install Gem from S3 via CLI Source: https://guides.rubygems.org/using-s3-source Install a specific gem version from an S3 bucket by providing credentials directly in the source URI. ```bash $ gem install rake -v 12.3.2 --source s3://:@bucket1 ``` -------------------------------- ### Install plugins via Gemfile Source: https://guides.rubygems.org/bundler_plugins Define plugins in your Gemfile to install them from RubyGems, a local path, or a Git repository. ```ruby plugin 'my_plugin' # Installs from Rubygems plugin 'my_plugin', path: '/path/to/plugin' # Installs from a path plugin 'my_plugin', git: 'https://github.com/repo/my_plugin.git' # Installs from Git ``` -------------------------------- ### View gem documentation Source: https://guides.rubygems.org/rubygems-basics Uses the ri tool to display documentation for an installed gem. ```bash $ ri RBTree = RBTree < MultiRBTree (from gem rbtree-0.4.5) ------------------------------------------------------------------------ A sorted associative collection that cannot contain duplicate keys. RBTree is a subclass of MultiRBTree. ------------------------------------------------------------------------ ``` -------------------------------- ### Define post-install message Source: https://guides.rubygems.org/specification-reference Specify a message to display to the user immediately after the gem installation completes. ```ruby spec.post_install_message = "Thanks for installing!" ``` -------------------------------- ### OTP authentication prompt Source: https://guides.rubygems.org/using-mfa-in-command-line Example of the CLI prompting for an OTP code during the signin process. ```bash $ gem signin Enter your RubyGems.org credentials. Don't have an account yet? Create one at https://rubygems.org/sign_up Email: gem_author@example Password: You have enabled multi-factor authentication. Please enter OTP code. Code: 111111 Signed in. ``` -------------------------------- ### Generate Gem Index Source: https://guides.rubygems.org/run-your-own-gem-server Create an index of all installed gem files. ```bash $ gemirro index ``` -------------------------------- ### Configure Gem Sources Source: https://guides.rubygems.org/using_bundler_in_applications Examples of defining gem sources, including block-based and per-gem source definitions. ```ruby source "https://your_ruby_gem_server.url" ``` ```ruby source "https://your_ruby_gem_server.url" do # gems end gem "my_gem", source: "https://your_2_ruby_gem_server.url" ``` -------------------------------- ### Create a RubyMotion project Source: https://guides.rubygems.org/rubymotion Initialize a new RubyMotion application and navigate into the project directory. ```bash $ motion create myapp $ cd myapp ``` -------------------------------- ### Display gem contents Source: https://guides.rubygems.org/command-reference Lists the files contained within an installed gem. ```bash gem contents GEMNAME [GEMNAME ...] [options] ``` -------------------------------- ### Install gem from git repository Source: https://guides.rubygems.org/git Use this when the git repository has a .gemspec file at its root. ```ruby gem 'rack', git: 'https://github.com/rack/rack' ``` -------------------------------- ### Get help for gem commands Source: https://guides.rubygems.org/command-reference Displays help information for a specific gem command. ```bash gem help ARGUMENT [options] ``` -------------------------------- ### Add Gems to Gemfile Source: https://guides.rubygems.org/using_bundler_in_applications Examples of adding gems with specific versions or version constraints. ```ruby # frozen_string_literal: true # A sample Gemfile source "https://rubygems.org" gem "rails" ``` ```ruby gem "rails", "3.0.0" ``` ```ruby gem "rails", "~> 4.0.0" # which is same as gem "rails", ">= 4.0.0", "< 4.1.0" gem "nokogiri", ">= 1.4.2" ``` -------------------------------- ### Example Gemfile.lock with Bundler 1.17.1 Source: https://guides.rubygems.org/bundler_2_upgrade A sample Gemfile.lock showing the BUNDLED WITH section indicating version 1.17.1. ```text GEM remote: https://rubygems.org/ specs: rack (2.2.4) PLATFORMS ruby DEPENDENCIES rack BUNDLED WITH 1.17.1 ``` -------------------------------- ### Generate RDoc for installed gems Source: https://guides.rubygems.org/command-reference Builds documentation for pre-installed gems using RDoc or RI. ```bash gem rdoc [args] [options] ``` -------------------------------- ### Install gem from subdirectory Source: https://guides.rubygems.org/git Use the :glob option to locate the .gemspec file within a subdirectory. ```ruby gem 'cf-copilot', git: 'https://github.com/cloudfoundry/copilot', glob: 'sdk/ruby/*.gemspec' ``` -------------------------------- ### Initialize Mirror Directory Source: https://guides.rubygems.org/run-your-own-gem-server Create a new, empty mirror directory at the specified path. ```bash $ gemirro init /srv/http/mirror.com/ ``` -------------------------------- ### GET /versions Source: https://guides.rubygems.org/rubygems-org-compact-index-api Retrieves a custom text-based index containing information about all versions of all rubygems. The file is append-only during the month and recalculated at the start of each month. ```APIDOC ## GET /versions ### Description Returns a custom text-based format containing information about all versions of all rubygems. This endpoint is intended to be a compact index of all possible rubygem versions. ### Method GET ### Endpoint /versions ### Response #### Success Response (200) - **body** (text/plain) - A text-based index file where each line represents a rubygem and its versions, followed by an MD5 checksum of its corresponding info file. ``` -------------------------------- ### Start Sinatra with bundle exec Source: https://guides.rubygems.org/sinatra Use rackup with bundle exec to ensure the application runs within the context of the defined dependencies. ```bash $ bundle exec rackup ``` -------------------------------- ### WebAuthn authentication flow Source: https://guides.rubygems.org/using-mfa-in-command-line Example output showing the WebAuthn verification prompt during the gem signin process. ```text Enter your RubyGems.org credentials. Don't have an account yet? Create one at https://rubygems.org/sign_up Email: gem_author@example Password: [snip of API key setup] You have enabled multi-factor authentication. Please visit http://localhost:3000/webauthn_verification/?port= to authenticate via security device. If you can't verify using WebAuthn but have OTP enabled, you can re-run the gem signin command with the `--otp [your_code]` option. ``` -------------------------------- ### Create a basic RubyGems plugin Source: https://guides.rubygems.org/plugins Demonstrates the required file naming convention and verification of plugin loading. ```bash % cat lib/rubygems_plugin.rb puts 'hello from my plugin!' % RUBYOPT=-Ilib gem hello from my plugin! RubyGems is a sophisticated package manager for Ruby. This is a basic help message containing pointers to more information. Usage: […] ``` -------------------------------- ### Optimize installation speed with full index Source: https://guides.rubygems.org/faqs Use the --full-index flag to download all gem information in a single request, which can improve performance on high-latency connections. ```bash $ bundle install --full-index ``` -------------------------------- ### Example gem directory structure Source: https://guides.rubygems.org/patterns A sample file structure showing potential conflicts with standard library names in the lib directory. ```text . └── lib ├── foo │ └── cgi.rb ├── erb.rb ├── foo.rb └── set.rb ``` -------------------------------- ### Creating the bin directory and executable file Source: https://guides.rubygems.org/make-your-own-gem Commands to set up the directory structure and permissions for a new gem executable. ```bash $ mkdir bin $ touch bin/hola $ chmod a+x bin/hola ``` -------------------------------- ### Initialize Bundler Source: https://guides.rubygems.org/bundler_workflow Create a new Gemfile in the current directory. ```bash $ bundle init ``` -------------------------------- ### Locate RubyGems installation path on macOS Source: https://guides.rubygems.org/rubygems_tls_ssl_troubleshooting_guide Use this command to find the installation path of RubyGems on a macOS system. ```shell $ gem which rubygems ``` -------------------------------- ### Compile the application Source: https://guides.rubygems.org/rubymotion Run the application compilation process using bundle exec to ensure the correct environment. ```bash $ bundle exec rake ``` -------------------------------- ### Locate RubyGems installation path on Windows Source: https://guides.rubygems.org/rubygems_tls_ssl_troubleshooting_guide Use this command to find the installation path of RubyGems on a Windows system. ```shell C:\>gem which rubygems ``` -------------------------------- ### Define the plugins.rb entry point Source: https://guides.rubygems.org/bundler_plugins The plugins.rb file serves as the entry point for Bundler to load your plugin. ```ruby require 'my_plugin' ``` -------------------------------- ### Configure Bundler to Exclude Groups Source: https://guides.rubygems.org/groups Use bundle config to prevent specific groups from being installed during bundle install. ```bash $ bundle config set --local without test development ``` ```bash $ bundle config set --local without production ``` -------------------------------- ### Install gem without requiring Source: https://guides.rubygems.org/gemfile Prevents Bundler from automatically requiring the gem while still managing its installation and dependencies. ```ruby gem 'rspec', :require => false gem 'sqlite3' ``` -------------------------------- ### Running the local executable Source: https://guides.rubygems.org/make-your-own-gem Commands to execute the local script using the -Ilib flag to include the library path. ```bash $ ruby -Ilib ./bin/hola hello world $ ruby -Ilib ./bin/hola spanish hola mundo ``` -------------------------------- ### Verify gem installation in IRB Source: https://guides.rubygems.org/make-your-own-gem Tests the installed gem by requiring it and calling its methods within an interactive Ruby session. ```ruby $ irb 3.1.2 :001 > require "hola" => true 3.1.2 :002 > Hola.hi Hello world! => nil ``` -------------------------------- ### Initialize Bundler in an application Source: https://guides.rubygems.org/bundler_setup Place this at the top of your application's entry file to discover the Gemfile and set up the load path. ```ruby require 'bundler/setup' ``` -------------------------------- ### Generate and Navigate to a Rails App Source: https://guides.rubygems.org/rails Create a new Rails application and enter the project directory. ```bash $ rails new myapp $ cd myapp ``` -------------------------------- ### Open command description Source: https://guides.rubygems.org/command-reference Provides details on how the open command handles editor selection and directory navigation. ```text The open command opens gem in editor and changes current path to gem's source directory. Editor command can be specified with -e option, otherwise rubygems will look for editor in $EDITOR, $VISUAL and $GEM_EDITOR variables. ``` -------------------------------- ### Build and Test C Extension Source: https://guides.rubygems.org/gems-with-extensions Commands to compile the extension and verify functionality via the command line. ```bash $ cd ext/my_malloc $ ruby extconf.rb checking for malloc()... yes checking for free()... yes creating Makefile $ make compiling my_malloc.c linking shared-object my_malloc.bundle $ cd ../.. $ ruby -Ilib:ext -r my_malloc -e "p MyMalloc.new(5).free" # ``` -------------------------------- ### Authenticating with RubyGems Source: https://guides.rubygems.org/make-your-own-gem Run the sign-in command to configure your local environment with RubyGems.org credentials. ```bash $ gem signin Enter your RubyGems.org credentials. Don't have an account yet? Create one at https://rubygems.org/sign_up Email: (your-email-address@example.com) Password: (your password for RubyGems.org) API Key name [host-user-20220102030405]: Please select scopes you want to enable for the API key (y/n) index_rubygems [y/N]: n push_rubygem [y/N]: y yank_rubygem [y/N]: n add_owner [y/N]: n remove_owner [y/N]: n access_webhooks [y/N]: n show_dashboard [y/N]: n You have enabled multi-factor authentication. Please enter OTP code. Code: 123456 Signed in with API key: host-user-20220102030405. ``` -------------------------------- ### Install Ruby via RVM without binaries Source: https://guides.rubygems.org/rubygems_tls_ssl_troubleshooting_guide Installs a specific version of Ruby using RVM while disabling precompiled binaries to resolve SSL issues. ```shell $ rvm install 2.2.3 --disable-binary ``` -------------------------------- ### Generate binstubs for shortcuts Source: https://guides.rubygems.org/getting_started Create project-specific executables in the bin directory to avoid needing bundle exec. ```bash $ bundle install --binstubs $ bin/rspec spec/models ``` -------------------------------- ### Unpack and run a modified installed gem Source: https://guides.rubygems.org/rubygems-basics Extract an already installed gem, modify its source files, and execute it by adding the local path to the Ruby load path. ```bash $ gem unpack rake Unpacked gem: '.../13.0.6' $ vim 13.0.6/lib/rake/... $ ruby -I 13.0.6/lib -S rake some_rake_task [...] ``` -------------------------------- ### GET /api/v1/gems.(json|yaml) Source: https://guides.rubygems.org/rubygems-org-api List all gems that you own. ```APIDOC ## GET /api/v1/gems.(json|yaml) ### Description List all gems that you own. Returns an array of the JSON or YAML representation of gems you own. ### Method GET ### Endpoint /api/v1/gems.(json|yaml) ``` -------------------------------- ### GET /api/v1/activity/just_updated Source: https://guides.rubygems.org/rubygems-org-api Pulls the 50 most recently updated gems. ```APIDOC ## GET /api/v1/activity/just_updated ### Description Pulls the 50 most recently updated gems. Returns an array of the JSON or YAML representation of the gem versions. ### Method GET ### Endpoint /api/v1/activity/just_updated ``` -------------------------------- ### GET /api/v1/downloads.(json|yaml) Source: https://guides.rubygems.org/rubygems-org-api Returns the total number of downloads on RubyGems. ```APIDOC ## GET /api/v1/downloads.(json|yaml) ### Description Returns an object containing the total number of downloads on RubyGems. ### Method GET ### Endpoint /api/v1/downloads.(json|yaml) ### Response #### Success Response (200) - **total** (integer) - The total number of downloads on RubyGems. #### Response Example { "total": 461672727 } ``` -------------------------------- ### Load the bundled environment Source: https://guides.rubygems.org/getting_started Require bundler/setup to ensure the application uses the exact gem versions specified in the bundle. ```ruby require 'bundler/setup' # require your gems as usual require 'nokogiri' ``` -------------------------------- ### GET /api/v1/search.(json|yaml) Source: https://guides.rubygems.org/rubygems-org-api Submit a search to RubyGems.org for active gems. ```APIDOC ## GET /api/v1/search.(json|yaml) ### Description Submit a search to RubyGems.org for active gems, just like a search query on the site. Returns an array of the JSON or YAML representation of gems that match. ### Method GET ### Endpoint /api/v1/search.(json|yaml) ### Parameters #### Query Parameters - **query** (string) - Required - The search term. - **page** (integer) - Optional - The page number for paginated results. ``` -------------------------------- ### Equivalent manual requirements for Bundler.require Source: https://guides.rubygems.org/bundler_setup This demonstrates what Bundler.require(:default) expands to for a specific Gemfile. ```ruby require 'rails' require 'rack-cache' require 'nokogiri' ``` -------------------------------- ### add_development_dependency(gem, *requirements) Source: https://guides.rubygems.org/specification-reference Adds a development dependency to the gem, which is not installed by default. ```APIDOC ## add_development_dependency(gem, *requirements) ### Description Adds a development dependency named `gem` with `requirements` to this gem. Development dependencies aren’t installed by default and aren’t activated when a gem is required. ### Usage ```ruby spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4' ``` ``` -------------------------------- ### Add development dependency to gemspec Source: https://guides.rubygems.org/specification-reference Adds a development dependency that is not installed by default. ```ruby spec.add_development_dependency 'example', '~> 1.1', '>= 1.1.4' ``` -------------------------------- ### Listing outdated gems Source: https://guides.rubygems.org/using_bundler_in_applications Check for installed gems that have newer versions available. ```bash $ bundle outdated Fetching gem metadata from https://rubygems.org/ Fetching version metadata from https://rubygems.org/ Fetching dependency metadata from https://rubygems.org/ Resolving dependencies....... Outdated gems included in the bundle: * nokogiri (newest 1.6.8, installed 1.6.7.2) in group "default" ``` -------------------------------- ### Enable git submodules Source: https://guides.rubygems.org/git Expand submodules within the git repository during installation. ```ruby gem 'rugged', git: 'git://github.com/libgit2/rugged.git', submodules: true ``` -------------------------------- ### Organize gems into groups Source: https://guides.rubygems.org/gemfile Categorizes gems into groups for conditional installation or loading. ```ruby gem 'wirble', :group => :development gem 'debugger', :group => [:development, :test] group :test do gem 'rspec' end ``` -------------------------------- ### GET /api/v1/api_key Source: https://guides.rubygems.org/rubygems-org-api Retrieve your API key using HTTP basic auth. ```APIDOC ## GET /api/v1/api_key ### Description Retrieve your API key using HTTP basic auth. ### Method GET ### Endpoint /api/v1/api_key.(json|yaml) ### Response #### Success Response (200) - **rubygems_api_key** (string) - The user's API key. ``` -------------------------------- ### Display gem cert usage Source: https://guides.rubygems.org/command-reference Shows the basic command syntax for gem cert. ```bash gem cert [options] ``` -------------------------------- ### Add a gem server source Source: https://guides.rubygems.org/run-your-own-gem-server Use the gem sources command to register your local gem server URL with the RubyGems system. ```bash gem sources --add http://localhost:9292 ``` -------------------------------- ### GET /api/v1/gems/[GEM NAME]/reverse_dependencies.json Source: https://guides.rubygems.org/rubygems-org-api List dependants of the specified gem. ```APIDOC ## GET /api/v1/gems/[GEM NAME]/reverse_dependencies.json ### Description List dependants of the specified gem. This is all the dependants whose latest version depend on the particular gem. Returns an array that includes names of the dependant gems. ### Method GET ### Endpoint /api/v1/gems/[GEM NAME]/reverse_dependencies.json ### Parameters #### Path Parameters - **GEM NAME** (string) - Required - The name of the gem to find dependants for. ``` -------------------------------- ### Compile and test a Ruby gem extension Source: https://guides.rubygems.org/gems-with-extensions Use these commands to install dependencies, compile the native extension, and verify functionality. ```bash $ bundle install $ bundle exec rake compile $ bundle exec ruby -Ilib -r my_gem -e "puts MyGem.hello('world')" Hello world, from Rust! ``` -------------------------------- ### List Installed Gems Source: https://guides.rubygems.org/command-reference Display local gems matching a specific regular expression. ```bash gem list [REGEXP ...] [options] ``` -------------------------------- ### Show gem information Source: https://guides.rubygems.org/command-reference Retrieves details such as name, description, and license for a specified gem. ```bash gem info GEMNAME [options] ``` -------------------------------- ### Implement Minitest Suite Source: https://guides.rubygems.org/make-your-own-gem A basic test file structure using the Minitest framework. ```ruby $ cat test/test_hola.rb require "minitest/autorun" require "hola" class HolaTest < Minitest::Test def test_english_hello assert_equal "hello world", Hola.hi("english") end def test_any_hello assert_equal "hello world", Hola.hi("ruby") end def test_spanish_hello assert_equal "hola mundo", Hola.hi("spanish") end end ``` -------------------------------- ### Fetch a gem Source: https://guides.rubygems.org/command-reference Downloads a specified gem to the current directory. ```bash gem fetch GEMNAME [GEMNAME ...] [options] ``` -------------------------------- ### GET /api/v1/activity/latest Source: https://guides.rubygems.org/rubygems-org-api Pulls the 50 gems most recently added to RubyGems.org for the first time. ```APIDOC ## GET /api/v1/activity/latest ### Description Pulls the 50 gems most recently added to RubyGems.org (for the first time). Returns an array of the JSON or YAML representation of the gems. ### Method GET ### Endpoint /api/v1/activity/latest ```