0
0
Rubyprogramming~10 mins

Creating a gem basics in Ruby - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
AMyModule
BGemfile
CGem
DMyGem
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase or incorrect module names.
Confusing the gem name with the Gemfile.
2fill in blank
medium

Complete 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'
A'my_gem'
B:MyGem
C:my_gem
D"MyGem"
Attempts:
3 left
💡 Hint
Common Mistakes
Using symbols instead of strings for the gem name.
Capitalizing the gem name incorrectly.
3fill in blank
hard

Fix 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'
A'jane.doe@example.com'
Bjane.doe@example.com
C:jane.doe@example.com
D['jane.doe@example.com']
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the email string.
Using symbols or arrays instead of a string.
4fill in blank
hard

Fill 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'
A"A simple Ruby gem"
BA simple Ruby gem
C"https://example.com/my_gem"
Dhttps://example.com/my_gem
Attempts:
3 left
💡 Hint
Common Mistakes
Not using quotes for string values.
Using bare words or URLs without quotes.
5fill in blank
hard

Fill 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'
AMyGem
B"0.1.0"
DMyGemModule
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatching module names.
Not quoting the version string.
Using wrong module name when printing.