Class: Lazylead::Logs

Inherits:
Attachment show all
Defined in:
lib/lazylead/task/accuracy/logs.rb

Overview

Check that ticket has log file(s) in attachment.

Direct Known Subclasses

LogsLink

Instance Attribute Summary

Attributes inherited from Requirement

#desc, #field, #score

Instance Method Summary collapse

Methods inherited from Attachment

#passed

Methods inherited from Requirement

#blank?, #non_blank?, #passed

Constructor Details

#initialize(files = %w[log.zip logs.zip log.gz logs.gz log.tar.gz logs.tar.gz log.7z logs.7z log.tar logs.tar])) ⇒ Logs

Returns a new instance of Logs.



30
31
32
33
34
# File 'lib/lazylead/task/accuracy/logs.rb', line 30

def initialize(files = %w[log.zip logs.zip log.gz logs.gz log.tar.gz
                          logs.tar.gz log.7z logs.7z log.tar logs.tar])
  super("Log files", 2, "Attachments")
  @files = files
end

Instance Method Details

#matches?(attachment) ⇒ Boolean

Ensure that ticket has a ‘*.log’ file more ‘5KB’

Returns:

  • (Boolean)


37
38
39
40
41
42
43
44
45
# File 'lib/lazylead/task/accuracy/logs.rb', line 37

def matches?(attachment)
  name = attachment.attrs["filename"].downcase
  return false unless attachment.attrs["size"].to_i > 5120
  return true if File.extname(name).start_with? ".log", ".txt", ".out"
  return true if @files.any? { |l| name.end_with? l }
  %w[.zip .7z .gz tar.gz].any? do |l|
    name.end_with?(l) && name.split(/(?:[^a-zA-Z0-9](?<![^\x00-\x7F]))+/).include?("logs")
  end
end