0
0
Rubyprogramming

Gem versions and constraints in Ruby - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a gem version constraint in Ruby?
A gem version constraint tells RubyGems which versions of a gem are allowed to be installed. It helps control compatibility by specifying version ranges or exact versions.
Click to reveal answer
intermediate
What does the '~> 2.3' version constraint mean?
The '~> 2.3' constraint means any version >= 2.3.0 and < 3.0.0. It allows updates that do not change the leftmost digit before the dot.
Click to reveal answer
beginner
How do you specify an exact gem version in a Gemfile?
You specify an exact version by using the '=' operator, like gem 'rails', '= 6.1.4'. This installs only that exact version.
Click to reveal answer
beginner
What does the version constraint '>= 1.5' mean?
It means any version greater than or equal to 1.5 is allowed. This lets RubyGems install 1.5 or any newer version.
Click to reveal answer
beginner
Why use version constraints in your Gemfile?
Version constraints help keep your app stable by preventing incompatible gem updates. They ensure your app uses gem versions you have tested.
Click to reveal answer
What does the version constraint '~> 1.2.3' allow?
AOnly version 1.2.3
BVersions >= 1.2.3 and < 2.0.0
CVersions >= 1.2.3 and < 1.3.0
DVersions >= 1.2.0 and < 1.3.0
How do you specify a gem version exactly 2.0.1 in a Gemfile?
Agem 'gemname', '~> 2.0.1'
Bgem 'gemname', '< 2.0.1'
Cgem 'gemname', '>= 2.0.1'
Dgem 'gemname', '= 2.0.1'
What does '>= 3.0' mean in a gem version constraint?
AVersions 3.0 and higher
BVersions less than 3.0
COnly version 3.0
DVersions between 2.0 and 3.0
Which constraint allows any version less than 2.0?
A~> 2.0
B< 2.0
C> 2.0
D= 2.0
Why is it important to use version constraints in your Gemfile?
ATo prevent incompatible gem updates
BTo ignore gem dependencies
CTo make installation slower
DTo allow any gem version to install
Explain how the pessimistic version constraint '~>' works in Ruby gems.
Think about how '~>' limits updates to compatible versions.
You got /3 concepts.
    Describe why specifying exact or range versions for gems is important in a Ruby project.
    Consider what happens if a gem updates with breaking changes.
    You got /4 concepts.