Sha256: 5e3a24191c421ff1a04dbb6acb14e9177fa8e3ff03f5daf9b20730c585a044f5
Contents?: true
Size: 791 Bytes
Versions: 38
Compression:
Stored size: 791 Bytes
Contents
module DuckPuncher module JSONStorage require 'json' def self.dir_name Pathname.new('.duck_puncher') end def self.write(file_name, key, load_path) FileUtils.mkdir(dir_name) unless File.exists?(dir_name) data = read(file_name) key = key.to_sym data[key] ||= {} data[key][:require_with] ||= key.to_s.tr('-', '/') data[key][:load_paths] ||= [] data[key][:load_paths] << load_path.to_s unless data[key][:load_paths].include?(load_path.to_s) File.open(dir_name.join(file_name), 'wb') { |f| f << data.to_json } end def self.read(file_name) if File.exists?(dir_name.join file_name) JSON.parse File.read(dir_name.join file_name), symbolize_names: true else {} end end end end
Version data entries
38 entries across 38 versions & 1 rubygems