Module: Zakuro::Operation::MonthParser

Defined in:
lib/zakuro/operation/month/parser.rb

Overview

MonthParser 月情報解析(yaml)

Class Method Summary collapse

Class Method Details

.load(yaml_hash: {}) ⇒ Array<MonthHistory>

設定ファイルを読み込む

Parameters:

  • yaml_hash (Hash) (defaults to: {})

    設定ファイルテキスト

Returns:



137
138
139
140
141
142
143
144
# File 'lib/zakuro/operation/month/parser.rb', line 137

def load(yaml_hash: {})
  histories = create_histories(yaml_hash: yaml_hash)

  annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
  annotation_parser.create

  add_annotations(histories: histories, annotation_parser: annotation_parser)
end

.run(filepath:) ⇒ Array<MonthHistory>

実行する

Returns:

Raises:

  • (ArgumentError)

    引数エラー



120
121
122
123
124
125
126
127
128
# File 'lib/zakuro/operation/month/parser.rb', line 120

def run(filepath:)
  hash = YAML.load_file(filepath)

  failed = Validator.run(yaml_hash: hash)

  raise ArgumentError, failed.join("\n") unless failed.empty?

  load(yaml_hash: hash)
end