Class: WatchmonkeyCli::Checker::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/watchmonkey_cli/checker.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(checker, *args) ⇒ Result

Returns a new instance of Result.



48
49
50
51
52
53
54
# File 'lib/watchmonkey_cli/checker.rb', line 48

def initialize checker, *args
  @checker = checker
  @args = args
  @mutex = Monitor.new
  @type = :info
  @spool = { error: [], info: [], debug: []}
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



45
46
47
# File 'lib/watchmonkey_cli/checker.rb', line 45

def args
  @args
end

#checkerObject (readonly)

Returns the value of attribute checker.



45
46
47
# File 'lib/watchmonkey_cli/checker.rb', line 45

def checker
  @checker
end

#commandObject

Returns the value of attribute command.



46
47
48
# File 'lib/watchmonkey_cli/checker.rb', line 46

def command
  @command
end

#dataObject

Returns the value of attribute data.



46
47
48
# File 'lib/watchmonkey_cli/checker.rb', line 46

def data
  @data
end

#resultObject

Returns the value of attribute result.



46
47
48
# File 'lib/watchmonkey_cli/checker.rb', line 46

def result
  @result
end

#typeObject (readonly)

Returns the value of attribute type.



45
46
47
# File 'lib/watchmonkey_cli/checker.rb', line 45

def type
  @type
end

Instance Method Details

#descriptorObject



60
61
62
# File 'lib/watchmonkey_cli/checker.rb', line 60

def descriptor
  "[#{@checker.class.checker_name} | #{args.join(" | ")}]"
end

#dump!Object



80
81
82
83
84
85
86
87
88
# File 'lib/watchmonkey_cli/checker.rb', line 80

def dump!
  sync do
    @spool.each do |t, messages|
      while messages.any?
        @checker.send(t, "#{str_descriptor}#{messages.shift}", self)
      end
    end
  end
end

#messagesObject



76
77
78
# File 'lib/watchmonkey_cli/checker.rb', line 76

def messages
  @spool.map(&:second).flatten
end

#str_descriptorObject



72
73
74
# File 'lib/watchmonkey_cli/checker.rb', line 72

def str_descriptor
  "#{descriptor}\n\t"
end

#str_runningObject



68
69
70
# File 'lib/watchmonkey_cli/checker.rb', line 68

def str_running
  "Running checker #{@checker.class.checker_name} with [#{args.join(" | ")}]"
end

#str_safeObject



64
65
66
# File 'lib/watchmonkey_cli/checker.rb', line 64

def str_safe
  "#{descriptor}\n\t"
end

#sync(&block) ⇒ Object



56
57
58
# File 'lib/watchmonkey_cli/checker.rb', line 56

def sync &block
  @mutex.synchronize(&block)
end