Class: Tasks::Gitlab::AuditEventTypes::CheckDocsTask

Inherits:
Object
  • Object
show all
Defined in:
lib/tasks/gitlab/audit_event_types/check_docs_task.rb

Instance Method Summary collapse

Constructor Details

#initialize(docs_dir, docs_path, template_erb_path) ⇒ CheckDocsTask

Returns a new instance of CheckDocsTask.



7
8
9
10
11
# File 'lib/tasks/gitlab/audit_event_types/check_docs_task.rb', line 7

def initialize(docs_dir, docs_path, template_erb_path)
  @event_types_dir = docs_dir
  @audit_event_types_doc_file = docs_path
  @event_type_erb_template = ERB.new(File.read(template_erb_path), trim_mode: '<>')
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/tasks/gitlab/audit_event_types/check_docs_task.rb', line 13

def run
  doc = File.read(@audit_event_types_doc_file)

  if doc == @event_type_erb_template.result
    puts "Audit event types documentation is up to date."
  else
    error_message = "Audit event types documentation is outdated! Please update it by running " \
                    "`bundle exec rake gitlab:audit_event_types:compile_docs`."
    heading = '#' * 10
    puts heading
    puts '#'
    puts "# #{error_message}"
    puts '#'
    puts heading

    abort
  end
end