zakuro 0.6.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Makefile +3 -0
- data/README.md +46 -17
- data/VERSION +1 -1
- data/doc/dropped_date.md +93 -0
- data/doc/error.md +45 -0
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/day.rb +52 -0
- data/lib/zakuro/calculation/base/gengou.rb +49 -3
- 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/{scroll.rb → abstract_scroll.rb} +44 -37
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- 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/{list.rb → abstract_list.rb} +50 -64
- data/lib/zakuro/calculation/era/gengou/internal/reserve/{range.rb → abstract_range.rb} +73 -50
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +156 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +73 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +23 -22
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- 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 +55 -16
- 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/{full_range.rb → abstract_full_range.rb} +45 -29
- data/lib/zakuro/calculation/range/abstract_operation_range.rb +193 -0
- data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
- data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
- data/lib/zakuro/calculation/range/medieval_annual_range.rb +64 -63
- data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
- data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
- 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/{specifier → summary}/internal/month.rb +33 -12
- 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 +179 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +98 -0
- data/lib/zakuro/calculation/summary/japan/specifier/specified_range.rb +34 -0
- data/lib/zakuro/calculation/summary/western/range.rb +127 -0
- data/lib/zakuro/calculation/summary/western/single.rb +115 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +173 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +100 -0
- data/lib/zakuro/calculation/type/old_float.rb +2 -2
- data/lib/zakuro/calculation/type/optional.rb +46 -0
- data/lib/zakuro/condition.rb +143 -94
- 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 +93 -74
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +135 -133
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +143 -122
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +177 -168
- data/lib/zakuro/era/japan/gengou/alignment.rb +40 -25
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +199 -181
- data/lib/zakuro/era/japan/gengou/resource/type.rb +243 -234
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +257 -254
- data/lib/zakuro/era/japan/gengou/resource.rb +23 -22
- data/lib/zakuro/era/japan/gengou.rb +28 -41
- 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 +71 -0
- data/lib/zakuro/exception/case/preset.rb +51 -0
- data/lib/zakuro/exception/case/template.rb +48 -0
- data/lib/zakuro/exception/cause.rb +28 -0
- data/lib/zakuro/exception/exception.rb +39 -0
- data/lib/zakuro/exception/zakuro_error.rb +46 -0
- data/lib/zakuro/gateway/locale/date.rb +127 -0
- data/lib/zakuro/gateway/locale/range.rb +67 -0
- data/lib/zakuro/gateway/range.rb +99 -0
- data/lib/zakuro/gateway/single.rb +81 -0
- data/lib/zakuro/merchant.rb +67 -33
- data/lib/zakuro/operation/month/parser.rb +252 -249
- data/lib/zakuro/operation/month/type.rb +44 -35
- data/lib/zakuro/operation/month/validator.rb +182 -178
- data/lib/zakuro/operation/operation.rb +38 -36
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/output/response.rb +107 -141
- data/lib/zakuro/result/data/day.rb +43 -0
- data/lib/zakuro/result/data/gengou.rb +35 -0
- data/lib/zakuro/result/data/month.rb +63 -0
- 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 +56 -0
- data/lib/zakuro/result/data/solar_term.rb +35 -0
- data/lib/zakuro/result/data/year.rb +45 -0
- data/lib/zakuro/result/operation/month/annotation.rb +40 -0
- data/lib/zakuro/result/operation/month/history.rb +54 -0
- data/lib/zakuro/result/operation/month.rb +31 -0
- data/lib/zakuro/result/operation.rb +22 -97
- data/lib/zakuro/result/result.rb +6 -4
- 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 +5 -0
- 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 +68 -16
- data/lib/zakuro/calculation/range/operated_range.rb +0 -193
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +0 -220
- data/lib/zakuro/calculation/specifier/multiple_day.rb +0 -162
- data/lib/zakuro/calculation/specifier/single_day.rb +0 -87
- data/lib/zakuro/calculation/summary/range.rb +0 -120
- data/lib/zakuro/calculation/summary/single.rb +0 -110
- data/lib/zakuro/result/data.rb +0 -187
- data/lib/zakuro/version/context.rb +0 -44
- data/lib/zakuro/version/version_class_resolver.rb +0 -74
@@ -20,122 +20,124 @@ module Zakuro
|
|
20
20
|
EMPTY_STRING = '-'
|
21
21
|
BOOLEANS = %w[true false].freeze
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
23
|
+
class << self
|
24
|
+
#
|
25
|
+
# 有効文字列か
|
26
|
+
#
|
27
|
+
# @param [String] str 対象文字列
|
28
|
+
#
|
29
|
+
# @return [True] 有効
|
30
|
+
# @return [False] 無効
|
31
|
+
#
|
32
|
+
def string?(str: '')
|
33
|
+
return false if str == ''
|
33
34
|
|
34
|
-
|
35
|
+
return false unless str
|
35
36
|
|
36
|
-
|
37
|
-
|
37
|
+
str.is_a?(String)
|
38
|
+
end
|
38
39
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
40
|
+
#
|
41
|
+
# 有効文字列(空文字許容)か
|
42
|
+
#
|
43
|
+
# @param [String] str 対象文字列
|
44
|
+
#
|
45
|
+
# @return [True] 有効
|
46
|
+
# @return [False] 無効
|
47
|
+
#
|
48
|
+
def empiable_string?(str: '')
|
49
|
+
return false unless str
|
49
50
|
|
50
|
-
|
51
|
-
|
51
|
+
str.is_a?(String)
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
54
|
+
#
|
55
|
+
# 正数か
|
56
|
+
#
|
57
|
+
# @param [String] str 対象文字列
|
58
|
+
#
|
59
|
+
# @return [True] 正数
|
60
|
+
# @return [False] 負数
|
61
|
+
#
|
62
|
+
def positive?(str: '')
|
63
|
+
return true if str == EMPTY_STRING
|
63
64
|
|
64
|
-
|
65
|
+
return false unless str
|
65
66
|
|
66
|
-
|
67
|
-
|
67
|
+
/^[0-9]+$/.match?(str)
|
68
|
+
end
|
68
69
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
70
|
+
#
|
71
|
+
# 数値か
|
72
|
+
#
|
73
|
+
# @param [String] str 対象文字列
|
74
|
+
#
|
75
|
+
# @return [True] 数値
|
76
|
+
# @return [False] 非数値
|
77
|
+
#
|
78
|
+
def num?(str: '')
|
79
|
+
return true if str == EMPTY_STRING
|
79
80
|
|
80
|
-
|
81
|
+
return false unless str
|
81
82
|
|
82
|
-
|
83
|
-
|
83
|
+
/^[-0-9]+$/.match?(str)
|
84
|
+
end
|
84
85
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
86
|
+
#
|
87
|
+
# booleanか
|
88
|
+
#
|
89
|
+
# @param [String] str 対象文字列
|
90
|
+
#
|
91
|
+
# @return [True] boolean
|
92
|
+
# @return [False] 非boolean
|
93
|
+
#
|
94
|
+
def bool?(str: '')
|
95
|
+
BOOLEANS.include?(str)
|
96
|
+
end
|
96
97
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
98
|
+
#
|
99
|
+
# boolean(空許容)か
|
100
|
+
#
|
101
|
+
# @param [String] str 対象文字列
|
102
|
+
#
|
103
|
+
# @return [True] boolean
|
104
|
+
# @return [False] 非boolean
|
105
|
+
#
|
106
|
+
def empiable_bool?(str: '')
|
107
|
+
return true if str == EMPTY_STRING
|
107
108
|
|
108
|
-
|
109
|
-
|
109
|
+
bool?(str: str)
|
110
|
+
end
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
112
|
+
#
|
113
|
+
# 月差分か
|
114
|
+
#
|
115
|
+
# @param [String] str 対象文字列
|
116
|
+
#
|
117
|
+
# @return [True] 有効
|
118
|
+
# @return [False] 無効
|
119
|
+
#
|
120
|
+
def month_days?(str: '')
|
121
|
+
return true if str == EMPTY_STRING
|
121
122
|
|
122
|
-
|
123
|
+
return false unless str
|
123
124
|
|
124
|
-
|
125
|
-
|
125
|
+
/^[大小]$/.match?(str)
|
126
|
+
end
|
126
127
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
128
|
+
#
|
129
|
+
# 西暦日か
|
130
|
+
#
|
131
|
+
# @param [String] str 対象文字列
|
132
|
+
#
|
133
|
+
# @return [True] 有効
|
134
|
+
# @return [False] 無効
|
135
|
+
#
|
136
|
+
def western_date?(str: '')
|
137
|
+
return Western::Calendar.new if str == EMPTY_STRING
|
137
138
|
|
138
|
-
|
139
|
+
Western::Calendar.valid_date_string(text: str)
|
140
|
+
end
|
139
141
|
end
|
140
142
|
end
|
141
143
|
|
@@ -381,9 +383,9 @@ module Zakuro
|
|
381
383
|
|
382
384
|
prefix = "[#{@index}] invalid"
|
383
385
|
|
384
|
-
failed +=
|
386
|
+
failed += month.validate
|
385
387
|
|
386
|
-
failed +=
|
388
|
+
failed += solar_term.validate
|
387
389
|
|
388
390
|
failed.push("#{prefix} 'days'. #{@days}") unless days?
|
389
391
|
|
@@ -432,11 +434,11 @@ module Zakuro
|
|
432
434
|
def validate
|
433
435
|
failed = []
|
434
436
|
|
435
|
-
failed +=
|
437
|
+
failed += number.validate
|
436
438
|
|
437
|
-
failed +=
|
439
|
+
failed += leaped.validate
|
438
440
|
|
439
|
-
failed +=
|
441
|
+
failed += days.validate
|
440
442
|
|
441
443
|
failed
|
442
444
|
end
|
@@ -461,19 +463,19 @@ module Zakuro
|
|
461
463
|
#
|
462
464
|
# @param [Integer] index 連番
|
463
465
|
# @param [Hash<String, Object>] yaml_hash yaml
|
464
|
-
# @option yaml_hash [Hash] :
|
465
|
-
# @option yaml_hash [Hash] :
|
466
|
+
# @option yaml_hash [Hash] :src 移動元
|
467
|
+
# @option yaml_hash [Hash] :dest 移動先
|
466
468
|
# @option yaml_hash [String] :days 中気差分
|
467
469
|
#
|
468
470
|
def initialize(index:, yaml_hash: {})
|
469
471
|
@index = index
|
470
|
-
@source = Source.new(diff_index: index, yaml_hash: yaml_hash['
|
471
|
-
@destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['
|
472
|
+
@source = Source.new(diff_index: index, yaml_hash: yaml_hash['src'])
|
473
|
+
@destination = Destination.new(diff_index: index, yaml_hash: yaml_hash['dest'])
|
472
474
|
@days = yaml_hash['days']
|
473
475
|
end
|
474
476
|
|
475
477
|
def days?
|
476
|
-
Types.positive?(str:
|
478
|
+
Types.positive?(str: days)
|
477
479
|
end
|
478
480
|
|
479
481
|
# :reek:TooManyStatements { max_statements: 6 }
|
@@ -488,9 +490,9 @@ module Zakuro
|
|
488
490
|
|
489
491
|
prefix = "[#{index}][solar_term] invalid"
|
490
492
|
|
491
|
-
failed +=
|
493
|
+
failed += source.validate
|
492
494
|
|
493
|
-
failed +=
|
495
|
+
failed += destination.validate
|
494
496
|
|
495
497
|
failed.push("#{prefix} 'days'. #{@days}") unless days?
|
496
498
|
|
@@ -537,27 +539,27 @@ module Zakuro
|
|
537
539
|
def validate
|
538
540
|
failed = []
|
539
541
|
|
540
|
-
prefix = "[#{
|
542
|
+
prefix = "[#{diff_index}][solar_term.src] invalid"
|
541
543
|
|
542
|
-
failed.push("#{prefix} 'index'. #{
|
544
|
+
failed.push("#{prefix} 'index'. #{index}") unless index?
|
543
545
|
|
544
|
-
failed.push("#{prefix} 'to'. #{
|
546
|
+
failed.push("#{prefix} 'to'. #{to}") unless to?
|
545
547
|
|
546
|
-
failed.push("#{prefix} 'zodiac_name'. #{
|
548
|
+
failed.push("#{prefix} 'zodiac_name'. #{zodiac_name}") unless zodiac_name?
|
547
549
|
|
548
550
|
failed
|
549
551
|
end
|
550
552
|
|
551
553
|
def index?
|
552
|
-
Types.positive?(str:
|
554
|
+
Types.positive?(str: index)
|
553
555
|
end
|
554
556
|
|
555
557
|
def to?
|
556
|
-
Types.western_date?(str:
|
558
|
+
Types.western_date?(str: to)
|
557
559
|
end
|
558
560
|
|
559
561
|
def zodiac_name?
|
560
|
-
Types.string?(str:
|
562
|
+
Types.string?(str: zodiac_name)
|
561
563
|
end
|
562
564
|
end
|
563
565
|
|
@@ -600,27 +602,27 @@ module Zakuro
|
|
600
602
|
def validate
|
601
603
|
failed = []
|
602
604
|
|
603
|
-
prefix = "[#{
|
605
|
+
prefix = "[#{diff_index}][solar_term.dest] invalid"
|
604
606
|
|
605
|
-
failed.push("#{prefix} 'index'. #{
|
607
|
+
failed.push("#{prefix} 'index'. #{index}") unless index?
|
606
608
|
|
607
|
-
failed.push("#{prefix} 'from'. #{
|
609
|
+
failed.push("#{prefix} 'from'. #{from}") unless from?
|
608
610
|
|
609
|
-
failed.push("#{prefix} 'zodiac_name'. #{
|
611
|
+
failed.push("#{prefix} 'zodiac_name'. #{zodiac_name}") unless zodiac_name?
|
610
612
|
|
611
613
|
failed
|
612
614
|
end
|
613
615
|
|
614
616
|
def index?
|
615
|
-
Types.positive?(str:
|
617
|
+
Types.positive?(str: index)
|
616
618
|
end
|
617
619
|
|
618
620
|
def from?
|
619
|
-
Types.western_date?(str:
|
621
|
+
Types.western_date?(str: from)
|
620
622
|
end
|
621
623
|
|
622
624
|
def zodiac_name?
|
623
|
-
Types.string?(str:
|
625
|
+
Types.string?(str: zodiac_name)
|
624
626
|
end
|
625
627
|
end
|
626
628
|
end
|
@@ -633,23 +635,23 @@ module Zakuro
|
|
633
635
|
|
634
636
|
# @return [Integer] 連番
|
635
637
|
attr_reader :index
|
636
|
-
# @return [String]
|
637
|
-
attr_reader :
|
638
|
-
# @return [String]
|
639
|
-
attr_reader :
|
638
|
+
# @return [String] 移動元
|
639
|
+
attr_reader :src
|
640
|
+
# @return [String] 移動先
|
641
|
+
attr_reader :dest
|
640
642
|
|
641
643
|
#
|
642
644
|
# 初期化
|
643
645
|
#
|
644
646
|
# @param [Integer] index 連番
|
645
647
|
# @param [Hash<String, String>] yaml_hash yaml
|
646
|
-
# @option yaml_hash [String] :
|
647
|
-
# @option yaml_hash [String] :
|
648
|
+
# @option yaml_hash [String] :src 移動元
|
649
|
+
# @option yaml_hash [String] :dest 移動先
|
648
650
|
#
|
649
651
|
def initialize(index:, yaml_hash: {})
|
650
652
|
@index = index
|
651
|
-
@
|
652
|
-
@
|
653
|
+
@src = yaml_hash['src']
|
654
|
+
@dest = yaml_hash['dest']
|
653
655
|
end
|
654
656
|
|
655
657
|
#
|
@@ -660,21 +662,21 @@ module Zakuro
|
|
660
662
|
def validate
|
661
663
|
failed = []
|
662
664
|
|
663
|
-
prefix = "[#{
|
665
|
+
prefix = "[#{index}][#{NAME}] invalid"
|
664
666
|
|
665
|
-
failed.push("#{prefix} '
|
667
|
+
failed.push("#{prefix} 'src'. #{src}") unless src?
|
666
668
|
|
667
|
-
failed.push("#{prefix} '
|
669
|
+
failed.push("#{prefix} 'dest'. #{dest}") unless dest?
|
668
670
|
|
669
671
|
failed
|
670
672
|
end
|
671
673
|
|
672
|
-
def
|
673
|
-
Types.positive?(str:
|
674
|
+
def src?
|
675
|
+
Types.positive?(str: src)
|
674
676
|
end
|
675
677
|
|
676
|
-
def
|
677
|
-
Types.positive?(str:
|
678
|
+
def dest?
|
679
|
+
Types.positive?(str: dest)
|
678
680
|
end
|
679
681
|
end
|
680
682
|
|
@@ -686,23 +688,23 @@ module Zakuro
|
|
686
688
|
|
687
689
|
# @return [Integer] 連番
|
688
690
|
attr_reader :index
|
689
|
-
# @return [String]
|
690
|
-
attr_reader :
|
691
|
-
# @return [String]
|
692
|
-
attr_reader :
|
691
|
+
# @return [String] 移動元
|
692
|
+
attr_reader :src
|
693
|
+
# @return [String] 移動先
|
694
|
+
attr_reader :dest
|
693
695
|
|
694
696
|
#
|
695
697
|
# 初期化
|
696
698
|
#
|
697
699
|
# @param [Integer] index 連番
|
698
700
|
# @param [Hash<String, String>] yaml_hash yaml
|
699
|
-
# @option yaml_hash [String] :
|
700
|
-
# @option yaml_hash [String] :
|
701
|
+
# @option yaml_hash [String] :src 移動元
|
702
|
+
# @option yaml_hash [String] :dest 移動先
|
701
703
|
#
|
702
704
|
def initialize(index:, yaml_hash: {})
|
703
705
|
@index = index
|
704
|
-
@
|
705
|
-
@
|
706
|
+
@src = yaml_hash['src']
|
707
|
+
@dest = yaml_hash['dest']
|
706
708
|
end
|
707
709
|
|
708
710
|
#
|
@@ -713,21 +715,21 @@ module Zakuro
|
|
713
715
|
def validate
|
714
716
|
failed = []
|
715
717
|
|
716
|
-
prefix = "[#{
|
718
|
+
prefix = "[#{index}][#{NAME}] invalid"
|
717
719
|
|
718
|
-
failed.push("#{prefix} '
|
720
|
+
failed.push("#{prefix} 'src'. #{src}") unless src?
|
719
721
|
|
720
|
-
failed.push("#{prefix} '
|
722
|
+
failed.push("#{prefix} 'dest'. #{dest}") unless dest?
|
721
723
|
|
722
724
|
failed
|
723
725
|
end
|
724
726
|
|
725
|
-
def
|
726
|
-
Types.empiable_bool?(str:
|
727
|
+
def src?
|
728
|
+
Types.empiable_bool?(str: src)
|
727
729
|
end
|
728
730
|
|
729
|
-
def
|
730
|
-
Types.empiable_bool?(str:
|
731
|
+
def dest?
|
732
|
+
Types.empiable_bool?(str: dest)
|
731
733
|
end
|
732
734
|
end
|
733
735
|
|
@@ -739,23 +741,23 @@ module Zakuro
|
|
739
741
|
|
740
742
|
# @return [Integer] 連番
|
741
743
|
attr_reader :index
|
742
|
-
# @return [String]
|
743
|
-
attr_reader :
|
744
|
-
# @return [String]
|
745
|
-
attr_reader :
|
744
|
+
# @return [String] 移動元
|
745
|
+
attr_reader :src
|
746
|
+
# @return [String] 移動先
|
747
|
+
attr_reader :dest
|
746
748
|
|
747
749
|
#
|
748
750
|
# 初期化
|
749
751
|
#
|
750
752
|
# @param [Integer] index 連番
|
751
753
|
# @param [Hash<String, String>] yaml_hash yaml
|
752
|
-
# @option yaml_hash [String] :
|
753
|
-
# @option yaml_hash [String] :
|
754
|
+
# @option yaml_hash [String] :src 移動元
|
755
|
+
# @option yaml_hash [String] :dest 移動先
|
754
756
|
#
|
755
757
|
def initialize(index:, yaml_hash: {})
|
756
758
|
@index = index
|
757
|
-
@
|
758
|
-
@
|
759
|
+
@src = yaml_hash['src']
|
760
|
+
@dest = yaml_hash['dest']
|
759
761
|
end
|
760
762
|
|
761
763
|
#
|
@@ -766,36 +768,38 @@ module Zakuro
|
|
766
768
|
def validate
|
767
769
|
failed = []
|
768
770
|
|
769
|
-
prefix = "[#{
|
771
|
+
prefix = "[#{index}][#{NAME}] invalid"
|
770
772
|
|
771
|
-
failed.push("#{prefix} '
|
773
|
+
failed.push("#{prefix} 'src'. #{src}") unless src?
|
772
774
|
|
773
|
-
failed.push("#{prefix} '
|
775
|
+
failed.push("#{prefix} 'dest'. #{dest}") unless dest?
|
774
776
|
|
775
777
|
failed
|
776
778
|
end
|
777
779
|
|
778
|
-
def
|
779
|
-
Types.month_days?(str:
|
780
|
+
def src?
|
781
|
+
Types.month_days?(str: src)
|
780
782
|
end
|
781
783
|
|
782
|
-
def
|
783
|
-
Types.month_days?(str:
|
784
|
+
def dest?
|
785
|
+
Types.month_days?(str: dest)
|
784
786
|
end
|
785
787
|
end
|
786
788
|
|
787
789
|
# :reek:TooManyStatements { max_statements: 7 }
|
788
790
|
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
791
|
+
class << self
|
792
|
+
def run(yaml_hash: {})
|
793
|
+
failed = []
|
794
|
+
yaml_hash.each_with_index do |history, index|
|
795
|
+
failed += MonthHistory.new(index: index, yaml_hash: history).validate
|
796
|
+
failed += Annotation.new(index: index, yaml_hash: history).validate
|
797
|
+
failed += Reference.new(index: index, yaml_hash: history).validate
|
798
|
+
failed += Diffs.new(index: index, yaml_hash: history['diffs']).validate
|
799
|
+
end
|
797
800
|
|
798
|
-
|
801
|
+
failed
|
802
|
+
end
|
799
803
|
end
|
800
804
|
end
|
801
805
|
end
|
@@ -16,51 +16,53 @@ module Zakuro
|
|
16
16
|
__dir__
|
17
17
|
))
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
19
|
+
class << self
|
20
|
+
#
|
21
|
+
# 変更履歴(月)を返す
|
22
|
+
#
|
23
|
+
# @return [Array<MonthHistory>] 変更履歴
|
24
|
+
#
|
25
|
+
def month_histories
|
26
|
+
MONTH_HISTORIES
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
+
# :reek:ControlParameter
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
31
|
+
#
|
32
|
+
# 変更履歴を特定する
|
33
|
+
#
|
34
|
+
# @param [Western::Calendar] western_date 月初日の西暦日
|
35
|
+
#
|
36
|
+
# @return [Operation::MonthHistory] 変更履歴
|
37
|
+
#
|
38
|
+
def specify_history(western_date:)
|
39
|
+
month_histroies = month_histories
|
40
|
+
|
41
|
+
month_histroies.each do |history|
|
42
|
+
return history if western_date == history.western_date
|
43
|
+
end
|
39
44
|
|
40
|
-
|
41
|
-
return history if western_date == history.western_date
|
45
|
+
Operation::MonthHistory.new
|
42
46
|
end
|
43
47
|
|
44
|
-
|
45
|
-
end
|
48
|
+
# :reek:ControlParameter
|
46
49
|
|
47
|
-
|
50
|
+
#
|
51
|
+
# 変更履歴を特定する
|
52
|
+
#
|
53
|
+
# @param [Western::Calendar] id 変更履歴ID
|
54
|
+
#
|
55
|
+
# @return [Operation::MonthHistory] 変更履歴
|
56
|
+
#
|
57
|
+
def specify_history_by_id(id:)
|
58
|
+
month_histroies = month_histories
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# @param [Western::Calendar] id 変更履歴ID
|
53
|
-
#
|
54
|
-
# @return [Operation::MonthHistory] 変更履歴
|
55
|
-
#
|
56
|
-
def self.specify_history_by_id(id:)
|
57
|
-
month_histroies = Operation.month_histories
|
60
|
+
month_histroies.each do |history|
|
61
|
+
return history if id == history.id
|
62
|
+
end
|
58
63
|
|
59
|
-
|
60
|
-
return history if id == history.id
|
64
|
+
Operation::MonthHistory.new
|
61
65
|
end
|
62
|
-
|
63
|
-
Operation::MonthHistory.new
|
64
66
|
end
|
65
67
|
end
|
66
68
|
end
|