mirror of
https://github.com/awesome-print/awesome_print
synced 2023-03-27 23:22:34 -04:00
Split out dotfile loading
This is so that we can stub the loading of the dotfile completely instead of just trying to stub via it's implimentation. This also makes it easier to only stub the dotfile loading instead of stubbing all file access which then causes problems with other things, such as Pry, which actually need to read from the filesystem.
This commit is contained in:
parent
fa6f4d3768
commit
8aef1bde91
1 changed files with 9 additions and 2 deletions
|
@ -137,11 +137,18 @@ module AwesomePrint
|
|||
@options.merge!(options)
|
||||
end
|
||||
|
||||
# This method needs to be mocked during testing so that it always loads
|
||||
# predictable values
|
||||
#---------------------------------------------------------------------------
|
||||
def load_dotfile
|
||||
dotfile = File.join(ENV['HOME'], '.aprc')
|
||||
load dotfile if File.readable?(dotfile)
|
||||
end
|
||||
|
||||
# Load ~/.aprc file with custom defaults that override default options.
|
||||
#---------------------------------------------------------------------------
|
||||
def merge_custom_defaults!
|
||||
dotfile = File.join(ENV['HOME'], '.aprc')
|
||||
load dotfile if File.readable?(dotfile)
|
||||
load_dotfile
|
||||
merge_options!(AwesomePrint.defaults) if AwesomePrint.defaults.is_a?(Hash)
|
||||
rescue => e
|
||||
$stderr.puts "Could not load #{dotfile}: #{e}"
|
||||
|
|
Loading…
Reference in a new issue