zakuro 0.7.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +48 -13
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/csv/month.csv +100 -79
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +5 -5
- data/lib/zakuro/calculation/base/linear_gengou.rb +5 -5
- data/lib/zakuro/calculation/base/operated_year.rb +26 -24
- data/lib/zakuro/calculation/base/year.rb +7 -7
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +55 -47
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +28 -24
- data/lib/zakuro/calculation/cycle/zodiac.rb +22 -20
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +38 -29
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +4 -4
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +74 -72
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +16 -16
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +58 -35
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +3 -3
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +111 -113
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +7 -9
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +22 -20
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +39 -22
- data/lib/zakuro/calculation/era/version/version.rb +12 -10
- data/lib/zakuro/calculation/monthly/abstract_lunar_phase.rb +13 -9
- data/lib/zakuro/calculation/monthly/const.rb +18 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +40 -38
- data/lib/zakuro/calculation/monthly/month.rb +17 -17
- data/lib/zakuro/calculation/monthly/month_label.rb +4 -4
- data/lib/zakuro/calculation/monthly/operated_month.rb +37 -86
- data/lib/zakuro/calculation/monthly/operated_solar_term.rb +80 -0
- data/lib/zakuro/calculation/option/dropped_date/abstract_parameter.rb +44 -0
- data/lib/zakuro/calculation/option/dropped_date/location.rb +135 -0
- data/lib/zakuro/calculation/range/abstract_full_range.rb +40 -25
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +111 -109
- data/lib/zakuro/calculation/range/dated_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/dated_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +1 -1
- data/lib/zakuro/calculation/range/named_operation_range.rb +1 -1
- data/lib/zakuro/calculation/range/operated_solar_term.rb +220 -0
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +32 -29
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +115 -117
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +1 -1
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +48 -46
- data/lib/zakuro/calculation/stella/solar/abstract_average.rb +31 -26
- data/lib/zakuro/calculation/stella/solar/abstract_location.rb +7 -5
- data/lib/zakuro/calculation/stella/solar/choukei_value.rb +114 -114
- data/lib/zakuro/calculation/summary/internal/day.rb +42 -0
- data/lib/zakuro/calculation/summary/internal/month.rb +32 -11
- data/lib/zakuro/calculation/summary/internal/operation.rb +68 -67
- data/lib/zakuro/calculation/summary/internal/option.rb +101 -0
- data/lib/zakuro/calculation/summary/japan/range.rb +145 -118
- data/lib/zakuro/calculation/summary/japan/single.rb +87 -87
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +57 -50
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +95 -92
- data/lib/zakuro/calculation/summary/western/single.rb +78 -76
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +123 -119
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +63 -56
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +142 -92
- data/lib/zakuro/context/context.rb +44 -0
- data/lib/zakuro/context/option.rb +119 -0
- data/lib/zakuro/context/version_class_resolver.rb +112 -0
- data/lib/zakuro/era/japan/calendar.rb +35 -33
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +8 -4
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +117 -118
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +7 -5
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +20 -14
- data/lib/zakuro/era/japan/gengou/alignment.rb +27 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +51 -34
- data/lib/zakuro/era/japan/gengou/resource/type.rb +45 -37
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +34 -32
- data/lib/zakuro/era/japan/gengou.rb +28 -26
- data/lib/zakuro/era/japan/version.rb +18 -16
- data/lib/zakuro/era/western/calendar.rb +104 -88
- data/lib/zakuro/exception/case/pattern.rb +39 -3
- data/lib/zakuro/exception/case/preset.rb +2 -2
- data/lib/zakuro/exception/exception.rb +17 -15
- data/lib/zakuro/exception/zakuro_error.rb +19 -1
- data/lib/zakuro/gateway/locale/date.rb +2 -2
- data/lib/zakuro/gateway/locale/range.rb +3 -3
- data/lib/zakuro/gateway/range.rb +3 -3
- data/lib/zakuro/gateway/single.rb +14 -3
- data/lib/zakuro/merchant.rb +79 -9
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +17 -8
- data/lib/zakuro/operation/month/validator.rb +148 -144
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +955 -281
- data/lib/zakuro/output/response.rb +107 -141
- data/lib/zakuro/result/data/option/abstract_option.rb +37 -0
- data/lib/zakuro/result/data/option/dropped_date/calculation.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/option.rb +47 -0
- data/lib/zakuro/result/data/option/dropped_date/solar_term.rb +48 -0
- data/lib/zakuro/result/data/single_day.rb +9 -1
- data/lib/zakuro/result/operation/month/annotation.rb +2 -2
- data/lib/zakuro/result/operation/month/history.rb +2 -2
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +39 -0
- data/lib/zakuro/result/result.rb +3 -3
- data/lib/zakuro/tools/stringifier.rb +67 -42
- data/lib/zakuro/tools/typeconv.rb +17 -15
- data/lib/zakuro/tools/typeof.rb +15 -13
- data/lib/zakuro/version/daien/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +10 -12
- data/lib/zakuro/version/daien/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +19 -17
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/daien/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/daien/stella/solar/average.rb +53 -51
- data/lib/zakuro/version/daien/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/daien/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/genka/cycle/remainder.rb +4 -4
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +7 -5
- data/lib/zakuro/version/genka/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +48 -44
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +30 -28
- data/lib/zakuro/version/genka/stella/origin/january.rb +22 -20
- data/lib/zakuro/version/gihou/cycle/remainder.rb +2 -2
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +9 -9
- data/lib/zakuro/version/gihou/option/dropped_date/parameter.rb +31 -0
- data/lib/zakuro/version/gihou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/gihou/stella/lunar/adjustment.rb +42 -37
- data/lib/zakuro/version/gihou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +52 -47
- data/lib/zakuro/version/gihou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/gihou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/gihou/stella/origin/winter_solstice.rb +24 -22
- data/lib/zakuro/version/gihou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/gihou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/gihou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/gihou/stella/solar/value.rb +13 -11
- data/lib/zakuro/version/senmyou/const/remainder.rb +7 -1
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +37 -2
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +10 -10
- data/lib/zakuro/version/senmyou/option/dropped_date/parameter.rb +33 -0
- data/lib/zakuro/version/senmyou/range/annual_range.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +42 -36
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +16 -14
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +39 -34
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +15 -13
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +23 -21
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +22 -20
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +12 -10
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +52 -50
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +19 -17
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +13 -11
- metadata +27 -7
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -218
- data/lib/zakuro/result/operation/month/bundle.rb +0 -36
- data/lib/zakuro/result/operation/operation.rb +0 -44
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -15,199 +15,203 @@ module Zakuro
|
|
15
15
|
# TypeParser 型ごと変換
|
16
16
|
#
|
17
17
|
module TypeParser
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
str
|
28
|
-
|
29
|
-
|
30
|
-
def self.text(str:)
|
31
|
-
return '' if invalid?(str: str)
|
32
|
-
|
33
|
-
str
|
34
|
-
end
|
18
|
+
class << self
|
19
|
+
#
|
20
|
+
# 無効値かを判定する
|
21
|
+
#
|
22
|
+
# @param [String] str 文字列
|
23
|
+
#
|
24
|
+
# @return [True] 無効値
|
25
|
+
# @return [False] 有効値
|
26
|
+
#
|
27
|
+
def invalid?(str:)
|
28
|
+
str == '-'
|
29
|
+
end
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
#
|
39
|
-
# @param [String] str 文字列
|
40
|
-
#
|
41
|
-
# @return [True] 有効
|
42
|
-
# @return [False] 無効
|
43
|
-
#
|
44
|
-
def self.modified?(str:)
|
45
|
-
str == 'true'
|
46
|
-
end
|
31
|
+
def text(str:)
|
32
|
+
return '' if invalid?(str: str)
|
47
33
|
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
# @param [String] str 文字列
|
52
|
-
#
|
53
|
-
# @return [Integer] 月
|
54
|
-
#
|
55
|
-
def self.month_number(str:)
|
56
|
-
return -1 if invalid?(str: str)
|
57
|
-
|
58
|
-
str.to_i
|
59
|
-
end
|
34
|
+
str
|
35
|
+
end
|
60
36
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
37
|
+
#
|
38
|
+
# 有効行を変換する
|
39
|
+
#
|
40
|
+
# @param [String] str 文字列
|
41
|
+
#
|
42
|
+
# @return [True] 有効
|
43
|
+
# @return [False] 無効
|
44
|
+
#
|
45
|
+
def modified?(str:)
|
46
|
+
str == 'true'
|
47
|
+
end
|
72
48
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
49
|
+
#
|
50
|
+
# 月を変換する
|
51
|
+
#
|
52
|
+
# @param [String] str 文字列
|
53
|
+
#
|
54
|
+
# @return [Integer] 月
|
55
|
+
#
|
56
|
+
def month_number(str:)
|
57
|
+
return -1 if invalid?(str: str)
|
58
|
+
|
59
|
+
str.to_i
|
60
|
+
end
|
82
61
|
|
83
|
-
|
84
|
-
|
62
|
+
#
|
63
|
+
# 閏有無を変換する
|
64
|
+
#
|
65
|
+
# @param [String] str 文字列
|
66
|
+
#
|
67
|
+
# @return [True] 閏あり
|
68
|
+
# @return [True] 閏なし/閏設定なし
|
69
|
+
#
|
70
|
+
def month_leaped(str:)
|
71
|
+
str == 'true'
|
72
|
+
end
|
85
73
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
74
|
+
#
|
75
|
+
# 西暦日を変換する
|
76
|
+
#
|
77
|
+
# @param [String] str 文字列
|
78
|
+
#
|
79
|
+
# @return [Western::Calendar] 西暦日
|
80
|
+
#
|
81
|
+
def western_date(str:)
|
82
|
+
return Western::Calendar.new if invalid?(str: str)
|
83
|
+
|
84
|
+
Western::Calendar.parse(text: str)
|
85
|
+
end
|
95
86
|
|
96
|
-
|
97
|
-
|
87
|
+
#
|
88
|
+
# 日(差分)を変換する
|
89
|
+
#
|
90
|
+
# @param [String] str 文字列
|
91
|
+
#
|
92
|
+
# @return [Integer] 日(差分)
|
93
|
+
#
|
94
|
+
def days(str:)
|
95
|
+
return INVALID_DAY_VALUE if invalid?(str: str)
|
96
|
+
|
97
|
+
str.to_i
|
98
|
+
end
|
98
99
|
|
99
|
-
|
100
|
-
|
100
|
+
def solar_term_index(str:)
|
101
|
+
return -1 if invalid?(str: str)
|
101
102
|
|
102
|
-
|
103
|
-
|
103
|
+
str.to_i
|
104
|
+
end
|
105
|
+
end
|
104
106
|
end
|
105
107
|
|
106
108
|
#
|
107
109
|
# MonthParser 月情報解析(yaml)
|
108
110
|
#
|
109
111
|
module MonthParser
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
112
|
+
class << self
|
113
|
+
#
|
114
|
+
# 実行する
|
115
|
+
#
|
116
|
+
# @return [Array<MonthHistory>] 変更履歴
|
117
|
+
#
|
118
|
+
# @raise [ArgumentError] 引数エラー
|
119
|
+
#
|
120
|
+
def run(filepath:)
|
121
|
+
hash = YAML.load_file(filepath)
|
122
|
+
|
123
|
+
failed = Validator.run(yaml_hash: hash)
|
124
|
+
|
125
|
+
raise ArgumentError, failed.join("\n") unless failed.empty?
|
126
|
+
|
127
|
+
load(yaml_hash: hash)
|
128
|
+
end
|
124
129
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
130
|
+
#
|
131
|
+
# 設定ファイルを読み込む
|
132
|
+
#
|
133
|
+
# @param [Hash] yaml_hash 設定ファイルテキスト
|
134
|
+
#
|
135
|
+
# @return [Array<MonthHistory>] 変更履歴
|
136
|
+
#
|
137
|
+
def load(yaml_hash: {})
|
138
|
+
histories = create_histories(yaml_hash: yaml_hash)
|
134
139
|
|
135
|
-
|
136
|
-
|
140
|
+
annotation_parser = AnnotationParser.new(yaml_hash: yaml_hash)
|
141
|
+
annotation_parser.create
|
137
142
|
|
138
|
-
|
139
|
-
|
143
|
+
add_annotations(histories: histories, annotation_parser: annotation_parser)
|
144
|
+
end
|
140
145
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
yaml_hash
|
151
|
-
|
146
|
+
private
|
147
|
+
|
148
|
+
#
|
149
|
+
# 変更履歴を読み込む
|
150
|
+
#
|
151
|
+
# @param [Hash] yaml_hash 設定ファイルテキスト
|
152
|
+
#
|
153
|
+
# @return [Array<MonthHistory>] 変更履歴
|
154
|
+
#
|
155
|
+
def create_histories(yaml_hash: {})
|
156
|
+
result = []
|
157
|
+
yaml_hash.each do |month|
|
158
|
+
next unless Operation::TypeParser.modified?(str: month['modified'])
|
159
|
+
|
160
|
+
result.push(
|
161
|
+
create_history(yaml_hash: month)
|
162
|
+
)
|
163
|
+
end
|
164
|
+
result
|
165
|
+
end
|
152
166
|
|
153
|
-
|
154
|
-
|
155
|
-
|
167
|
+
def create_history(yaml_hash: {})
|
168
|
+
diffs = MonthDiffsParser.create(yaml_hash: yaml_hash['diffs'])
|
169
|
+
|
170
|
+
western_date = Operation::TypeParser.western_date(str: yaml_hash['western_date'])
|
171
|
+
reference = Reference.new(page: yaml_hash['page'].to_i, number: yaml_hash['number'].to_i,
|
172
|
+
japan_date: yaml_hash['japan_date'])
|
173
|
+
MonthHistory.new(id: yaml_hash['id'],
|
174
|
+
parent_id: Operation::TypeParser.text(str: yaml_hash['parent_id']),
|
175
|
+
reference: reference,
|
176
|
+
western_date: western_date,
|
177
|
+
diffs: diffs)
|
156
178
|
end
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
reference: reference,
|
170
|
-
western_date: western_date,
|
171
|
-
diffs: diffs)
|
172
|
-
end
|
173
|
-
private_class_method :create_history
|
174
|
-
|
175
|
-
def self.add_annotations(annotation_parser:, histories: [])
|
176
|
-
result = []
|
177
|
-
histories.each do |history|
|
178
|
-
id = history.id
|
179
|
-
result.push(
|
180
|
-
MonthHistory.new(
|
181
|
-
id: id, parent_id: history.parent_id, reference: history.reference,
|
182
|
-
western_date: history.western_date,
|
183
|
-
annotations: annotation_parser.specify(id: id),
|
184
|
-
diffs: history.diffs
|
179
|
+
|
180
|
+
def add_annotations(annotation_parser:, histories: [])
|
181
|
+
result = []
|
182
|
+
histories.each do |history|
|
183
|
+
id = history.id
|
184
|
+
result.push(
|
185
|
+
MonthHistory.new(
|
186
|
+
id: id, parent_id: history.parent_id, reference: history.reference,
|
187
|
+
western_date: history.western_date,
|
188
|
+
annotations: annotation_parser.specify(id: id),
|
189
|
+
diffs: history.diffs
|
190
|
+
)
|
185
191
|
)
|
186
|
-
|
187
|
-
end
|
192
|
+
end
|
188
193
|
|
189
|
-
|
190
|
-
end
|
191
|
-
private_class_method :add_annotations
|
192
|
-
|
193
|
-
def self.create_history_annnotations(history:, annotations: {}, relations: {})
|
194
|
-
history_id = history.id
|
195
|
-
history_annotations = []
|
196
|
-
[history_id, relations.fetch(history_id, '')].each do |id|
|
197
|
-
add_annotation(history_annotations: history_annotations,
|
198
|
-
annotations: annotations, id: id)
|
194
|
+
result
|
199
195
|
end
|
200
196
|
|
201
|
-
|
202
|
-
|
197
|
+
def create_history_annnotations(history:, annotations: {}, relations: {})
|
198
|
+
history_id = history.id
|
199
|
+
history_annotations = []
|
200
|
+
[history_id, relations.fetch(history_id, '')].each do |id|
|
201
|
+
add_annotation(history_annotations: history_annotations,
|
202
|
+
annotations: annotations, id: id)
|
203
|
+
end
|
203
204
|
|
204
|
-
|
205
|
-
|
206
|
-
return if annotation.invalid?
|
205
|
+
history_annotations
|
206
|
+
end
|
207
207
|
|
208
|
-
history_annotations
|
208
|
+
def add_annotation(history_annotations: [], annotations: {}, id: '')
|
209
|
+
annotation = annotations.fetch(id, Annotation.new)
|
210
|
+
return if annotation.invalid?
|
211
|
+
|
212
|
+
history_annotations.push(annotation)
|
213
|
+
end
|
209
214
|
end
|
210
|
-
private_class_method :add_annotation
|
211
215
|
end
|
212
216
|
|
213
217
|
#
|
@@ -236,31 +240,33 @@ module Zakuro
|
|
236
240
|
def create
|
237
241
|
@yaml_hash.each do |month|
|
238
242
|
AnnotationParser.resolve_history(
|
239
|
-
hash: month, annotations:
|
243
|
+
hash: month, annotations: annotations, relations: relations
|
240
244
|
)
|
241
245
|
end
|
242
246
|
end
|
243
247
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
id
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
248
|
+
class << self
|
249
|
+
#
|
250
|
+
# 月別履歴情報から注釈情報を取り出す
|
251
|
+
#
|
252
|
+
# @param [<Type>] hash 月別履歴情報yaml
|
253
|
+
# @param [Hash<String, Annotation>] annotations 注釈
|
254
|
+
# @param [Hash<String, String>] relations 関連注釈の対応関係
|
255
|
+
#
|
256
|
+
def resolve_history(hash: {}, annotations: {}, relations: {})
|
257
|
+
id = hash['id']
|
258
|
+
annotations[id] = Annotation.new(
|
259
|
+
id: id,
|
260
|
+
description: Operation::TypeParser.text(str: hash['description']),
|
261
|
+
note: Operation::TypeParser.text(str: hash['note'])
|
262
|
+
)
|
263
|
+
relation_id = hash['relation_id']
|
264
|
+
|
265
|
+
return if Operation::TypeParser.invalid?(str: relation_id)
|
266
|
+
|
267
|
+
relations[id] = relation_id
|
268
|
+
end
|
269
|
+
end
|
264
270
|
|
265
271
|
#
|
266
272
|
# 注釈を特定する
|
@@ -293,7 +299,7 @@ module Zakuro
|
|
293
299
|
end
|
294
300
|
|
295
301
|
def annotation(id: '')
|
296
|
-
|
302
|
+
annotations.fetch(id, Annotation.new)
|
297
303
|
end
|
298
304
|
end
|
299
305
|
|
@@ -301,73 +307,70 @@ module Zakuro
|
|
301
307
|
# MonthDiffsParser 月情報(差分)解析
|
302
308
|
#
|
303
309
|
module MonthDiffsParser
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
310
|
+
class << self
|
311
|
+
def create(yaml_hash: {})
|
312
|
+
Diffs.new(
|
313
|
+
month: create_month(yaml_hash: yaml_hash['month']),
|
314
|
+
solar_term: create_solar_term(yaml_hash: yaml_hash['solar_term']),
|
315
|
+
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
316
|
+
)
|
317
|
+
end
|
311
318
|
|
312
|
-
|
313
|
-
SolarTerm::Direction.new(
|
314
|
-
source: create_source_solar_term(yaml_hash: yaml_hash['src']),
|
315
|
-
destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
|
316
|
-
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
317
|
-
)
|
318
|
-
end
|
319
|
-
private_class_method :create_solar_term
|
320
|
-
|
321
|
-
def self.create_source_solar_term(yaml_hash: {})
|
322
|
-
SolarTerm::Source.new(
|
323
|
-
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
324
|
-
to: Operation::TypeParser.western_date(str: yaml_hash['to']),
|
325
|
-
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
326
|
-
)
|
327
|
-
end
|
328
|
-
private_class_method :create_source_solar_term
|
329
|
-
|
330
|
-
def self.create_destination_solar_term(yaml_hash: {})
|
331
|
-
SolarTerm::Destination.new(
|
332
|
-
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
333
|
-
from: Operation::TypeParser.western_date(str: yaml_hash['from']),
|
334
|
-
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
335
|
-
)
|
336
|
-
end
|
337
|
-
private_class_method :create_destination_solar_term
|
338
|
-
|
339
|
-
def self.create_month(yaml_hash: {})
|
340
|
-
Month.new(
|
341
|
-
number: create_month_number(yaml_hash: yaml_hash['number']),
|
342
|
-
leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
|
343
|
-
is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
|
344
|
-
)
|
345
|
-
end
|
346
|
-
private_class_method :create_month
|
319
|
+
private
|
347
320
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
321
|
+
def create_solar_term(yaml_hash: {})
|
322
|
+
SolarTerm::Direction.new(
|
323
|
+
source: create_source_solar_term(yaml_hash: yaml_hash['src']),
|
324
|
+
destination: create_destination_solar_term(yaml_hash: yaml_hash['dest']),
|
325
|
+
days: Operation::TypeParser.days(str: yaml_hash['days'])
|
326
|
+
)
|
327
|
+
end
|
355
328
|
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
329
|
+
def create_source_solar_term(yaml_hash: {})
|
330
|
+
SolarTerm::Source.new(
|
331
|
+
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
332
|
+
to: Operation::TypeParser.western_date(str: yaml_hash['to']),
|
333
|
+
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
334
|
+
)
|
335
|
+
end
|
363
336
|
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
337
|
+
def create_destination_solar_term(yaml_hash: {})
|
338
|
+
SolarTerm::Destination.new(
|
339
|
+
index: Operation::TypeParser.solar_term_index(str: yaml_hash['index']),
|
340
|
+
from: Operation::TypeParser.western_date(str: yaml_hash['from']),
|
341
|
+
zodiac_name: Operation::TypeParser.text(str: yaml_hash['zodiac_name'])
|
342
|
+
)
|
343
|
+
end
|
344
|
+
|
345
|
+
def create_month(yaml_hash: {})
|
346
|
+
Month.new(
|
347
|
+
number: create_month_number(yaml_hash: yaml_hash['number']),
|
348
|
+
leaped: create_month_leaped(yaml_hash: yaml_hash['leaped']),
|
349
|
+
is_many_days: create_month_day(yaml_hash: yaml_hash['days'])
|
350
|
+
)
|
351
|
+
end
|
352
|
+
|
353
|
+
def create_month_number(yaml_hash: {})
|
354
|
+
Number.new(
|
355
|
+
src: Operation::TypeParser.month_number(str: yaml_hash['src']),
|
356
|
+
dest: Operation::TypeParser.month_number(str: yaml_hash['dest'])
|
357
|
+
)
|
358
|
+
end
|
359
|
+
|
360
|
+
def create_month_leaped(yaml_hash: {})
|
361
|
+
Leaped.new(
|
362
|
+
src: Operation::TypeParser.month_leaped(str: yaml_hash['src']),
|
363
|
+
dest: Operation::TypeParser.month_leaped(str: yaml_hash['dest'])
|
364
|
+
)
|
365
|
+
end
|
366
|
+
|
367
|
+
def create_month_day(yaml_hash: {})
|
368
|
+
Days.new(
|
369
|
+
src: yaml_hash['src'],
|
370
|
+
dest: yaml_hash['dest']
|
371
|
+
)
|
372
|
+
end
|
369
373
|
end
|
370
|
-
private_class_method :create_month_day
|
371
374
|
end
|
372
375
|
end
|
373
376
|
end
|
@@ -250,7 +250,7 @@ module Zakuro
|
|
250
250
|
# @return [False] 有効
|
251
251
|
#
|
252
252
|
def invalid_days?
|
253
|
-
|
253
|
+
days == INVALID_DAY_VALUE
|
254
254
|
end
|
255
255
|
|
256
256
|
#
|
@@ -260,7 +260,7 @@ module Zakuro
|
|
260
260
|
# @return [False] 有効
|
261
261
|
#
|
262
262
|
def invalid?
|
263
|
-
|
263
|
+
source.invalid? && destination.invalid?
|
264
264
|
end
|
265
265
|
end
|
266
266
|
|
@@ -295,7 +295,7 @@ module Zakuro
|
|
295
295
|
# @return [False] 有効
|
296
296
|
#
|
297
297
|
def invalid?
|
298
|
-
|
298
|
+
index == -1
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
@@ -330,7 +330,7 @@ module Zakuro
|
|
330
330
|
# @return [False] 有効
|
331
331
|
#
|
332
332
|
def invalid?
|
333
|
-
|
333
|
+
index == -1
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
@@ -339,7 +339,7 @@ module Zakuro
|
|
339
339
|
# Number 月
|
340
340
|
#
|
341
341
|
class Number
|
342
|
-
# @return [Integer]
|
342
|
+
# @return [Integer] 移動元
|
343
343
|
attr_reader :src
|
344
344
|
# @return [Integer] 移動先
|
345
345
|
attr_reader :dest
|
@@ -362,7 +362,7 @@ module Zakuro
|
|
362
362
|
# @return [False] 有効
|
363
363
|
#
|
364
364
|
def invalid?
|
365
|
-
|
365
|
+
src == -1 || dest == -1
|
366
366
|
end
|
367
367
|
|
368
368
|
#
|
@@ -381,7 +381,7 @@ module Zakuro
|
|
381
381
|
# @return [Integer] 間隔
|
382
382
|
#
|
383
383
|
def interval
|
384
|
-
|
384
|
+
src - dest
|
385
385
|
end
|
386
386
|
|
387
387
|
#
|
@@ -453,7 +453,7 @@ module Zakuro
|
|
453
453
|
# @return [False] 有効
|
454
454
|
#
|
455
455
|
def invalid?
|
456
|
-
|
456
|
+
!src && !dest
|
457
457
|
end
|
458
458
|
end
|
459
459
|
|
@@ -466,6 +466,15 @@ module Zakuro
|
|
466
466
|
# @return [String] 30日
|
467
467
|
BIG = '大'
|
468
468
|
|
469
|
+
# NOTE: 下記readerは不要とする
|
470
|
+
# * Number/Leaped とメソッド名を揃えている
|
471
|
+
# * 大小の真偽値が必要で、文字列ではない
|
472
|
+
#
|
473
|
+
# @return [String] 移動元
|
474
|
+
# attr_reader :src
|
475
|
+
# @return [String] 移動先
|
476
|
+
# attr_reader :dest
|
477
|
+
|
469
478
|
#
|
470
479
|
# 初期化
|
471
480
|
#
|