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-cache-next-0.1.16 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-cache-next-0.1.15 lib/cocoapods-binary-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.19 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.18 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.17 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.16 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.15 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.14 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.13 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.12 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.11 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.10 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.9 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-ht-1.0.0 lib/cocoapods-binary-ht/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.8 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.7 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.6 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.5 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.4 lib/cocoapods-binary-artifactory-cache/helper/json.rb
cocoapods-binary-artifactory-cache-0.0.3 lib/cocoapods-binary-artifactory-cache/helper/json.rb