Sha256: 9d1217b8b3e45d948bf0aadc961b07f04c05f708e5e18ac8d7000abfd4cfea41

Contents?: true

Size: 491 Bytes

Versions: 2

Compression:

Stored size: 491 Bytes

Contents

require 'yaml'
require 'open-uri'

module IRKit
  module App

    DATA_FILE = ENV["IRKIT_DATA_FILE"] || File.expand_path('.irkit.json', ENV['HOME'])

    if File.exists?(DATA_FILE) || DATA_FILE =~ /\A#{URI::regexp(['http', 'https'])}\z/
      Data = Hashie::Mash.new JSON.parse(open(DATA_FILE).read)
    else
      Data = Hashie::Mash.new("IR" => {}, "Device" => {})
    end

    def Data.save
      File.open DATA_FILE, "w+" do |f|
        f.write self.to_json
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
irkit-0.1.0 lib/irkit/app/data.rb
irkit-0.0.9 lib/irkit/app/data.rb