Class: Vivlio::Starter::CLI::StatBuilder
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::StatBuilder
- Defined in:
- lib/vivlio/starter/cli/metrics.rb
Overview
個別 Markdown の統計情報を構築する
Instance Method Summary collapse
-
#build(path) ⇒ Object
単一ファイルから統計情報ハッシュを生成する.
Instance Method Details
#build(path) ⇒ Object
単一ファイルから統計情報ハッシュを生成する
155 156 157 158 159 160 161 162 163 |
# File 'lib/vivlio/starter/cli/metrics.rb', line 155 def build(path) absolute = Pathname.new(path) absolute = Pathname.new('.') / path unless absolute.absolute? content = File.read(absolute, encoding: 'UTF-8') base_metrics(content).merge(sentence_metrics(content)).merge(clause_metrics(content)).merge('path' => path) rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError => e Common.log_warn("エンコーディングエラーのためスキップします: #{path} (#{e.})") blank_stat(path) end |