lib/rconfig/load_paths.rb in rconfig-0.4.2 vs lib/rconfig/load_paths.rb in rconfig-0.4.3
- old
+ new
@@ -19,28 +19,28 @@
# configuration files.
# It only allows one path to be entered at a time.
def add_load_path(path)
if path = parse_load_paths(path).first # only accept first one.
self.load_paths << path
+ self.load_paths.uniq!
return reload(true) # Load Paths have changed so force a reload
end
false
end
##
# If the paths are made up of a delimited string, then parse out the
# individual paths. Verify that each path is valid.
def parse_load_paths(paths)
- return [] unless paths
if paths.is_a? String
path_sep = (paths =~ /;/) ? ';' : ':'
paths = paths.split(/#{path_sep}+/)
end
raise ArgumentError, "Path(s) must be a String or an Array [#{paths.inspect}]" unless paths.is_a? Array
raise ArgumentError, "Must provide at least one load path: [#{paths.inspect}]" if paths.empty?
paths.each do |dir|
dir = CONFIG_ROOT if dir == 'CONFIG_ROOT'
- raise RConfig::InvalidConfigPathError, "This directory is invalid: [#{dir.inspect}]" unless Dir.exists?(dir)
+ raise InvalidLoadPathError, "This directory is invalid: [#{dir.inspect}]" unless Dir.exists?(dir)
end
paths
end
##