Module: Renalware::Feeds::Job

Extended by:
ActiveSupport::Concern
Included in:
Files::PracticeMemberships::ImportJob, Files::Practices::ImportJob, Files::PrimaryCarePhysicians::ImportJob
Defined in:
app/models/concerns/renalware/feeds/job.rb

Instance Method Summary collapse

Instance Method Details

#find_file_in(files, pattern) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'app/models/concerns/renalware/feeds/job.rb', line 21

def find_file_in(files, pattern)
  file = files.select{ |f| f.basename.to_s.match(pattern) }.first
  if file.nil?
    msg = "Zip file does not contain a file with name matching #{pattern}!"
    log(msg)
    fail(msg)
  end
  file
end

#formatted_exception(error) ⇒ Object



10
11
12
13
14
15
# File 'app/models/concerns/renalware/feeds/job.rb', line 10

def formatted_exception(error)
  [
    "#{error.backtrace.first}: #{error.message} (#{error.class})",
    error.backtrace.drop(1).map{ |s| "\t#{s}" }
  ].join("\n")
end

#log(msg) ⇒ Object



17
18
19
# File 'app/models/concerns/renalware/feeds/job.rb', line 17

def log(msg)
  Rails.logger.info(msg)
end