class HammerCLIForemanTasks::CommandExtensions::RecurringLogic
Public Class Methods
format_record(data)
click to toggle source
The recurring_logics API already computes the action, the occurrences and the limits (see the `base` rabl view). The extension only normalizes them: the API spells the occurrences with a single “r”, so they are copied to the corrected keys and rendered as dates, while blank limits show “Unlimited”. The action, occurrences and purpose are nilled when empty so their `hide_blank` fields skip the line entirely in the info output. Working off these fields keeps the list and the info command consistent, as the list output has no `tasks` to recompute them from.
# File lib/hammer_cli_foreman_tasks/command_extensions/recurring_logic.rb, line 36 def self.format_record(data) data['action'] = nil if data['action'].to_s.empty? data['last_occurrence'] = data['last_occurence'] data['next_occurrence'] = data['next_occurence'] data['iteration_limit'] = format_recurring_logic_limit(data['max_iteration']) data['repeat_until'] = format_recurring_logic_limit(data['end_time']) data['purpose'] = nil if data['purpose'].to_s.empty? end
format_recurring_logic_limit(thing)
click to toggle source
# File lib/hammer_cli_foreman_tasks/command_extensions/recurring_logic.rb, line 45 def self.format_recurring_logic_limit(thing) thing || _('Unlimited') end
records(data)
click to toggle source
The info command hands over a single recurring logic, the list command a whole collection wrapped in `results`. Both are formatted the same way.
# File lib/hammer_cli_foreman_tasks/command_extensions/recurring_logic.rb, line 24 def self.records(data) data.is_a?(Hash) && data['results'].is_a?(Array) ? data['results'] : [data] end