Class: Logcli::Actions::Grep
- Inherits:
-
Object
- Object
- Logcli::Actions::Grep
- Defined in:
- lib/logcli/actions/grep.rb
Constant Summary collapse
- COMMAND =
'grep'.freeze
Instance Attribute Summary collapse
-
#grep ⇒ Object
Returns the value of attribute grep.
-
#path ⇒ Object
Returns the value of attribute path.
-
#tmp_path ⇒ Object
readonly
Returns the value of attribute tmp_path.
Class Method Summary collapse
Instance Method Summary collapse
- #call(ssh) ⇒ Object
-
#initialize(opts) ⇒ Grep
constructor
A new instance of Grep.
Constructor Details
#initialize(opts) ⇒ Grep
Returns a new instance of Grep.
8 9 10 11 |
# File 'lib/logcli/actions/grep.rb', line 8 def initialize opts @grep = opts.fetch(:grep) @path = opts.fetch(:path) end |
Instance Attribute Details
#grep ⇒ Object
Returns the value of attribute grep.
5 6 7 |
# File 'lib/logcli/actions/grep.rb', line 5 def grep @grep end |
#path ⇒ Object
Returns the value of attribute path.
5 6 7 |
# File 'lib/logcli/actions/grep.rb', line 5 def path @path end |
#tmp_path ⇒ Object (readonly)
Returns the value of attribute tmp_path.
6 7 8 |
# File 'lib/logcli/actions/grep.rb', line 6 def tmp_path @tmp_path end |
Class Method Details
.call(opts) ⇒ Object
27 28 29 30 |
# File 'lib/logcli/actions/grep.rb', line 27 def self.call opts grep = new opts grep.call end |
Instance Method Details
#call(ssh) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/logcli/actions/grep.rb', line 13 def call ssh cmd = "#{COMMAND} -rni \"#{grep}\" #{path} > #{tmp_path}" puts "[grep] start: [#{cmd}]" ssh.execute! cmd puts "[grep] finish: [#{cmd}]" end |