Module: Kcaco

Defined in:
lib/kcaco.rb,
lib/kcaco/version.rb,
lib/kcaco/file_writer.rb,
lib/kcaco/wrapped_exception.rb

Defined Under Namespace

Classes: FileWriter, WrappedException

Class Method Summary collapse

Class Method Details

.auto_save=(bool) ⇒ Object



9
10
11
# File 'lib/kcaco.rb', line 9

def auto_save=(bool)
  @auto_save = bool
end

.auto_save?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/kcaco.rb', line 13

def auto_save?
  @auto_save != false
end

.pretty(exception) ⇒ Object



35
36
37
38
39
40
# File 'lib/kcaco.rb', line 35

def pretty(exception)
  wrapped_exception = Kcaco::WrappedException.new(exception)
  wrapped_exception.payload = yield if block_given?
  save(wrapped_exception) if auto_save?
  wrapped_exception.pretty
end

.save(wrapped_exception) ⇒ Object



30
31
32
33
# File 'lib/kcaco.rb', line 30

def save(wrapped_exception)
  Kcaco::FileWriter.new(wrapped_exception).
    save(save_path(wrapped_exception))
end

.save_path(wrapped_exception = nil) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/kcaco.rb', line 21

def save_path(wrapped_exception = nil)
  @save_path ||= "/tmp/kcaco/exceptions"
  if wrapped_exception
    File.join(@save_path, wrapped_exception.uuid)
  else
    @save_path
  end
end

.save_path=(path) ⇒ Object



17
18
19
# File 'lib/kcaco.rb', line 17

def save_path=(path)
  @save_path = path
end

.versionObject



3
4
5
# File 'lib/kcaco/version.rb', line 3

def version
  "0.0.2"
end