GEMS Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How to show the gem directory located?

A

bundle info gem_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to open the gem directory?

A

bundle open gem_name

# or 
atom $(bundle show name_of_gem)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to return the gem to the initial state?

A

gem pristine gem_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How does ‘require’ work?

A

The key is in the $LOAD_PATH global variable. This variable holds a list of paths that will be searched for files to load.

When you use require, one of two things can happen:
If the required file is found, it’s loaded & added to the $LOADED_FEATURES array.
If the file is not found in one of these paths (in $LOAD_PATH ) then an exception is raised.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the differences between require and require relative?

A

require_relative lets you require files relative to the current directory without having to change the $LOAD_PATH .
Note that require_relative starts from the directory where the file is located and not from your current directory, this is a key difference in require vs require_relative .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the differences between require and load?

A

The load method is only really useful on irb/pry to reload some file you are working on.

The difference with require is that load will not check $LOADED_FEATURES to see if a file has already been loaded. What this means is that if you call load 10 times for the same file, that file will be loaded 10 times. With require it will only be loaded once.

  • Another difference:
    With load you need to provide the file extension, but require will append .rb as the
    extension.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly