zakuro 0.2.0 → 0.6.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 +17 -1
- data/VERSION +1 -0
- data/doc/gengou.md +22 -22
- data/doc/operation/csv/month.csv +468 -202
- data/doc/operation/operation.xlsx +0 -0
- data/lib/zakuro/calculation/base/gengou.rb +82 -0
- data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
- data/lib/zakuro/calculation/base/operated_year.rb +104 -0
- data/lib/zakuro/calculation/base/year.rb +28 -13
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +29 -29
- data/lib/zakuro/calculation/gengou/internal/counter.rb +129 -0
- data/lib/zakuro/calculation/gengou/internal/reserve/interval.rb +183 -0
- data/lib/zakuro/calculation/gengou/internal/reserve/list.rb +382 -0
- data/lib/zakuro/calculation/gengou/internal/reserve.rb +42 -0
- data/lib/zakuro/calculation/gengou/scroll.rb +262 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
- data/lib/zakuro/calculation/monthly/month.rb +49 -2
- data/lib/zakuro/calculation/monthly/operated_month.rb +49 -5
- data/lib/zakuro/calculation/range/full_range.rb +65 -103
- data/lib/zakuro/calculation/range/operated_range.rb +73 -23
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -17
- data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
- data/lib/zakuro/calculation/specifier/single_day.rb +13 -35
- data/lib/zakuro/calculation/stella/lunar/abstract_location.rb +9 -7
- data/lib/zakuro/calculation/stella/lunar/choukei_value.rb +19 -0
- data/lib/zakuro/calculation/summary/single.rb +5 -2
- data/lib/zakuro/calculation/version/internal/crawler.rb +51 -0
- data/lib/zakuro/calculation/version/internal/range.rb +39 -0
- data/lib/zakuro/calculation/version/version.rb +24 -0
- data/lib/zakuro/era/japan/calendar.rb +133 -0
- data/lib/zakuro/era/japan/gengou/parser.rb +95 -25
- data/lib/zakuro/era/japan/gengou/type.rb +148 -41
- data/lib/zakuro/era/japan/gengou/validator.rb +157 -52
- data/lib/zakuro/era/japan/gengou/yaml/set-001-until-south.yaml +1870 -0
- data/lib/zakuro/era/japan/gengou/yaml/set-002-from-north.yaml +810 -0
- data/lib/zakuro/era/japan/gengou/yaml/set-003-modern.yaml +50 -0
- data/lib/zakuro/era/japan/gengou.rb +5 -5
- data/lib/zakuro/era/japan/version.rb +151 -0
- data/lib/zakuro/era/{western.rb → western/calendar.rb} +0 -0
- data/lib/zakuro/merchant.rb +12 -3
- data/lib/zakuro/operation/month/parser.rb +1 -1
- data/lib/zakuro/operation/month/type.rb +59 -1
- data/lib/zakuro/operation/month/validator.rb +1 -1
- data/lib/zakuro/operation/yaml/month.yaml +8512 -0
- data/lib/zakuro/output/response.rb +5 -5
- data/lib/zakuro/tools/typeconv.rb +38 -0
- data/lib/zakuro/tools/typeof.rb +4 -1
- data/lib/zakuro/version/context.rb +25 -4
- data/lib/zakuro/version/daien/const/number.rb +55 -0
- data/lib/zakuro/version/daien/const/remainder.rb +53 -0
- data/lib/zakuro/version/daien/cycle/remainder.rb +85 -0
- data/lib/zakuro/version/daien/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/daien/daien.rb +11 -0
- data/lib/zakuro/version/daien/monthly/lunar_phase.rb +106 -0
- data/lib/zakuro/version/daien/range/annual_range.rb +39 -0
- data/lib/zakuro/version/daien/stella/lunar/adjustment.rb +240 -0
- data/lib/zakuro/version/daien/stella/lunar/localization.rb +44 -0
- data/lib/zakuro/version/daien/stella/lunar/location.rb +80 -0
- data/lib/zakuro/version/daien/stella/lunar/value.rb +75 -0
- data/lib/zakuro/version/daien/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/daien/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/daien/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/daien/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/daien/stella/solar/average.rb +98 -0
- data/lib/zakuro/version/daien/stella/solar/interval.rb +108 -0
- data/lib/zakuro/version/daien/stella/solar/location.rb +61 -0
- data/lib/zakuro/version/daien/stella/solar/value.rb +36 -0
- data/lib/zakuro/version/genka/const/number.rb +43 -0
- data/lib/zakuro/version/genka/const/remainder.rb +33 -0
- data/lib/zakuro/version/genka/cycle/remainder.rb +92 -0
- data/lib/zakuro/version/genka/cycle/solar_term.rb +34 -0
- data/lib/zakuro/version/genka/genka.rb +1 -9
- data/lib/zakuro/version/genka/monthly/lunar_phase.rb +95 -0
- data/lib/zakuro/version/genka/range/annual_range.rb +77 -0
- data/lib/zakuro/version/genka/stella/origin/first_term.rb +55 -0
- data/lib/zakuro/version/genka/stella/origin/january.rb +49 -0
- data/lib/zakuro/version/genka/stella/solar/average.rb +41 -0
- data/lib/zakuro/version/gihou/const/remainder.rb +0 -2
- data/lib/zakuro/version/gihou/cycle/remainder.rb +27 -6
- data/lib/zakuro/version/gihou/gihou.rb +1 -30
- data/lib/zakuro/version/gihou/monthly/lunar_phase.rb +1 -1
- data/lib/zakuro/version/gihou/stella/lunar/location.rb +2 -8
- data/lib/zakuro/version/gihou/stella/lunar/value.rb +3 -2
- data/lib/zakuro/version/gihou/stella/solar/average.rb +3 -3
- data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
- data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
- data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
- data/lib/zakuro/version/kansei/kansei.rb +1 -9
- data/lib/zakuro/version/senmyou/const/remainder.rb +0 -2
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +27 -6
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +1 -1
- data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +2 -8
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +3 -2
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +3 -3
- data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
- data/lib/zakuro/version/version_class_resolver.rb +8 -0
- data/zakuro.gemspec +1 -3
- metadata +50 -14
- data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
- data/lib/zakuro/era/japan/reki.rb +0 -91
- data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
- data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
- data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
- data/lib/zakuro/version/abstract_version.rb +0 -29
- data/lib/zakuro/version/taien/taien.rb +0 -19
- data/lib/zakuro/version.rb +0 -7
- data/lib/zakuro/version_factory.rb +0 -59
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../
|
3
|
+
require_relative '../../japan/calendar'
|
4
|
+
require_relative '../../western/calendar'
|
4
5
|
require_relative './type'
|
5
6
|
require 'yaml'
|
6
7
|
|
@@ -14,8 +15,6 @@ module Zakuro
|
|
14
15
|
# Validator yaml解析
|
15
16
|
#
|
16
17
|
module Validator
|
17
|
-
# :reek:TooManyInstanceVariables { max_instance_variables: 5 }
|
18
|
-
|
19
18
|
#
|
20
19
|
# Set 元号セット情報の検証/展開
|
21
20
|
#
|
@@ -24,8 +23,10 @@ module Zakuro
|
|
24
23
|
attr_reader :id
|
25
24
|
# @return [String] 元号セット名
|
26
25
|
attr_reader :name
|
27
|
-
# @return [String]
|
28
|
-
attr_reader :
|
26
|
+
# @return [Hash<String, String>] 終了年
|
27
|
+
attr_reader :both_end_year
|
28
|
+
# @return [Hash<String, String>] 終了日
|
29
|
+
attr_reader :both_end_date
|
29
30
|
# @return [Array<Hash<String, String>>] 元号情報
|
30
31
|
attr_reader :list
|
31
32
|
|
@@ -37,12 +38,11 @@ module Zakuro
|
|
37
38
|
def initialize(hash:)
|
38
39
|
@id = hash['id']
|
39
40
|
@name = hash['name']
|
40
|
-
@
|
41
|
+
@both_end_year = hash['end_year']
|
42
|
+
@both_end_date = hash['end_date']
|
41
43
|
@list = hash['list']
|
42
44
|
end
|
43
45
|
|
44
|
-
# :reek:TooManyStatements { max_statements: 6 }
|
45
|
-
|
46
46
|
#
|
47
47
|
# 検証する
|
48
48
|
#
|
@@ -50,11 +50,13 @@ module Zakuro
|
|
50
50
|
#
|
51
51
|
def validate
|
52
52
|
failed = []
|
53
|
-
failed.push("invalid id. #{id}") unless id?
|
53
|
+
failed.push("invalid id. #{@id}") unless id?
|
54
54
|
|
55
|
-
failed.push("invalid name. #{name}") unless name?
|
55
|
+
failed.push("invalid name. #{@name}") unless name?
|
56
56
|
|
57
|
-
failed
|
57
|
+
failed |= validate_both_end_year
|
58
|
+
|
59
|
+
failed |= validate_both_end_date
|
58
60
|
|
59
61
|
failed |= validate_list
|
60
62
|
failed
|
@@ -85,13 +87,21 @@ module Zakuro
|
|
85
87
|
end
|
86
88
|
|
87
89
|
#
|
88
|
-
#
|
90
|
+
# 終了年を検証する
|
89
91
|
#
|
90
|
-
# @return [
|
91
|
-
#
|
92
|
+
# @return [Array<String>] 不正メッセージ
|
93
|
+
#
|
94
|
+
def validate_both_end_year
|
95
|
+
Both::Year.new(hash: @both_end_year).validate
|
96
|
+
end
|
97
|
+
|
92
98
|
#
|
93
|
-
|
94
|
-
|
99
|
+
# 終了日を検証する
|
100
|
+
#
|
101
|
+
# @return [Array<String>] 不正メッセージ
|
102
|
+
#
|
103
|
+
def validate_both_end_date
|
104
|
+
Both::Date.new(hash: @both_end_date).validate
|
95
105
|
end
|
96
106
|
|
97
107
|
#
|
@@ -109,8 +119,7 @@ module Zakuro
|
|
109
119
|
#
|
110
120
|
# 元号情報を検証する
|
111
121
|
#
|
112
|
-
# @return [
|
113
|
-
# @return [False] 正しくない
|
122
|
+
# @return [Array<String>] 不正メッセージ
|
114
123
|
#
|
115
124
|
def validate_list
|
116
125
|
return ["invalid list. #{@list.class}"] unless list?
|
@@ -123,8 +132,6 @@ module Zakuro
|
|
123
132
|
end
|
124
133
|
end
|
125
134
|
|
126
|
-
# :reek:TooManyInstanceVariables { max_instance_variables: 5 }
|
127
|
-
|
128
135
|
#
|
129
136
|
# Gengou 元号情報
|
130
137
|
#
|
@@ -133,12 +140,10 @@ module Zakuro
|
|
133
140
|
attr_reader :index
|
134
141
|
# @return [String] 元号名
|
135
142
|
attr_reader :name
|
136
|
-
# @return [String]
|
137
|
-
attr_reader :
|
138
|
-
# @return [String]
|
139
|
-
attr_reader :
|
140
|
-
# @return [String] 開始年
|
141
|
-
attr_reader :start_year
|
143
|
+
# @return [Hash<String, String>] 開始年
|
144
|
+
attr_reader :both_start_year
|
145
|
+
# @return [Hash<String, String>] 開始日
|
146
|
+
attr_reader :both_start_date
|
142
147
|
|
143
148
|
#
|
144
149
|
# 初期化
|
@@ -149,13 +154,10 @@ module Zakuro
|
|
149
154
|
def initialize(hash:, index:)
|
150
155
|
@index = index
|
151
156
|
@name = hash['name']
|
152
|
-
@
|
153
|
-
@
|
154
|
-
@start_year = hash['start_year']
|
157
|
+
@both_start_year = hash['start_year']
|
158
|
+
@both_start_date = hash['start_date']
|
155
159
|
end
|
156
160
|
|
157
|
-
# :reek:TooManyStatements { max_statements: 7 }
|
158
|
-
|
159
161
|
#
|
160
162
|
# 検証する
|
161
163
|
#
|
@@ -167,11 +169,9 @@ module Zakuro
|
|
167
169
|
|
168
170
|
failed.push(prefix + "invalid name. #{@name}") unless name?
|
169
171
|
|
170
|
-
failed
|
171
|
-
|
172
|
-
failed.push(prefix + "invalid start_year. #{@start_year}") unless year?
|
172
|
+
failed |= validate_both_start_year
|
173
173
|
|
174
|
-
failed
|
174
|
+
failed |= validate_both_start_date
|
175
175
|
|
176
176
|
failed
|
177
177
|
end
|
@@ -189,35 +189,140 @@ module Zakuro
|
|
189
189
|
end
|
190
190
|
|
191
191
|
#
|
192
|
-
#
|
192
|
+
# 開始年を検証する
|
193
193
|
#
|
194
|
-
# @return [
|
195
|
-
# @return [False] 正しくない
|
194
|
+
# @return [Array<String>] 不正メッセージ
|
196
195
|
#
|
197
|
-
def
|
198
|
-
|
196
|
+
def validate_both_start_year
|
197
|
+
Both::Year.new(hash: @both_start_year).validate
|
199
198
|
end
|
200
199
|
|
201
200
|
#
|
202
|
-
#
|
201
|
+
# 開始日を検証する
|
203
202
|
#
|
204
|
-
# @return [
|
205
|
-
# @return [False] 正しくない
|
203
|
+
# @return [Array<String>] 不正メッセージ
|
206
204
|
#
|
207
|
-
def
|
208
|
-
|
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
|
209
271
|
end
|
210
272
|
|
211
273
|
#
|
212
|
-
#
|
213
|
-
#
|
214
|
-
# @return [True] 正しい
|
215
|
-
# @return [False] 正しくない
|
274
|
+
# Date 日
|
216
275
|
#
|
217
|
-
|
218
|
-
return
|
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?
|
219
301
|
|
220
|
-
|
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
|
221
326
|
end
|
222
327
|
end
|
223
328
|
|