lib/alexandria/preferences.rb in alexandria-book-collection-manager-0.7.4 vs lib/alexandria/preferences.rb in alexandria-book-collection-manager-0.7.5

- old
+ new

@@ -46,11 +46,14 @@ end def save! log.debug { "preferences save!" } @changed_settings.each do |variable_name| - log.debug { "saving preference #{variable_name} / #{@alexandria_settings[variable_name].class}" } + log.debug do + klass = @alexandria_settings[variable_name].class + "saving preference #{variable_name} / #{klass}" + end generic_save_setting(variable_name, @alexandria_settings[variable_name]) end @changed_settings.clear end @@ -123,11 +126,13 @@ # set non-list value exec_gconf_set(var_path, new_value) end rescue StandardError => ex log.debug { new_value.inspect } - log.error { "Could not set GConf setting #{variable_name} to value: #{new_value.inspect}" } + log.error do + "Could not set GConf setting #{variable_name} to value: #{new_value.inspect}" + end log << ex.message log << ex end ## @@ -175,11 +180,11 @@ # new_value = {} end type = get_gconf_type(new_value) value_str = new_value if new_value.is_a? String - new_value.gsub!(/\"/, '\\"') + new_value = new_value.gsub(/\"/, '\\"') value_str = "\"#{new_value}\"" end puts value_str if /cols_width/.match?(var_path) `gconftool-2 --type #{type} --set #{var_path} #{value_str}` end @@ -224,11 +229,13 @@ # #discriminate method) and returns them in a Hash. def gconftool_values_to_hash(all_vals) hash = {} vals = all_vals.split(/$/) vals.each do |val| - hash[Regexp.last_match[1]] = discriminate(Regexp.last_match[2]) if /([a-z_]+) = (.*)/ =~ val + if /([a-z_]+) = (.*)/ =~ val + hash[Regexp.last_match[1]] = discriminate(Regexp.last_match[2]) + end end hash end # Make a judgement about the type of the settings we get back from @@ -244,12 +251,12 @@ elsif value =~ /^\[(.*)\]$/ # list (assume of type String) Regexp.last_match[1].split(",") elsif value =~ /^\((.*)\)$/ # pair (assume of type int) begin pair = Regexp.last_match[1].split(",") - return [discriminate(pair.first), discriminate(pair.last)] + [discriminate(pair.first), discriminate(pair.last)] rescue StandardError - return [0, 0] + [0, 0] end else value # string end end