Sha256: be9eed9e635cf63318d95d1c856cec33f6c09d280dcf53c02b089dc63b4c3099

Contents?: true

Size: 532 Bytes

Versions: 35

Compression:

Stored size: 532 Bytes

Contents

require "json"

module PodPrebuild
  class JSONFile
    attr_reader :path
    attr_reader :data

    def initialize(path)
      @path = path
      @data = load_json
    end

    def empty?
      @data.empty?
    end

    def [](key)
      @data[key]
    end

    def []=(key, value)
      @data[key] = value
    end

    def save!
      File.open(@path, "w") { |f| f.write(JSON.pretty_generate(@data)) }
    end

    private

    def load_json
      File.open(@path) { |f| JSON.parse(f.read) }
    rescue
      {}
    end
  end
end

Version data entries

35 entries across 35 versions & 4 rubygems

Version Path
cocoapods-binary-artifactory-cache-0.0.2 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.1 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-cache-0.1.14 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.13 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.12 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.11 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.10 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.9 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.8 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.7 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.6 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.5 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.3 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.2 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-0.1.1 lib/cocoapods-binary-cache/helper/json.rb