module OLE_QA::Framework::Bib_Factory
Manufacture strings for bibliographic, instance, and item record testing
Public Class Methods
barcode()
click to toggle source
Return a random string of between 12 and 18 numbers to be used as a barcode.
# File lib/data_factory/bib_factory.rb, line 23 def barcode (0..(11..17).to_a.sample).map{(0..9).to_a.sample}.join end
call_number(format = "LOC")
click to toggle source
Return a random (non-validated) call number in the specified format.
# File lib/data_factory/bib_factory.rb, line 28 def call_number(format = "LOC") call_num = Array.new # TODO - Use case...when once other formats are added. # LOC Format Call Number call_num << (0..(0..1).to_a.sample).map{('A'..'Z').to_a.sample}.join call_num << (0..(1..3).to_a.sample).map{(1..9).to_a.sample}.join << " " call_num << "." << ('A'..'Z').to_a.sample call_num << (0..(1..2).to_a.sample).map{(1..9).to_a.sample}.join call_num.join end
circulation_info(desk_code = '')
click to toggle source
Return a hash containing circulation desk and location information. @note Pass a circulation desk code defined in data/circulation.yml to return
info on a specific circulation desk.
# File lib/data_factory/bib_factory.rb, line 67 def circulation_info(desk_code = '') circ_ary = YAML.load_file(OLE_QA::Framework.data_dir + '/circulation.yml') hsh_out = desk_code.empty? ? circ_ary.sample : circ_ary.find {|circ| circ[:code] == desk_code} raise OLE_QA::Framework::Error,"No circulation desk found.#{ ' Given: ' + desk_code unless desk_code.empty?}" if hsh_out.nil? return hsh_out end
title(len = 8..12)
click to toggle source
Return a random title with the specified length.
# File lib/data_factory/bib_factory.rb, line 40 def title(len = 8..12) if len.class == Range name_builder(sampler(len)) else name_builder(len.to_i) end end