class Oddb2xml::SemanticCheckXML
Attributes
basename[R]
components[RW]
filename[R]
hash[R]
keys[R]
sub_key_names[R]
version[R]
Public Class Methods
get_component_key_name(component_name)
click to toggle source
# File lib/oddb2xml/semantic_check.rb, line 22 def self.get_component_key_name(component_name) return "LIMNAMEBAG" if /LIMITATION/i.match?(component_name) return "PRODNO" if /PRODUCT/i.match?(component_name) return "GTIN" if /ITEM/i.match?(component_name) raise "Cannot determine keyname for component #{component_name}" end
new(filename, components = ["PRODUCTS", "LIMITATIONS", "ITEMS"])
click to toggle source
# File lib/oddb2xml/semantic_check.rb, line 14 def initialize(filename, components = ["PRODUCTS", "LIMITATIONS", "ITEMS"]) raise "File #{filename} must exist" unless File.exist?(filename) @filename = filename @basename = File.basename(filename) @components = components @hash = load_file(@filename) end
Public Instance Methods
get_items(component_name)
click to toggle source
# File lib/oddb2xml/semantic_check.rb, line 29 def get_items(component_name) # hack to make it spec/check_artikelstamm.rb work if called alone or as part # of the whole spec suite xx = @hash[:ARTIKELSTAMM] || @hash["ARTIKELSTAMM"] comps = xx[component_name.to_sym] || xx[component_name] comps.values.first end
load_file(name)
click to toggle source
# File lib/oddb2xml/semantic_check.rb, line 37 def load_file(name) Oddb2xml.log_timestamp "Reading #{name} #{(File.size(name) / 1024 / 1024).to_i} MB. This may take some time" Ox.load(IO.read(name), mode: :hash_no_attrs) end