Class: Danger::DangerToc
- Inherits:
-
Plugin
- Object
- Plugin
- Danger::DangerToc
- Extended by:
- Forwardable
- Defined in:
- lib/toc/plugin.rb
Overview
Check whether the TOC in .md file(s) has been updated.
Instance Method Summary collapse
-
#check ⇒ void
Run all checks.
-
#check! ⇒ void
Run all checks.
-
#is_toc_correct? ⇒ boolean
Is the TOC format correct?.
-
#toc_changes? ⇒ boolean
Has the README file been modified?.
Instance Method Details
#check ⇒ void
This method returns an undefined value.
Run all checks.
29 30 31 32 |
# File 'lib/toc/plugin.rb', line 29 def check warn '[DEPRECATION] `check` is deprecated. Please use `check!` instead.' check! end |
#check! ⇒ void
This method returns an undefined value.
Run all checks.
23 24 25 |
# File 'lib/toc/plugin.rb', line 23 def check! is_toc_correct? end |
#is_toc_correct? ⇒ boolean
Is the TOC format correct?
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/toc/plugin.rb', line 42 def is_toc_correct? files.all? do |filename| toc_file = Danger::Toc::MarkdownFile.new(filename) if !toc_file.exists? messaging.fail("The #{filename} file does not exist.", sticky: false) false elsif toc_file.good? true else markdown "Here's the expected TOC for \#{filename}:\n\n```markdown\n# \#{Danger::Toc.config.header}\n\n\#{toc_file.toc_from_headers.join(\"\\n\")}\n```\n MARKDOWN\n if toc_file.has_toc?\n messaging.fail(\"The TOC found in \#{filename} doesn't match the sections of the file.\", sticky: false)\n else\n messaging.fail(\"The \#{filename} file is missing a TOC.\", sticky: false)\n end\n false\n end\n end\nend\n" |
#toc_changes? ⇒ boolean
Has the README file been modified?
36 37 38 |
# File 'lib/toc/plugin.rb', line 36 def toc_changes? (git.modified_files & files).any? || (git.added_files & files).any? end |