Method: PortalModule.save_configuration

Defined in:
lib/portal_module.rb

.save_configuration(path = nil) ⇒ Object

Write configuration to disk

Writes to current working dir (pwd) if path is nil

Returns path of emitted file



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/portal_module.rb', line 72

def self.save_configuration(path = nil)
  # If no path provided, see if we can find one in the dir tree.
  if path.nil?
    path = find_config_path
  end

  # Still no path? Use the current working dir.
  if path.nil?
    path = Pathname.pwd
  end

  unless path.to_s.end_with?('/' + CONFIG_FILE_NAME)
    path = Pathname(path) + CONFIG_FILE_NAME
  end

  path = Pathname(path).expand_path
  File.write(path, YAML.dump(configuration))

  path
end