lib/olaf/settings.rb
# Query latest settings from file for a :from_file field,
# if they are out of date.
#
# @param name [String] The filename as a string
#
Query latest settings from file for a :from_file field,
if they are out of date.
Query latest settings from file for a : from_file field if they are out of date .
def sync(name)
      name = name.to_s
      filename = @fields[name][:from_file]
      mtime = File.mtime filename
      if !@sync[name] || mtime != @sync[name]
        ext = filename.split(".")[-1]
        raise "Not a JSON or YAML file: #{filename}!" unless EXTENSIONS[ext]
        @values[name] = indifferent_freeze EXTENSIONS[ext].call(File.read filename)
        @sync[name] = mtime
      end
    end
def sync ( name ) name = name . to_s filename = @fields [ name ] [ :from_file ] mtime = File . mtime filename if ! @sync [ name ] || mtime != @sync [ name ] ext = filename . split ( "." ) [ - 1 ] raise "Not a JSON or YAML file: #{filename}!" unless EXTENSIONS [ ext ] @values [ name ] = indifferent_freeze EXTENSIONS [ ext ] . call ( File . read filename ) @sync [ name ] = mtime end end
Query latest settings from file for a :from_file field,
if they are out of date.
Query latest settings from file for a : from_file field if they are out of date .
name
The filename as a string
The filename as a string