class GoogleScribe

Attributes

url[RW]

Public Class Methods

new(url = nil) click to toggle source
# File lib/google_scribe.rb, line 6
def initialize(url = nil)
        self.url = url
end

Public Instance Methods

log_process(process_name, preserve_exceptions = true, &block) click to toggle source

Will log the data returned by the block If the process fails, it will log the error message instead If preserve_exceptions is false, exceptions will fail silently otherwise, the exception will be logged normally

# File lib/google_scribe.rb, line 18
def log_process(process_name, preserve_exceptions = true, &block)
        begin
                block_data = block.call
                process_data = { "Process" => process_name, "Success" => true }

                if block_data.is_a?(Hash)
                        self.send_data(block_data.merge(process_data))
                else
                        self.send_data(process_data)
                end

        rescue Exception => e
                lines = e.backtrace.reject{|s| s.include?("/gems/") }
                error_message = "#{ e.message } : #{ lines.first }"

                process_data = { "Process" => process_name, "Success" => false,
                        "Error Message" => error_message }

                self.send_data(process_data)

                raise e if preserve_exceptions
        end
end
send_data(data) click to toggle source
# File lib/google_scribe.rb, line 10
def send_data(data)
        GoogleSheetsClient.post(data, self.url)
end