Class: JsDependency::Report::Markdown
- Inherits:
-
Object
- Object
- JsDependency::Report::Markdown
- Defined in:
- lib/js_dependency/report/markdown.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#mermaid_markdown ⇒ Object
readonly
Returns the value of attribute mermaid_markdown.
-
#orphan_list ⇒ Object
readonly
Returns the value of attribute orphan_list.
Instance Method Summary collapse
- #export ⇒ String
-
#initialize(orphan_list, mermaid_markdown, identifier: nil) ⇒ Markdown
constructor
A new instance of Markdown.
Constructor Details
#initialize(orphan_list, mermaid_markdown, identifier: nil) ⇒ Markdown
Returns a new instance of Markdown.
11 12 13 14 15 |
# File 'lib/js_dependency/report/markdown.rb', line 11 def initialize(orphan_list, mermaid_markdown, identifier: nil) @orphan_list = orphan_list || [] @mermaid_markdown = mermaid_markdown @identifier = identifier || "js_dependency_report_identifier" end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
6 7 8 |
# File 'lib/js_dependency/report/markdown.rb', line 6 def identifier @identifier end |
#mermaid_markdown ⇒ Object (readonly)
Returns the value of attribute mermaid_markdown.
6 7 8 |
# File 'lib/js_dependency/report/markdown.rb', line 6 def mermaid_markdown @mermaid_markdown end |
#orphan_list ⇒ Object (readonly)
Returns the value of attribute orphan_list.
6 7 8 |
# File 'lib/js_dependency/report/markdown.rb', line 6 def orphan_list @orphan_list end |
Instance Method Details
#export ⇒ String
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/js_dependency/report/markdown.rb', line 18 def export markdown = <<~MAKRDOWNTEXT ## JsDependency Reports ### Orphan modules MAKRDOWNTEXT if @orphan_list.empty? markdown += "No orphaned module !\n\n" else markdown += "#{@orphan_list.size} orphaned modules.\n\n" markdown += "#{@orphan_list.map { |str| "* ``#{str}``" }.join("\n")}\n\n" end markdown += "### Module dependency\n\n" if @mermaid_markdown.nil? || @mermaid_markdown.empty? markdown += ".vue or .js or .jsx files are not changed.\n\n" else markdown += <<~MAKRDOWNTEXT ```mermaid MAKRDOWNTEXT markdown += @mermaid_markdown.to_s markdown += <<~MAKRDOWNTEXT ``` MAKRDOWNTEXT end markdown += "<!-- #{@identifier} -->" markdown end |