From: "Mauricio Fernández" Date: 2002-12-30T21:35:23+09:00 Subject: FreeRIDE 0.5.0rc1: patch to allow per-user properties This is quite a hack, but it is transparent to the system and fixes the issues I experienced. Comments? ==== --- freeride-0.5.0rc1.orig/freebase/readers.rb +++ freeride-0.5.0rc1/freebase/readers.rb @@ -23,9 +23,29 @@ def self.load_libraries require 'yaml' end - + + def self.local_name(name) + filespec = $1 if name =~ %r{(config/.*)} + filespec = $1 if name =~ %r{(plugins/.*)} + "#{ENV['HOME']}/.freeride/#{filespec}" + end + + class << self + private :local_name + end + def self.save(base_slot, filespec, name, version) - file = File.new(filespec, "w+") + begin + file = File.new(filespec, "w+") + rescue Errno::EACCES + filespec = local_name(filespec) + dir = "/" + File.dirname(filespec[1..-1]).split("/").each do |d| + dir += "#{d}/" + Dir.mkdir(dir) rescue nil + end + file = File.new(filespec, "w+") + end file.puts "#### Properties: #{name} - Version: #{version}" file.puts gather_data(base_slot).to_yaml(:SortKeys=>true) file.close @@ -45,6 +65,12 @@ end def self.load(base_slot, filespec) + filespec2 = local_name(filespec) + if File.exist?(filespec2) + data = nil + File.open(filespec2) {|file| file.binmode; data = file.read} + read_slot(base_slot, YAML.load(data)) + end return unless File.exist?(filespec) data = nil File.open(filespec) {|file| file.binmode; data = file.read} ====== -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com * JHM wonders what Joey did to earn "I'd just like to say, for the record, that Joey rules." -- Seen on #Debian