The `Pry.config.should_load_local_rc` flag was first added for pry#612. The
intended use case was to set it to `false` in your "global" RC file
(~/.pryrc, ~/.config/pry/pryrc, etc) to disable local RC files.
However, the refactoring in 78caffb
broke this functionality, because `Pry.rc_files_to_load` evaluates
`Pry.config.should_load_local_rc` before we ever load anything via
`Pry.load_rc_files`. The only way `should_load_local_rc` gets disabled
before this point is if we pass in the `-f` flag to Pry, which disables
*all* RC files.
The main point of `Pry.rc_files_to_load` is that it resolves the RC
paths and de-duplicates them, in case the global one symlinks to the
local one or vice versa. But it attempts to do this "ahead of time",
generating the list of files first before we ever load any of them, then
calling `Array#uniq`. This dedups the paths, but populating the array in
the first place means we check the `should_load_local_rc` boolean before
the global RC ever has a chance to set it.
This PR undoes some of that refactoring, bringing it closer to the old
code that had separate steps for `Pry.load_rc` and `Pry.load_local_rc`,
so we can check the config flag after the side effect of loading the
global RC file. However, it maintains the more general interface of
`Pry.load_rc_files`, in case other types of RC files are added in the
future. No matter the type of RC file, they all funnel through
`Pry.load_rc_file`, which now handles resolving paths and preventing
duplicates. It does this by maintaining `Pry.rc_files_loaded`, shifting
the logic from the more static "what will we load in the future?" to the
more dynamic "what have we loaded in the past?"
The `Pry.rc_files_to_load` method is removed by this PR, since it's not
necessarily an accurate reflection of the files that ultimately do get
loaded. Because it was public, this is technically a breaking change to
the API. However, note that the interface of `Pry.load_rc_files` remains
intact: true to the docstring, you can reload the RC files because we
take care to clear the `Pry.rc_files_loaded` array at the start.