Class: Evertils::Controller::Log

Inherits:
Base
  • Object
show all
Defined in:
lib/evertils/controllers/log.rb

Constant Summary collapse

WORDS_PER_LINE =
20

Constants inherited from Base

Base::OK, Base::QUIT, Base::QUIT_SOFT

Instance Attribute Summary

Attributes inherited from Base

#config, #request

Instance Method Summary collapse

Methods inherited from Base

#can_exec?, #exec, #initialize, #post_exec, #sample

Constructor Details

This class inherits a constructor from Evertils::Controller::Base

Instance Method Details

#grep(text = nil) ⇒ Object

Since:

  • 2.2.0



39
40
41
42
43
# File 'lib/evertils/controllers/log.rb', line 39

def grep(text = nil)
  runner = ActionRunner.new
  runner.params = GrepParams.new(text, 'search', 'Daily')
  runner.execute
end

#groupObject

Since:

  • 2.2.0



47
48
49
50
51
# File 'lib/evertils/controllers/log.rb', line 47

def group
  runner = ActionRunner.new
  runner.params = GroupParams.new('group', 'Daily')
  runner.execute
end

#message(text = nil) ⇒ Object

Send arbitrary text to the daily log



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/evertils/controllers/log.rb', line 24

def message(text = nil)
  return Notify.error('A message is required') if text.nil?

  @note = @note_helper.find_note_by_grammar(grammar.to_s)
  text_groups = text.split(' ').each_slice(WORDS_PER_LINE).map do |w|
    w.join(' ')
  end

  return Notify.error("Note not found for grammar '#{grammar}'") if @note.entity.nil?

  modify_with(text_groups)
end

#pre_execObject



15
16
17
18
19
20
21
# File 'lib/evertils/controllers/log.rb', line 15

def pre_exec
  super

  @note = nil
  @note_helper = Evertils::Helper::Note.instance
  @api_helper = Evertils::Helper::ApiEnmlHandler.new(@config)
end