class FbErrorMachine::ErrorWriter

Public Class Methods

find_description(row) click to toggle source
# File lib/fb_error_machine/error_writer.rb, line 16
def self.find_description(row)
  dirty_html = row.tds.to_a[1].inner_html
  sanitize(dirty_html)
end
find_error_code(row) click to toggle source
# File lib/fb_error_machine/error_writer.rb, line 12
def self.find_error_code(row)
  sanitize(row.tds.first.inner_html)
end
find_instructions(row) click to toggle source
# File lib/fb_error_machine/error_writer.rb, line 21
def self.find_instructions(row)
  sanitize(row.tds[2].inner_html)
end
sanitize(html) click to toggle source
# File lib/fb_error_machine/error_writer.rb, line 25
def self.sanitize(html)
  Sanitize.fragment(html).strip.gsub("\n", "").gsub("  ", " ")
end
write_errors(attrs) click to toggle source
# File lib/fb_error_machine/error_writer.rb, line 4
def self.write_errors(attrs)
  type = attrs.delete(:type)
  errors = attrs[:errors]

  store_path = "lib/fb_error_machine/#{type}_api_errors.yml"
  File.open(store_path, 'w') {|f| f.write errors.to_yaml }
end