lib/phonelib/core.rb in phonelib-0.6.8 vs lib/phonelib/core.rb in phonelib-0.6.9

- old
+ new

@@ -105,10 +105,20 @@ # @return [Boolean] Flag defines whether to do strict parsing check def strict_check=(strict) @@strict_check = strict end + @@override_phone_data = nil + # setter for data file to use + def override_phone_data=(file_path) + @@override_phone_data = file_path + end + + def override_phone_data + @@override_phone_data + end + # gem constants definition # @private Main data file FILE_MAIN_DATA = 'data/phone_data.dat' # @private Extended data file @@ -322,10 +332,15 @@ private # @private Load data file into memory def load_data data_file = "#{File.dirname(__FILE__)}/../../#{FILE_MAIN_DATA}" - Marshal.load(File.binread(data_file)) + default_data = Marshal.load(File.binread(data_file)) + if override_phone_data + override_data_file = Marshal.load(File.binread(override_phone_data)) + default_data.merge!(override_data_file) + end + default_data end # @private Load extended data file into memory def load_ext_data data_file = "#{File.dirname(__FILE__)}/../../#{FILE_EXT_DATA}"