zakuro 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +16 -3
- data/VERSION +1 -1
- data/lib/zakuro/calculation/base/gengou.rb +4 -4
- data/lib/zakuro/calculation/base/linear_gengou.rb +6 -6
- data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
- data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
- data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/list.rb +244 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/range.rb +193 -0
- data/lib/zakuro/calculation/{gengou → era/gengou}/internal/reserve.rb +6 -6
- data/lib/zakuro/calculation/{gengou → era/gengou}/scroll.rb +44 -95
- data/lib/zakuro/calculation/{version → era/version}/internal/crawler.rb +7 -7
- data/lib/zakuro/calculation/{version → era/version}/internal/range.rb +4 -4
- data/lib/zakuro/calculation/{version → era/version}/version.rb +3 -3
- data/lib/zakuro/calculation/monthly/month.rb +2 -2
- data/lib/zakuro/calculation/range/full_range.rb +18 -19
- data/lib/zakuro/calculation/range/operated_range.rb +3 -4
- data/lib/zakuro/calculation/specifier/internal/month.rb +84 -0
- data/lib/zakuro/calculation/specifier/multiple_day.rb +162 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +2 -2
- data/lib/zakuro/calculation/summary/internal/operation.rb +98 -0
- data/lib/zakuro/calculation/summary/range.rb +120 -0
- data/lib/zakuro/calculation/summary/single.rb +45 -67
- data/lib/zakuro/condition.rb +14 -0
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +106 -0
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +165 -0
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +156 -0
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +184 -0
- data/lib/zakuro/era/japan/gengou/alignment.rb +42 -0
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +242 -0
- data/lib/zakuro/era/japan/gengou/resource/type.rb +292 -0
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +346 -0
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-001-until-south.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-002-from-north.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/{yaml → resource/yaml}/set-003-modern.yaml +2 -2
- data/lib/zakuro/era/japan/gengou/resource.rb +32 -0
- data/lib/zakuro/era/japan/gengou.rb +34 -73
- data/lib/zakuro/era/japan/version.rb +18 -18
- data/lib/zakuro/merchant.rb +41 -3
- data/lib/zakuro/operation/month/validator.rb +1 -1
- data/lib/zakuro/result/result.rb +17 -0
- data/lib/zakuro/version/senmyou/README.md +11 -7
- metadata +32 -20
- data/lib/zakuro/calculation/gengou/internal/counter.rb +0 -129
- data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +0 -183
- data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +0 -382
- data/lib/zakuro/era/japan/gengou/parser.rb +0 -237
- data/lib/zakuro/era/japan/gengou/type.rb +0 -285
- data/lib/zakuro/era/japan/gengou/validator.rb +0 -341
@@ -1,341 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative '../../japan/calendar'
|
4
|
-
require_relative '../../western/calendar'
|
5
|
-
require_relative './type'
|
6
|
-
require 'yaml'
|
7
|
-
|
8
|
-
# :nodoc:
|
9
|
-
module Zakuro
|
10
|
-
#
|
11
|
-
# Japan 和暦
|
12
|
-
#
|
13
|
-
module Japan
|
14
|
-
#
|
15
|
-
# Validator yaml解析
|
16
|
-
#
|
17
|
-
module Validator
|
18
|
-
#
|
19
|
-
# Set 元号セット情報の検証/展開
|
20
|
-
#
|
21
|
-
class Set
|
22
|
-
# @return [String] 元号セットID
|
23
|
-
attr_reader :id
|
24
|
-
# @return [String] 元号セット名
|
25
|
-
attr_reader :name
|
26
|
-
# @return [Hash<String, String>] 終了年
|
27
|
-
attr_reader :both_end_year
|
28
|
-
# @return [Hash<String, String>] 終了日
|
29
|
-
attr_reader :both_end_date
|
30
|
-
# @return [Array<Hash<String, String>>] 元号情報
|
31
|
-
attr_reader :list
|
32
|
-
|
33
|
-
#
|
34
|
-
# 初期化
|
35
|
-
#
|
36
|
-
# @param [Hash<String, Object>] hash 元号セット情報
|
37
|
-
#
|
38
|
-
def initialize(hash:)
|
39
|
-
@id = hash['id']
|
40
|
-
@name = hash['name']
|
41
|
-
@both_end_year = hash['end_year']
|
42
|
-
@both_end_date = hash['end_date']
|
43
|
-
@list = hash['list']
|
44
|
-
end
|
45
|
-
|
46
|
-
#
|
47
|
-
# 検証する
|
48
|
-
#
|
49
|
-
# @return [Array<String>] 不正メッセージ
|
50
|
-
#
|
51
|
-
def validate
|
52
|
-
failed = []
|
53
|
-
failed.push("invalid id. #{@id}") unless id?
|
54
|
-
|
55
|
-
failed.push("invalid name. #{@name}") unless name?
|
56
|
-
|
57
|
-
failed |= validate_both_end_year
|
58
|
-
|
59
|
-
failed |= validate_both_end_date
|
60
|
-
|
61
|
-
failed |= validate_list
|
62
|
-
failed
|
63
|
-
end
|
64
|
-
|
65
|
-
#
|
66
|
-
# IDを検証する
|
67
|
-
#
|
68
|
-
# @return [True] 正しい
|
69
|
-
# @return [False] 正しくない
|
70
|
-
#
|
71
|
-
def id?
|
72
|
-
return false unless @id
|
73
|
-
|
74
|
-
@id.is_a?(Integer)
|
75
|
-
end
|
76
|
-
|
77
|
-
#
|
78
|
-
# 元号セット名を検証する
|
79
|
-
#
|
80
|
-
# @return [True] 正しい
|
81
|
-
# @return [False] 正しくない
|
82
|
-
#
|
83
|
-
def name?
|
84
|
-
return false unless @name
|
85
|
-
|
86
|
-
@name.is_a?(String)
|
87
|
-
end
|
88
|
-
|
89
|
-
#
|
90
|
-
# 終了年を検証する
|
91
|
-
#
|
92
|
-
# @return [Array<String>] 不正メッセージ
|
93
|
-
#
|
94
|
-
def validate_both_end_year
|
95
|
-
Both::Year.new(hash: @both_end_year).validate
|
96
|
-
end
|
97
|
-
|
98
|
-
#
|
99
|
-
# 終了日を検証する
|
100
|
-
#
|
101
|
-
# @return [Array<String>] 不正メッセージ
|
102
|
-
#
|
103
|
-
def validate_both_end_date
|
104
|
-
Both::Date.new(hash: @both_end_date).validate
|
105
|
-
end
|
106
|
-
|
107
|
-
#
|
108
|
-
# 元号情報を検証する
|
109
|
-
#
|
110
|
-
# @return [True] 正しい
|
111
|
-
# @return [False] 正しくない
|
112
|
-
#
|
113
|
-
def list?
|
114
|
-
return false unless @list
|
115
|
-
|
116
|
-
@list.is_a?(Array)
|
117
|
-
end
|
118
|
-
|
119
|
-
#
|
120
|
-
# 元号情報を検証する
|
121
|
-
#
|
122
|
-
# @return [Array<String>] 不正メッセージ
|
123
|
-
#
|
124
|
-
def validate_list
|
125
|
-
return ["invalid list. #{@list.class}"] unless list?
|
126
|
-
|
127
|
-
failed = []
|
128
|
-
list.each_with_index do |li, index|
|
129
|
-
failed |= Gengou.new(hash: li, index: index).validate
|
130
|
-
end
|
131
|
-
failed
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
#
|
136
|
-
# Gengou 元号情報
|
137
|
-
#
|
138
|
-
class Gengou
|
139
|
-
# @return [Integer] 要素位置
|
140
|
-
attr_reader :index
|
141
|
-
# @return [String] 元号名
|
142
|
-
attr_reader :name
|
143
|
-
# @return [Hash<String, String>] 開始年
|
144
|
-
attr_reader :both_start_year
|
145
|
-
# @return [Hash<String, String>] 開始日
|
146
|
-
attr_reader :both_start_date
|
147
|
-
|
148
|
-
#
|
149
|
-
# 初期化
|
150
|
-
#
|
151
|
-
# @param [Hash<String, Strin>] hash 元号情報
|
152
|
-
# @param [Integer] index (元号セット内での)元号の要素位置
|
153
|
-
#
|
154
|
-
def initialize(hash:, index:)
|
155
|
-
@index = index
|
156
|
-
@name = hash['name']
|
157
|
-
@both_start_year = hash['start_year']
|
158
|
-
@both_start_date = hash['start_date']
|
159
|
-
end
|
160
|
-
|
161
|
-
#
|
162
|
-
# 検証する
|
163
|
-
#
|
164
|
-
# @return [Array<String>] 不正メッセージ
|
165
|
-
#
|
166
|
-
def validate
|
167
|
-
prefix = "list[#{index}]. "
|
168
|
-
failed = []
|
169
|
-
|
170
|
-
failed.push(prefix + "invalid name. #{@name}") unless name?
|
171
|
-
|
172
|
-
failed |= validate_both_start_year
|
173
|
-
|
174
|
-
failed |= validate_both_start_date
|
175
|
-
|
176
|
-
failed
|
177
|
-
end
|
178
|
-
|
179
|
-
#
|
180
|
-
# 元号名を検証する
|
181
|
-
#
|
182
|
-
# @return [True] 正しい
|
183
|
-
# @return [False] 正しくない
|
184
|
-
#
|
185
|
-
def name?
|
186
|
-
return false unless @name
|
187
|
-
|
188
|
-
@name.is_a?(String)
|
189
|
-
end
|
190
|
-
|
191
|
-
#
|
192
|
-
# 開始年を検証する
|
193
|
-
#
|
194
|
-
# @return [Array<String>] 不正メッセージ
|
195
|
-
#
|
196
|
-
def validate_both_start_year
|
197
|
-
Both::Year.new(hash: @both_start_year).validate
|
198
|
-
end
|
199
|
-
|
200
|
-
#
|
201
|
-
# 開始日を検証する
|
202
|
-
#
|
203
|
-
# @return [Array<String>] 不正メッセージ
|
204
|
-
#
|
205
|
-
def validate_both_start_date
|
206
|
-
Both::Date.new(hash: @both_start_date).validate
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
#
|
211
|
-
# 和暦/西暦
|
212
|
-
#
|
213
|
-
module Both
|
214
|
-
#
|
215
|
-
# Year 年
|
216
|
-
#
|
217
|
-
class Year
|
218
|
-
# @return [String] 和暦元号年
|
219
|
-
attr_reader :japan
|
220
|
-
# @return [String] 西暦年
|
221
|
-
attr_reader :western
|
222
|
-
|
223
|
-
#
|
224
|
-
# 初期化
|
225
|
-
#
|
226
|
-
# @param [Hash<String, Strin>] hash 年情報
|
227
|
-
#
|
228
|
-
def initialize(hash:)
|
229
|
-
@japan = hash['japan']
|
230
|
-
@western = hash['western']
|
231
|
-
end
|
232
|
-
|
233
|
-
#
|
234
|
-
# 検証する
|
235
|
-
#
|
236
|
-
# @return [Array<String>] 不正メッセージ
|
237
|
-
#
|
238
|
-
def validate
|
239
|
-
failed = []
|
240
|
-
|
241
|
-
failed.push("invalid japan year. #{@japan}") unless japan?
|
242
|
-
|
243
|
-
failed.push("invalid western year. #{@western}") unless western?
|
244
|
-
|
245
|
-
failed
|
246
|
-
end
|
247
|
-
|
248
|
-
#
|
249
|
-
# 和暦元号年を検証する
|
250
|
-
#
|
251
|
-
# @return [True] 正しい
|
252
|
-
# @return [False] 正しくない
|
253
|
-
#
|
254
|
-
def japan?
|
255
|
-
return false unless @japan
|
256
|
-
|
257
|
-
@japan.is_a?(Integer)
|
258
|
-
end
|
259
|
-
|
260
|
-
#
|
261
|
-
# 和暦元号年を検証する
|
262
|
-
#
|
263
|
-
# @return [True] 正しい
|
264
|
-
# @return [False] 正しくない
|
265
|
-
#
|
266
|
-
def western?
|
267
|
-
return false unless @western
|
268
|
-
|
269
|
-
@western.is_a?(Integer)
|
270
|
-
end
|
271
|
-
end
|
272
|
-
|
273
|
-
#
|
274
|
-
# Date 日
|
275
|
-
#
|
276
|
-
class Date
|
277
|
-
# @return [String] 和暦日
|
278
|
-
attr_reader :japan
|
279
|
-
# @return [String] 西暦日
|
280
|
-
attr_reader :western
|
281
|
-
|
282
|
-
#
|
283
|
-
# 初期化
|
284
|
-
#
|
285
|
-
# @param [Hash<String, Strin>] hash 日情報
|
286
|
-
#
|
287
|
-
def initialize(hash:)
|
288
|
-
@japan = hash['japan']
|
289
|
-
@western = hash['western']
|
290
|
-
end
|
291
|
-
|
292
|
-
#
|
293
|
-
# 検証する
|
294
|
-
#
|
295
|
-
# @return [Array<String>] 不正メッセージ
|
296
|
-
#
|
297
|
-
def validate
|
298
|
-
failed = []
|
299
|
-
|
300
|
-
failed.push("invalid japan date. #{@japan}") unless japan?
|
301
|
-
|
302
|
-
failed.push("invalid western date. #{@western}") unless western?
|
303
|
-
|
304
|
-
failed
|
305
|
-
end
|
306
|
-
|
307
|
-
#
|
308
|
-
# 和暦日を検証する
|
309
|
-
#
|
310
|
-
# @return [True] 正しい
|
311
|
-
# @return [False] 正しくない
|
312
|
-
#
|
313
|
-
def japan?
|
314
|
-
Japan::Calendar.valid_date_string(text: @japan)
|
315
|
-
end
|
316
|
-
|
317
|
-
#
|
318
|
-
# 西暦日を検証する
|
319
|
-
#
|
320
|
-
# @return [True] 正しい
|
321
|
-
# @return [False] 正しくない
|
322
|
-
#
|
323
|
-
def western?
|
324
|
-
Western::Calendar.valid_date_string(str: @western)
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
#
|
330
|
-
# 検証する
|
331
|
-
#
|
332
|
-
# @param [Hash<String, Object>] yaml_hash yaml取得結果
|
333
|
-
#
|
334
|
-
# @return [Array<String>] 不正メッセージ
|
335
|
-
#
|
336
|
-
def self.run(yaml_hash:)
|
337
|
-
Set.new(hash: yaml_hash).validate
|
338
|
-
end
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|