Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a new Ruby gem module named MyGem.
Ruby
module [1] # gem code goes here end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect module names.
Confusing the gem name with the Gemfile.
✗ Incorrect
The module name for a gem should be a unique name, usually capitalized. Here,
MyGem is the correct module name.2fill in blank
mediumComplete the code to create a gemspec file with the gem name my_gem.
Ruby
Gem::Specification.new do |spec| spec.name = [1] spec.version = '0.1.0' end
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using symbols instead of strings for the gem name.
Capitalizing the gem name incorrectly.
✗ Incorrect
The gemspec
name should be a string representing the gem's name, here 'my_gem'.3fill in blank
hardFix the error in the gemspec code to correctly set the author email.
Ruby
spec.authors = ['Jane Doe'] spec.email = [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the email string.
Using symbols or arrays instead of a string.
✗ Incorrect
The
email field must be a string with quotes, not a bare word or symbol.4fill in blank
hardFill both blanks to create a gemspec that sets the summary and homepage URL.
Ruby
spec.summary = [1] spec.homepage = [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for string values.
Using bare words or URLs without quotes.
✗ Incorrect
Both
summary and homepage must be strings enclosed in quotes.5fill in blank
hardFill all three blanks to define a gem module with a version constant.
Ruby
module [1] VERSION = [2] end puts [3]::VERSION
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching module names.
Not quoting the version string.
Using wrong module name when printing.
✗ Incorrect
The module name is
MyGem, the version is a string "0.1.0", and to print the version we use MyGem::VERSION.