Class: Textus::Action::Audit
- Extended by:
- Contract::DSL
- Defined in:
- lib/textus/action/audit.rb
Defined Under Namespace
Classes: Query
Constant Summary collapse
- BURN =
:sync
Class Method Summary collapse
Instance Method Summary collapse
- #args ⇒ Object
- #call(container:) ⇒ Object
-
#initialize(**kwargs) ⇒ Audit
constructor
A new instance of Audit.
Methods included from Contract::DSL
arg, around, cli, cli_stdin, contract, contract?, summary, surfaces, verb, view
Methods inherited from Base
Constructor Details
Class Method Details
.parse_since(str, now: Time.now.utc) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/textus/action/audit.rb', line 67 def self.parse_since(str, now: Time.now.utc) return nil if str.nil? || str.empty? return Time.parse(str) if str =~ /\A\d{4}-\d{2}-\d{2}/ match = str.match(/\A(\d+)([smhd])\z/) or return nil mult = { "s" => 1, "m" => 60, "h" => 3600, "d" => 86_400 }[match[2]] now - (match[1].to_i * mult) end |
Instance Method Details
#args ⇒ Object
34 35 36 |
# File 'lib/textus/action/audit.rb', line 34 def args @query.to_h.compact end |
#call(container:) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/textus/action/audit.rb', line 38 def call(container:, **) @manifest = container.manifest @root = container.root @log_path = Textus::Layout.audit_log(container.root) @audit_log = container.audit_log query = @query check_cursor_expiry!(query.seq_since) files = all_log_files return [] if files.empty? rows = [] files.each do |file| File.foreach(file) do |line| parsed = parse_row(line.chomp) next unless parsed next unless query.matches?(parsed) next if query.lane && !key_in_lane?(parsed["key"], query.lane) rows << parsed break if limit_reached?(rows, query) end break if limit_reached?(rows, query) end rows end |