class PodPrebuild::JSONFile

Attributes

data[R]
path[R]

Public Class Methods

new(path) click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 8
def initialize(path)
  @path = path
  @data = load_json
end

Public Instance Methods

[](key) click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 17
def [](key)
  @data[key]
end
[]=(key, value) click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 21
def []=(key, value)
  @data[key] = value
end
empty?() click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 13
def empty?
  @data.empty?
end
save!() click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 25
def save!
  File.open(@path, "w") { |f| f.write(JSON.pretty_generate(@data)) }
end

Private Instance Methods

load_json() click to toggle source
# File lib/cocoapods-binary-cache/helper/json.rb, line 31
def load_json
  File.open(@path) { |f| JSON.parse(f.read) }
rescue
  {}
end