lib/object_factory_writer.rb
def find_files_to_attach(attributes)
    return @etd if @etd
    return [] if @settings[:files_dirs].blank?

    file_groups = attributes[:fulltext_link].map do |name|
      match = name.match(/.*Cylinder(\d+)$/)
      next if match.blank?
      cylinder_number = match[1]

      @settings[:files_dirs].map do |dir| # Look in all the dirs
        Dir.glob(File.join(dir, "**", "cusb-cyl#{cylinder_number}*"))
      end.flatten
    end.reject(&:blank?)

    logger.debug "Files to attach:"
    file_groups.flatten.each { |f| logger.debug f.inspect }

    file_groups
  end
# Extract the cylinder numbers from names like these:
# ["Cylinder 12783", "Cylinder 0006"]
# and then find the files that match those numbers.
# We want to return an array of arrays, like this:
# [
#   ['/path/cusb-cyl12783a.wav', /path/cusb-cyl12783b.wav'],
#   ['/path/cusb-cyl0006a.wav',  /path/cusb-cyl0006b.wav'],
# ]
Extract the cylinder numbers from names like these:
["Cylinder 12783", "Cylinder 0006"]
and then find the files that match those numbers.
Extract the cylinder numbers from names like these : [ " Cylinder 12783 " " Cylinder 0006 " ] and then find the files that match those numbers .
def find_files_to_attach(attributes)
    return @etd if @etd
    return [] if @settings[:files_dirs].blank?
    file_groups = attributes[:fulltext_link].map do |name|
      match = name.match(/.*Cylinder(\d+)$/)
      next if match.blank?
      cylinder_number = match[1]
      @settings[:files_dirs].map do |dir| 
        Dir.glob(File.join(dir, "**", "cusb-cyl#{cylinder_number}*"))
      end.flatten
    end.reject(&:blank?)
    logger.debug "Files to attach:"
    file_groups.flatten.each { |f| logger.debug f.inspect }
    file_groups
  end
def find_files_to_attach ( attributes ) return @etd if @etd return [ ] if @settings [ :files_dirs ] . blank? file_groups = attributes [ :fulltext_link ] . map do | name | match = name . match ( / .*Cylinder( \d +)$ / ) next if match . blank? cylinder_number = match [ 1 ] @settings [ :files_dirs ] . map do | dir | Dir . glob ( File . join ( dir , "**" , "cusb-cyl#{cylinder_number}*" ) ) end . flatten end . reject ( & :blank? ) logger . debug "Files to attach:" file_groups . flatten . each { | f | logger . debug f . inspect } file_groups end
Extract the cylinder numbers from names like these:
["Cylinder 12783", "Cylinder 0006"]
and then find the files that match those numbers.
Extract the cylinder numbers from names like these : [ " Cylinder 12783 " " Cylinder 0006 " ] and then find the files that match those numbers .
# Look in all the dirs
attributes