lib/exlibris/aleph/tab_helper.rb in exlibris-aleph-0.1.1 vs lib/exlibris/aleph/tab_helper.rb in exlibris-aleph-0.1.2

- old
+ new

@@ -30,10 +30,19 @@ @@tabs = @@alephe_tabs.keys + @@adm_tabs.keys @@adms = [] @@tab_path = nil @@yml_path = nil @@log_path = nil + @@irrelevant_sub_libraries = ["USR00", "HOME", "BOX", "ILLDT", "NYU51", "ALEPH", "USM50", + "MED", "HYL", "HIL", "LAM", "LAW", "LIT", "MUS", "WID", "EXL", "CIRC", "HILR", "HIL01", + "HYL01", "HYL02", "HYL03", "HYL04", "HYL05", "HYL06", "LAM01", "LAM02", "LAM03", "LAW01", + "LAW02", "LAW03", "LIT01", "LIT02", "MED01", "MED02", "MUS01", "MUS02", "WID01", "WID02", + "WID03", "WID04", "WID05", "U60WD", "U60HL", "U60LA", "U70WD", "CBAB", "BCU", "MBAZU", "USM51", + "ELEC5", "GDOC5", "EDUC5", "LINC5", "RRLIN", "OU511", "OR512", "OR513", "OR514", "OR515", "U61ED", + "U61EL", "U61LN", "S61GD", "USM53", "ELEC7", "GDOC7", "EDUC7", "LINC7", "USM54", "ELEC4", "USM55", + "CUN50", "CLEC5", "CDOC5", "CDUC5", "CINC5", "UNI50", "NARCV", "NELEC", "NRLEC", "NGDOC", "NRDOC", + "NEDUC", "NHLTH", "NLINC", "NLAW", "NMUSI", "NSCI", "NUPTN"] # Initialize TabHelper based on path to tabs, path to store yml configs, # path for log file, and the ADMs for the Aleph implementation # Exlibris::Aleph::TabHelper.init("/mnt/aleph_tab", ["ADM50", "ADM51"]) def self.init(tab_path, adms, refresh_time = ->{1.day.ago}) @@ -52,10 +61,16 @@ self.class.class_variable_get "#{class_variable}" end end end + # Sets class variable of irrelevant sub libraries to be ignored when building sub_libraries YAML + def self.set_irrelevant_sub_libraries(irrelevant_sub_libraries, replace = true) + @@irrelevant_sub_libraries |= irrelevant_sub_libraries if replace + @@irrelevant_sub_libraries = irrelevant_sub_libraries unless replace + end + # Refreshes the yml files that are used to parse the tables. def self.refresh_yml @@alephe_tabs.each do |key, klass| tab = Exlibris::Aleph::Config.const_get(klass).new(:aleph_library => "ALEPHE", :aleph_mnt_path => @@tab_path).to_h File.open( File.join(@@yml_path, "alephe", "#{key}.yml"), 'w' ) { |out| YAML.dump( tab, out ) } unless tab.empty? @@ -267,9 +282,11 @@ tab = instance_variable_get("@#{key}".to_sym) tab[adm] = YAML.load_file(File.join(@@yml_path, adm, "#{key}.yml")) instance_variable_set("@#{key}".to_sym, tab) end end + # Delete irrelevant sub libraries from @sub_library + @sub_libraries.delete_if {|key,value| @@irrelevant_sub_libraries.include? key } @updated_at = Time.now() end def raise_required_parameter_error(parameter) raise "Initialization error in #{self.class}. Missing required parameter: #{parameter}." \ No newline at end of file