Class: I18nFlow::CLI::LintCommand::MarkdownRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n_flow/cli/lint_command/markdown_renderer.rb

Constant Summary collapse

FILE =
__dir__ + '/markdown.erb'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(errors, url_formatter:) ⇒ MarkdownRenderer

Returns a new instance of MarkdownRenderer.



11
12
13
14
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 11

def initialize(errors, url_formatter:)
  @errors = errors
  @url_formatter = url_formatter
end

Instance Attribute Details

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 8

def errors
  @errors
end

#url_formatterObject (readonly)

Returns the value of attribute url_formatter.



9
10
11
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 9

def url_formatter
  @url_formatter
end

Instance Method Details

#error_countObject



24
25
26
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 24

def error_count
  @error_count ||= errors.sum { |_, errs| errs.size }
end

#file_countObject



20
21
22
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 20

def file_count
  @file_count ||= errors.size
end

#renderObject



16
17
18
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 16

def render
  with_link(erb.result(binding))
end

#summary_lineObject



28
29
30
31
32
33
34
35
# File 'lib/i18n_flow/cli/lint_command/markdown_renderer.rb', line 28

def summary_line
  @summary_line ||= 'Found %d %s in %d %s' % [
    error_count,
    error_count == 1 ? 'violation' : 'violations',
    file_count,
    file_count == 1 ? 'file' : 'files',
  ]
end