class PhraseAppUpdater::LocaleFile::JSONFile

Constants

EXTENSION
PHRASEAPP_TYPE

Public Class Methods

dump(hash) click to toggle source
# File lib/phraseapp_updater/locale_file/json_file.rb, line 23
def dump(hash)
  # Add indentation for better diffs
  json = Oj.dump(hash, indent: '  ', space:  ' ', object_nl: "\n", array_nl: "\n", mode: :strict)
  # Oj omits end of file newline unless using the integer form of :indent
  json << "\n"
  json
end
extension() click to toggle source
# File lib/phraseapp_updater/locale_file/json_file.rb, line 31
def extension
  EXTENSION
end
load(content) click to toggle source
# File lib/phraseapp_updater/locale_file/json_file.rb, line 17
def load(content)
  Oj.load(content)
rescue Oj::ParseError => e
  raise ArgumentError.new("Provided content was not valid JSON: #{e}")
end
phraseapp_type() click to toggle source
# File lib/phraseapp_updater/locale_file/json_file.rb, line 35
def phraseapp_type
  PHRASEAPP_TYPE
end