Class: Vivlio::Starter::CLI::Metrics::CatalogLoader

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio/starter/cli/metrics/catalog_loader.rb

Overview

catalog.yml から有効章を取得する

Constant Summary collapse

CATALOG_PATH =
'config/catalog.yml'
SECTIONS =
%w[PREFACE CHAPTERS APPENDICES POSTFACE].freeze

Instance Method Summary collapse

Constructor Details

#initialize(catalog_path = CATALOG_PATH) ⇒ CatalogLoader

Returns a new instance of CatalogLoader.



30
31
32
# File 'lib/vivlio/starter/cli/metrics/catalog_loader.rb', line 30

def initialize(catalog_path = CATALOG_PATH)
  @catalog_path = catalog_path
end

Instance Method Details

#catalog_exists?Boolean

catalog.yml が存在するか確認する

Returns:

  • (Boolean)


43
# File 'lib/vivlio/starter/cli/metrics/catalog_loader.rb', line 43

def catalog_exists? = File.exist?(catalog_path)

#enabled_chaptersObject

有効な章のベース名リストを取得する



35
36
37
38
39
40
# File 'lib/vivlio/starter/cli/metrics/catalog_loader.rb', line 35

def enabled_chapters
  return [] unless File.exist?(catalog_path)

  catalog = load_catalog
  SECTIONS.flat_map { extract_chapters(catalog[it]) }.compact.uniq
end