249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/chef/environment.rb', line 249
def self.load_from_file(name)
unless File.directory?(Chef::Config[:environment_path])
raise Chef::Exceptions::InvalidEnvironmentPath, "Environment path '#{Chef::Config[:environment_path]}' is invalid"
end
js_file = File.join(Chef::Config[:environment_path], "#{name}.json")
rb_file = File.join(Chef::Config[:environment_path], "#{name}.rb")
if File.exist?(js_file)
hash = Chef::JSONCompat.parse(IO.read(js_file))
from_hash(hash)
elsif File.exist?(rb_file)
environment = Chef::Environment.new
environment.name(name)
environment.from_file(rb_file)
environment
else
raise Chef::Exceptions::EnvironmentNotFound, "Environment '#{name}' could not be loaded from disk"
end
end
|