Class: Vivlio::Starter::CLI::Lint::DictManager
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::Lint::DictManager
- Defined in:
- lib/vivlio/starter/cli/lint/dict_manager.rb
Overview
辞書ファイルのロードとキャッシュを管理する
Constant Summary collapse
- BUNDLED_DIR =
File.('../../../../../config/spellcheck_dictionaries', __dir__)
- CACHE_DIR =
File.('../../../../../.cache/spellcheck-dictionaries', __dir__)
- DICT_BASE_URL =
'https://raw.githubusercontent.com/streetsidesoftware/' \ 'cspell-dicts/main/dictionaries'
- GLOSSARY_PATH =
'config/index_glossary_terms.yml'
Instance Method Summary collapse
-
#build_word_map(config) ⇒ Hash
辞書をマージして word_map を返す.
Instance Method Details
#build_word_map(config) ⇒ Hash
辞書をマージして word_map を返す
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/vivlio/starter/cli/lint/dict_manager.rb', line 23 def build_word_map(config) words = {} (bundled_dict_names + extra_dicts(config)).uniq.each do |name| path = resolve_path(name) load_into_word_map(path, words) if path end load_glossary_terms(words) extra_words(config).each do |w| word = w.to_s words[word.downcase] = word next unless word.include?('-') words[word.gsub('-', '').downcase] ||= word end words end |