class Harmoni::JSON
Public Class Methods
match?(file)
click to toggle source
# File lib/harmoni/types/json.rb, line 5 def self.match?(file) if File.exist?(file) begin ::JSON.parse(File.read(file)) true rescue => _e false end else file.file_name =~ /\.json$/i end end
Public Instance Methods
load_config()
click to toggle source
# File lib/harmoni/types/json.rb, line 22 def load_config if File.exist?(path) ::JSON.parse(File.read(path)) else {} end rescue => e BBLib.logger.warn("Failed to load file as json @ #{path}: #{e}") {} end
save()
click to toggle source
# File lib/harmoni/types/json.rb, line 18 def save configuration.to_json.to_file(path, mode: 'w') end