Class: Vivlio::Starter::CLI::LintCommands::LintRunner
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::LintCommands::LintRunner
- Defined in:
- lib/vivlio/starter/cli/lint.rb
Overview
text:lint 実行ロジックをまとめたランナー
Defined Under Namespace
Classes: TargetResolver
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(targets, options) ⇒ LintRunner
constructor
A new instance of LintRunner.
Constructor Details
#initialize(targets, options) ⇒ LintRunner
Returns a new instance of LintRunner.
107 108 109 110 |
# File 'lib/vivlio/starter/cli/lint.rb', line 107 def initialize(targets, ) @targets = Array(targets) @options = () end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
105 106 107 |
# File 'lib/vivlio/starter/cli/lint.rb', line 105 def @options end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
105 106 107 |
# File 'lib/vivlio/starter/cli/lint.rb', line 105 def targets @targets end |
Instance Method Details
#call ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/vivlio/starter/cli/lint.rb', line 112 def call ensure_textlint_available! ensure_config_present! ensure_support_yaml_files! files = resolve_targets if files.empty? Common.log_warn('textlint 対象となる Markdown ファイルが見つかりません。') return 0 end # vs-lint コメントを textlint ネイティブ記法に変換 converted_files = convert_vs_lint_comments(files) begin command = build_command(converted_files) Common.log_action("textlint 実行: #{Shellwords.join(command)}") stdout, stderr, status = Open3.capture3(*command) raw_stdout = stdout raw_stderr = stderr # stylish 出力の構造的再整形(列番号除去・ルール名括弧化・冗長部除去・日本語化) stdout = TextlintFormatter.reformat_output(stdout) unless stdout.nil? || stdout.empty? stdout = filter_textlint_summary(stdout) stderr = filter_textlint_summary(stderr) $stdout.print(stdout) unless stdout.nil? || stdout.empty? $stderr.print(stderr) unless stderr.nil? || stderr.empty? Common.log_always '' unless stdout.nil? || stdout.empty? lint_info = collect_textlint_info(status, raw_stdout, raw_stderr) spell_info = run_spellcheck(files) print_combined_summary(lint_info, spell_info) [lint_info[:exit], spell_info[:exit]].max ensure # 一時ファイルのクリーンアップ cleanup_temp_files(converted_files) end rescue LintError => e Common.log_error(e.) 1 end |