diff options
Diffstat (limited to 'lib/tasks/gitlab/audit_event_types/check_docs_task.rb')
-rw-r--r-- | lib/tasks/gitlab/audit_event_types/check_docs_task.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/tasks/gitlab/audit_event_types/check_docs_task.rb b/lib/tasks/gitlab/audit_event_types/check_docs_task.rb new file mode 100644 index 00000000000..f62dd116ed1 --- /dev/null +++ b/lib/tasks/gitlab/audit_event_types/check_docs_task.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Tasks + module Gitlab + module AuditEventTypes + class CheckDocsTask + 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 + + 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 + end + end + end +end |