lib/fulmar/domain/model/configuration.rb in fulmar-2.2.0 vs lib/fulmar/domain/model/configuration.rb in fulmar-2.2.1
- old
+ new
@@ -1,6 +1,7 @@
require 'yaml'
+require 'pathname'
require 'fulmar/domain/model/project'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/hash/deep_merge'
require 'active_support/hash_with_indifferent_access'
@@ -144,11 +145,11 @@
end
# Prepends the base to the path if it is not already absolute
def absolutize(path, base = @base_path)
return base if path == '.'
- path[0, 1] == '/' ? path : base + '/' + path
+ (Pathname.new path).absolute? ? path : base + '/' + path
end
# Checks if a key is a local path
def local_path?(key)
key.to_s.split('_').last == 'path' && !key.to_s.include?('remote')
@@ -156,10 +157,10 @@
# Check all keys ending with '_path' and prepend either the
# @base_path or the local_path from the environment
def absolutize_paths
each do |_env, _target, data|
- data.keys.each do |key|
+ data.each_key do |key|
data[:local_path] = absolutize(data[:local_path]) if data[:local_path]
if local_path?(key) && data[key].class == String
data[key] = absolutize(data[key], data[:local_path] || @base_path)
end
end