Class: SweetStaging::LogFile
- Inherits:
-
Object
- Object
- SweetStaging::LogFile
- Defined in:
- lib/sweet_staging.rb
Overview
%i(debug info warn error fatal unknown).each do |method_name|
define_method(method_name) { |*_args| }
end
end
Constant Summary collapse
- MAX_LINES =
1000
Instance Attribute Summary collapse
-
#client_total_lines ⇒ Object
readonly
Returns the value of attribute client_total_lines.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #amount ⇒ Object
-
#initialize(path:, client_total_lines:) ⇒ LogFile
constructor
A new instance of LogFile.
- #readlines ⇒ Object
- #total_lines ⇒ Object
Constructor Details
Instance Attribute Details
#client_total_lines ⇒ Object (readonly)
Returns the value of attribute client_total_lines.
57 58 59 |
# File 'lib/sweet_staging.rb', line 57 def client_total_lines @client_total_lines end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
57 58 59 |
# File 'lib/sweet_staging.rb', line 57 def path @path end |
Instance Method Details
#amount ⇒ Object
76 77 78 79 80 81 |
# File 'lib/sweet_staging.rb', line 76 def amount result = total_lines - client_total_lines.to_i result = MAX_LINES if result < 0 result = MAX_LINES if result > MAX_LINES result end |
#readlines ⇒ Object
71 72 73 74 |
# File 'lib/sweet_staging.rb', line 71 def readlines #puts "tail -n #{amount} #{path}" `tail -n #{amount} #{path}`.split(/\n/) end |
#total_lines ⇒ Object
64 65 66 67 68 69 |
# File 'lib/sweet_staging.rb', line 64 def total_lines @total_lines ||= begin #puts "wc -l #{path}" `wc -l #{path}`.split.first.to_i end end |