zakuro 0.5.0 → 0.7.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 +22 -7
- data/VERSION +1 -0
- data/doc/operation/transfer.rb +8 -8
- data/lib/zakuro/calculation/base/gengou.rb +128 -0
- data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
- data/lib/zakuro/calculation/base/operated_year.rb +5 -15
- data/lib/zakuro/calculation/base/year.rb +26 -14
- data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
- data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
- 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/abstract_list.rb +230 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
- 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 +158 -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 +75 -0
- data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +41 -0
- data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
- data/lib/zakuro/calculation/era/version/internal/crawler.rb +51 -0
- data/lib/zakuro/calculation/era/version/internal/range.rb +39 -0
- data/lib/zakuro/calculation/era/version/version.rb +24 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
- data/lib/zakuro/calculation/monthly/month.rb +88 -2
- data/lib/zakuro/calculation/monthly/operated_month.rb +3 -3
- data/lib/zakuro/calculation/range/abstract_full_range.rb +172 -0
- data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +17 -15
- 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/named_full_range.rb +38 -0
- data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -19
- 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/summary/internal/month.rb +84 -0
- data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -37
- data/lib/zakuro/calculation/summary/japan/range.rb +152 -0
- data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
- data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +91 -0
- data/lib/zakuro/calculation/summary/western/range.rb +124 -0
- data/lib/zakuro/calculation/summary/western/single.rb +113 -0
- data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +169 -0
- data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +93 -0
- data/lib/zakuro/condition.rb +15 -2
- data/lib/zakuro/era/japan/calendar.rb +133 -0
- data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +121 -0
- data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
- data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
- data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
- data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
- data/lib/zakuro/era/japan/gengou/resource/parser.rb +243 -0
- data/lib/zakuro/era/japan/gengou/resource/type.rb +293 -0
- data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1870 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +810 -0
- data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +50 -0
- data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
- data/lib/zakuro/era/japan/gengou.rb +26 -80
- data/lib/zakuro/era/japan/version.rb +151 -0
- data/lib/zakuro/era/{western.rb → western/calendar.rb} +9 -9
- data/lib/zakuro/exception/case/pattern.rb +35 -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 +37 -0
- data/lib/zakuro/exception/zakuro_error.rb +28 -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 +70 -0
- data/lib/zakuro/merchant.rb +15 -4
- data/lib/zakuro/operation/month/parser.rb +10 -10
- data/lib/zakuro/operation/month/type.rb +32 -32
- data/lib/zakuro/operation/month/validator.rb +51 -51
- data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
- data/lib/zakuro/output/logger.rb +17 -3
- data/lib/zakuro/output/response.rb +5 -5
- 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/single_day.rb +48 -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/bundle.rb +36 -0
- data/lib/zakuro/result/operation/month/history.rb +54 -0
- data/lib/zakuro/result/operation/operation.rb +44 -0
- data/lib/zakuro/result/result.rb +21 -2
- data/lib/zakuro/tools/typeconv.rb +38 -0
- data/lib/zakuro/tools/typeof.rb +4 -1
- data/lib/zakuro/version/context.rb +24 -3
- data/lib/zakuro/version/daien/daien.rb +1 -26
- data/lib/zakuro/version/genka/genka.rb +1 -26
- data/lib/zakuro/version/gihou/gihou.rb +1 -30
- 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/README.md +11 -7
- data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
- data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
- data/zakuro.gemspec +1 -3
- metadata +74 -22
- 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/full_range.rb +0 -210
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
- data/lib/zakuro/calculation/specifier/single_day.rb +0 -109
- data/lib/zakuro/era/japan/gengou/parser.rb +0 -167
- data/lib/zakuro/era/japan/gengou/type.rb +0 -178
- data/lib/zakuro/era/japan/gengou/validator.rb +0 -236
- 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/result/data.rb +0 -187
- data/lib/zakuro/result/operation.rb +0 -114
- data/lib/zakuro/version/abstract_version.rb +0 -29
- data/lib/zakuro/version.rb +0 -7
- data/lib/zakuro/version_factory.rb +0 -59
@@ -3,8 +3,6 @@
|
|
3
3
|
require_relative '../../operation/operation'
|
4
4
|
require_relative '../monthly/month'
|
5
5
|
|
6
|
-
# TODO: solar_termの中はsrc/destだが、yamlはcalc/actual。統一したい。
|
7
|
-
|
8
6
|
# :nodoc:
|
9
7
|
module Zakuro
|
10
8
|
# :nodoc:
|
@@ -57,6 +55,8 @@ module Zakuro
|
|
57
55
|
# @return [SolarTerm] 二十四節気
|
58
56
|
#
|
59
57
|
def get(western_date: Western::Calendar.new)
|
58
|
+
context = current_context(western_date: western_date)
|
59
|
+
|
60
60
|
solar_term_class = context.resolver.solar_term
|
61
61
|
solar_term = @directions.fetch(western_date.format, solar_term_class.new)
|
62
62
|
|
@@ -68,23 +68,6 @@ module Zakuro
|
|
68
68
|
[true, solar_term]
|
69
69
|
end
|
70
70
|
|
71
|
-
#
|
72
|
-
# 二十四節気の移動元/移動先を生成する
|
73
|
-
#
|
74
|
-
# @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
75
|
-
#
|
76
|
-
def create_directions
|
77
|
-
directions = {}
|
78
|
-
|
79
|
-
years.each do |year|
|
80
|
-
OperatedSolarTerms.create_directions_with_months(
|
81
|
-
context: context, directions: directions, months: year.months
|
82
|
-
)
|
83
|
-
end
|
84
|
-
|
85
|
-
directions
|
86
|
-
end
|
87
|
-
|
88
71
|
# :reek:TooManyStatements { max_statements: 6 }
|
89
72
|
|
90
73
|
#
|
@@ -195,6 +178,40 @@ module Zakuro
|
|
195
178
|
index: destination.index
|
196
179
|
)
|
197
180
|
end
|
181
|
+
|
182
|
+
private
|
183
|
+
|
184
|
+
#
|
185
|
+
# 日付に対応する暦コンテキストを取得する
|
186
|
+
#
|
187
|
+
# @param [Western::Calendar] western_date 西暦日
|
188
|
+
#
|
189
|
+
# @return [Context] 暦コンテキスト
|
190
|
+
#
|
191
|
+
def current_context(western_date: Western::Calendar.new)
|
192
|
+
@years.each do |year|
|
193
|
+
return year.context if western_date >= year.new_year_date
|
194
|
+
end
|
195
|
+
|
196
|
+
Context.new
|
197
|
+
end
|
198
|
+
|
199
|
+
#
|
200
|
+
# 二十四節気の移動元/移動先を生成する
|
201
|
+
#
|
202
|
+
# @return [Hash<String, SolarTerm>] 二十四節気の移動元/移動先(西暦日 -> 対応する二十四節気)
|
203
|
+
#
|
204
|
+
def create_directions
|
205
|
+
directions = {}
|
206
|
+
|
207
|
+
years.each do |year|
|
208
|
+
OperatedSolarTerms.create_directions_with_months(
|
209
|
+
context: year.context, directions: directions, months: year.months
|
210
|
+
)
|
211
|
+
end
|
212
|
+
|
213
|
+
directions
|
214
|
+
end
|
198
215
|
end
|
199
216
|
end
|
200
217
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../monthly/month'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Range
|
11
|
+
# :nodoc:
|
12
|
+
module Transfer
|
13
|
+
#
|
14
|
+
# GengouScroller 元号スクロール
|
15
|
+
#
|
16
|
+
module GengouScroller
|
17
|
+
#
|
18
|
+
# 元号を年に設定する
|
19
|
+
#
|
20
|
+
# @param [Gengou::Scroll] scroll 元号スクロール
|
21
|
+
# @param [Array<Base::Year>] years 年
|
22
|
+
#
|
23
|
+
def self.set(scroll:, years: [])
|
24
|
+
years.each do |year|
|
25
|
+
update_gengou_year(scroll: scroll, year: year)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# 年の元号を更新する
|
31
|
+
#
|
32
|
+
# @param [Base::Year] year 年
|
33
|
+
#
|
34
|
+
def self.update_gengou_year(scroll:, year:)
|
35
|
+
year.months.each_with_index do |month, index|
|
36
|
+
scroll.run(month: month)
|
37
|
+
gengou = scroll.to_gengou
|
38
|
+
year.months[index] = Monthly::Month.new(
|
39
|
+
context: month.context,
|
40
|
+
month_label: month.month_label,
|
41
|
+
first_day: Monthly::FirstDay.new(
|
42
|
+
remainder: month.first_day.remainder,
|
43
|
+
western_date: gengou.start_date.clone
|
44
|
+
),
|
45
|
+
solar_terms: month.solar_terms, gengou: gengou
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
private_class_method :update_gengou_year
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '../../../calculation/base/multi_gengou_roller'
|
4
3
|
require_relative '../../../calculation/base/year'
|
5
4
|
|
6
|
-
require_relative '../../../era/western'
|
5
|
+
require_relative '../../../era/western/calendar'
|
7
6
|
|
8
7
|
# :nodoc:
|
9
8
|
module Zakuro
|
@@ -21,27 +20,30 @@ module Zakuro
|
|
21
20
|
# 年間範囲内の年データの開始月を変更する
|
22
21
|
#
|
23
22
|
# @param [Context] context 暦コンテキスト
|
24
|
-
# @param [Array<Year>] annual_ranges 年データ(冬至基準)
|
23
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
25
24
|
#
|
26
|
-
# @return [Array<Year>] 年データ(元旦基準)
|
25
|
+
# @return [Array<Base::Year>] 年データ(元旦基準)
|
27
26
|
#
|
28
27
|
def self.get(context:, annual_ranges:)
|
29
28
|
categorize(context: context, annual_ranges: annual_ranges)
|
30
|
-
rearranged_years(annual_ranges: annual_ranges)
|
29
|
+
rearranged_years(context: context, annual_ranges: annual_ranges)
|
31
30
|
end
|
32
31
|
|
33
32
|
#
|
34
33
|
# 年間範囲内の年データの開始月を変更する
|
35
34
|
#
|
36
|
-
# @param [
|
35
|
+
# @param [Context] context 暦コンテキスト
|
36
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
37
37
|
#
|
38
|
-
# @return [Array<Year>] 年データ(元旦基準)
|
38
|
+
# @return [Array<Base::Year>] 年データ(元旦基準)
|
39
39
|
#
|
40
|
-
def self.rearranged_years(annual_ranges:)
|
40
|
+
def self.rearranged_years(context:, annual_ranges:)
|
41
41
|
years = []
|
42
42
|
|
43
43
|
(0..(annual_ranges.size - 2)).each do |index|
|
44
|
-
year = rearranged_year(
|
44
|
+
year = rearranged_year(
|
45
|
+
context: context, annual_ranges: annual_ranges, index: index
|
46
|
+
)
|
45
47
|
years.push(year)
|
46
48
|
end
|
47
49
|
|
@@ -53,7 +55,7 @@ module Zakuro
|
|
53
55
|
# 年間範囲を昨年/今年で分類する
|
54
56
|
#
|
55
57
|
# @param [Context] context 暦コンテキスト
|
56
|
-
# @param [Array<Year>] annual_range 1年データ
|
58
|
+
# @param [Array<Base::Year>] annual_range 1年データ
|
57
59
|
#
|
58
60
|
def self.categorize(context:, annual_ranges:)
|
59
61
|
annual_ranges.each do |annual_range|
|
@@ -86,16 +88,17 @@ module Zakuro
|
|
86
88
|
#
|
87
89
|
# 年データの開始月を変更する
|
88
90
|
#
|
89
|
-
# @param [
|
91
|
+
# @param [Context] context 暦コンテキスト
|
92
|
+
# @param [Array<Base::Year>] annual_ranges 年データ(冬至基準)
|
90
93
|
# @param [Integer] index 対象年の要素番号
|
91
94
|
#
|
92
|
-
# @return [Year] 年データ(元旦基準)
|
95
|
+
# @return [Base::Year] 年データ(元旦基準)
|
93
96
|
#
|
94
|
-
def self.rearranged_year(annual_ranges:, index:)
|
97
|
+
def self.rearranged_year(context:, annual_ranges:, index:)
|
95
98
|
current_annual_range = annual_ranges[index]
|
96
99
|
next_annual_range = annual_ranges[index + 1]
|
97
100
|
|
98
|
-
year = push_current_year(annual_range: current_annual_range)
|
101
|
+
year = push_current_year(context: context, annual_range: current_annual_range)
|
99
102
|
push_last_year(annual_range: next_annual_range, year: year)
|
100
103
|
|
101
104
|
year
|
@@ -105,12 +108,13 @@ module Zakuro
|
|
105
108
|
#
|
106
109
|
# 当年データを生成する
|
107
110
|
#
|
108
|
-
# @param [
|
109
|
-
# @param [
|
111
|
+
# @param [Context] context 暦コンテキスト
|
112
|
+
# @param [Array<Month>] annual_range 1年データ
|
110
113
|
#
|
111
|
-
# @return [Year] 当年月ありの対象年
|
114
|
+
# @return [Base::Year] 当年月ありの対象年
|
112
115
|
#
|
113
|
-
def self.push_current_year(
|
116
|
+
def self.push_current_year(context:, annual_range:)
|
117
|
+
year = Base::Year.new(context: context)
|
114
118
|
annual_range.each do |month|
|
115
119
|
next if month.is_last_year
|
116
120
|
|
@@ -124,10 +128,10 @@ module Zakuro
|
|
124
128
|
#
|
125
129
|
# 昨年データを生成する
|
126
130
|
#
|
127
|
-
# @param [Array<
|
128
|
-
# @param [Year] year 対象年
|
131
|
+
# @param [Array<Month>] annual_range 1年データ
|
132
|
+
# @param [Base::Year] year 対象年
|
129
133
|
#
|
130
|
-
# @return [Year] 昨年月ありの対象年
|
134
|
+
# @return [Base::Year] 昨年月ありの対象年
|
131
135
|
#
|
132
136
|
def self.push_last_year(annual_range:, year: Base::Year.new)
|
133
137
|
annual_range.each do |month|
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../../output/response'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
# :nodoc:
|
8
|
+
module Calculation
|
9
|
+
# :nodoc:
|
10
|
+
module Summary
|
11
|
+
#
|
12
|
+
# Month 特定月
|
13
|
+
#
|
14
|
+
class Month
|
15
|
+
# @return [Western::Calendar] 西暦開始日
|
16
|
+
attr_reader :start_date
|
17
|
+
# @return [Western::Calendar] 西暦終了日
|
18
|
+
attr_reader :last_date
|
19
|
+
# @return [Base::Year] 年
|
20
|
+
attr_reader :year
|
21
|
+
# @return [Monthly::Month] 月
|
22
|
+
attr_reader :month
|
23
|
+
|
24
|
+
#
|
25
|
+
# 初期化
|
26
|
+
#
|
27
|
+
# @param [Western::Calendar] start_date 西暦開始日
|
28
|
+
# @param [Western::Calendar] last_date 西暦終了日
|
29
|
+
# @param [Base::Year] year 年
|
30
|
+
# @param [Monthly::Month] month 月
|
31
|
+
#
|
32
|
+
def initialize(start_date:, last_date:, year:, month:)
|
33
|
+
@start_date = start_date
|
34
|
+
@last_date = last_date
|
35
|
+
@year = year
|
36
|
+
@month = month
|
37
|
+
end
|
38
|
+
|
39
|
+
#
|
40
|
+
# 取得する
|
41
|
+
#
|
42
|
+
# @return [Array<Result::Data::SingleDay>] 1日データ
|
43
|
+
#
|
44
|
+
def get
|
45
|
+
result = []
|
46
|
+
first_date = @month.western_date.clone
|
47
|
+
|
48
|
+
(0..@month.days).each do |index|
|
49
|
+
current_date = first_date.clone + index
|
50
|
+
|
51
|
+
next unless include?(date: current_date)
|
52
|
+
|
53
|
+
day = Output::Response::SingleDay.save_single_day(
|
54
|
+
param: Output::Response::SingleDay::Param.new(
|
55
|
+
year: @year, month: @month,
|
56
|
+
date: current_date, days: index
|
57
|
+
)
|
58
|
+
)
|
59
|
+
|
60
|
+
result.push(day)
|
61
|
+
end
|
62
|
+
|
63
|
+
result
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# 含まれるか
|
68
|
+
#
|
69
|
+
# @param [Western::Calendar] date 西暦日
|
70
|
+
#
|
71
|
+
# @return [True] 含む
|
72
|
+
# @return [False] 含まない
|
73
|
+
#
|
74
|
+
def include?(date:)
|
75
|
+
return false if date < @start_date
|
76
|
+
|
77
|
+
return false if date > @last_date
|
78
|
+
|
79
|
+
true
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -1,10 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
|
5
|
-
require_relative '../range/operated_range'
|
6
|
-
|
7
|
-
require_relative '../range/full_range'
|
3
|
+
require_relative '../../../operation/operation'
|
8
4
|
|
9
5
|
# :nodoc:
|
10
6
|
module Zakuro
|
@@ -13,35 +9,9 @@ module Zakuro
|
|
13
9
|
# :nodoc:
|
14
10
|
module Summary
|
15
11
|
#
|
16
|
-
#
|
12
|
+
# Operation 運用情報
|
17
13
|
#
|
18
|
-
module
|
19
|
-
#
|
20
|
-
# 生成する
|
21
|
-
#
|
22
|
-
# @param [Context] context 暦コンテキスト
|
23
|
-
# @param [Western::Calendar] date 西暦日
|
24
|
-
#
|
25
|
-
# @return [Result::Single] 一日検索結果(和暦日)
|
26
|
-
#
|
27
|
-
def self.get(context:, date: Western::Calendar.new)
|
28
|
-
full_range = Calculation::Range::FullRange.new(context: context, start_date: date)
|
29
|
-
years = full_range.get
|
30
|
-
|
31
|
-
calc_date = Calculation::Specifier::SingleDay.get(
|
32
|
-
years: years, date: date
|
33
|
-
)
|
34
|
-
|
35
|
-
operated_range = Calculation::Range::OperatedRange.new(context: context, years: years)
|
36
|
-
|
37
|
-
Result::Single.new(
|
38
|
-
data: Calculation::Specifier::SingleDay.get(
|
39
|
-
years: operated_range.get, date: date
|
40
|
-
),
|
41
|
-
operation: create_operation(calc_date: calc_date)
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
14
|
+
module Operation
|
45
15
|
#
|
46
16
|
# 運用情報を生成する
|
47
17
|
#
|
@@ -49,9 +19,9 @@ module Zakuro
|
|
49
19
|
#
|
50
20
|
# @return [Result::Operation::Bundle] 運用情報
|
51
21
|
#
|
52
|
-
def self.
|
22
|
+
def self.create(calc_date: Result::Data::SingleDay.new)
|
53
23
|
first_day = calc_date.month.first_day.western_date
|
54
|
-
operation_history = Operation.specify_history(western_date: first_day)
|
24
|
+
operation_history = Zakuro::Operation.specify_history(western_date: first_day)
|
55
25
|
|
56
26
|
operation_month = create_operation_month(operation_history: operation_history)
|
57
27
|
|
@@ -59,7 +29,6 @@ module Zakuro
|
|
59
29
|
operated: !operation_history.invalid?, month: operation_month, original: calc_date
|
60
30
|
)
|
61
31
|
end
|
62
|
-
private_class_method :create_operation
|
63
32
|
|
64
33
|
#
|
65
34
|
# 月履歴集約情報を生成する
|
@@ -71,7 +40,7 @@ module Zakuro
|
|
71
40
|
def self.create_operation_month(operation_history: Operation::MonthHistory.new)
|
72
41
|
return Result::Operation::Month::Bundle.new if operation_history.invalid?
|
73
42
|
|
74
|
-
parent_operation_history = Operation.specify_history_by_id(
|
43
|
+
parent_operation_history = Zakuro::Operation.specify_history_by_id(
|
75
44
|
id: operation_history.parent_id
|
76
45
|
)
|
77
46
|
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/named_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/named_full_range'
|
6
|
+
|
7
|
+
require_relative '../western/specifier/multiple_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
require_relative './specifier/single_day'
|
12
|
+
|
13
|
+
# :nodoc:
|
14
|
+
module Zakuro
|
15
|
+
# :nodoc:
|
16
|
+
module Calculation
|
17
|
+
# :nodoc:
|
18
|
+
module Summary
|
19
|
+
# :nodoc:
|
20
|
+
module Japan
|
21
|
+
#
|
22
|
+
# Range 期間
|
23
|
+
#
|
24
|
+
module Range
|
25
|
+
#
|
26
|
+
# 生成する
|
27
|
+
#
|
28
|
+
# @param [Context] context 暦コンテキスト
|
29
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
30
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
31
|
+
#
|
32
|
+
# @return [Result::Range] 期間検索結果(和暦日)
|
33
|
+
#
|
34
|
+
def self.get(context:, start_date: Japan::Calendar.new,
|
35
|
+
last_date: Japan::Calendar.new)
|
36
|
+
years = get_full_range_years(
|
37
|
+
context: context, start_date: start_date, last_date: last_date
|
38
|
+
)
|
39
|
+
operated_years = get_operation_range_years(
|
40
|
+
context: context, years: years, start_date: start_date, last_date: last_date
|
41
|
+
)
|
42
|
+
|
43
|
+
japan_start_date = Specifier::SingleDay.get(years: operated_years, date: start_date)
|
44
|
+
japan_last_date = Specifier::SingleDay.get(years: operated_years, date: last_date)
|
45
|
+
|
46
|
+
list = create_list(
|
47
|
+
operated_years: operated_years, years: years,
|
48
|
+
start_date: japan_start_date, last_date: japan_last_date
|
49
|
+
)
|
50
|
+
|
51
|
+
Result::Range.new(list: list)
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# <Description>
|
56
|
+
#
|
57
|
+
# @param [Array<Base::OperatedYear>] operated_years 運用結果範囲
|
58
|
+
# @param [Array<Base::Year>] years 完全範囲
|
59
|
+
# @param [Result::Data::SingleDay] start_date 和暦開始日
|
60
|
+
# @param [Result::Data::SingleDay] last_date 和暦終了日
|
61
|
+
#
|
62
|
+
# @return [Array<Result::Single>] 結果リスト
|
63
|
+
#
|
64
|
+
def self.create_list(operated_years: [], years: [],
|
65
|
+
start_date:, last_date:)
|
66
|
+
western_start_date = start_date.day.western_date
|
67
|
+
western_last_date = last_date.day.western_date
|
68
|
+
|
69
|
+
operated_dates = Western::Specifier::MultipleDay.get(
|
70
|
+
years: operated_years, start_date: western_start_date, last_date: western_last_date
|
71
|
+
)
|
72
|
+
|
73
|
+
dates = Western::Specifier::MultipleDay.get(
|
74
|
+
years: years, start_date: western_start_date, last_date: western_last_date
|
75
|
+
)
|
76
|
+
|
77
|
+
create_result_list(dates: dates, operated_dates: operated_dates)
|
78
|
+
end
|
79
|
+
private_class_method :create_list
|
80
|
+
|
81
|
+
#
|
82
|
+
# 完全範囲を取得する
|
83
|
+
#
|
84
|
+
# @param [Context] context 暦コンテキスト
|
85
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
86
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
87
|
+
#
|
88
|
+
# @return [Array<Base::Year>] 完全範囲
|
89
|
+
#
|
90
|
+
def self.get_full_range_years(context:, start_date: Japan::Calendar.new,
|
91
|
+
last_date: Japan::Calendar.new)
|
92
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
93
|
+
context: context, start_name: start_date.gengou, last_name: last_date.gengou
|
94
|
+
)
|
95
|
+
full_range.get
|
96
|
+
end
|
97
|
+
private_class_method :get_full_range_years
|
98
|
+
|
99
|
+
#
|
100
|
+
# 運用結果範囲を取得する
|
101
|
+
#
|
102
|
+
# @param [Context] context 暦コンテキスト
|
103
|
+
# @param [Array<Base::Year>] years 完全範囲
|
104
|
+
# @param [Japan::Calendar] start_date 和暦開始日
|
105
|
+
# @param [Japan::Calendar] last_date 和暦終了日
|
106
|
+
#
|
107
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
108
|
+
#
|
109
|
+
def self.get_operation_range_years(context:, years:, start_date: Japan::Calendar.new,
|
110
|
+
last_date: Japan::Calendar.new)
|
111
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
112
|
+
context: context, years: years,
|
113
|
+
start_name: start_date.gengou, last_name: last_date.gengou
|
114
|
+
)
|
115
|
+
operation_range.get
|
116
|
+
end
|
117
|
+
private_class_method :get_operation_range_years
|
118
|
+
|
119
|
+
#
|
120
|
+
# 結果リストを生成する
|
121
|
+
#
|
122
|
+
# @param [Array<Result::Data::SingleDay>] dates 検索結果(計算値)
|
123
|
+
# @param [Array<Result::Data::SingleDay>] operated_dates 検索結果(運用値)
|
124
|
+
#
|
125
|
+
# @return [Array<Result::Single>] 結果リスト
|
126
|
+
#
|
127
|
+
def self.create_result_list(dates:, operated_dates:)
|
128
|
+
result = []
|
129
|
+
|
130
|
+
return result if dates.size != operated_dates.size
|
131
|
+
|
132
|
+
(0..(dates.size - 1)).each do |index|
|
133
|
+
data = operated_dates[index]
|
134
|
+
|
135
|
+
date = dates[index]
|
136
|
+
operation = Operation.create(calc_date: date)
|
137
|
+
|
138
|
+
result.push(
|
139
|
+
Result::Single.new(
|
140
|
+
data: data,
|
141
|
+
operation: operation
|
142
|
+
)
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
result
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../range/named_operation_range'
|
4
|
+
|
5
|
+
require_relative '../../range/named_full_range'
|
6
|
+
|
7
|
+
require_relative '../western/specifier/single_day'
|
8
|
+
|
9
|
+
require_relative '../internal/operation'
|
10
|
+
|
11
|
+
require_relative './specifier/single_day'
|
12
|
+
|
13
|
+
# :nodoc:
|
14
|
+
module Zakuro
|
15
|
+
# :nodoc:
|
16
|
+
module Calculation
|
17
|
+
# :nodoc:
|
18
|
+
module Summary
|
19
|
+
# :nodoc:
|
20
|
+
module Japan
|
21
|
+
#
|
22
|
+
# Single 一日
|
23
|
+
#
|
24
|
+
module Single
|
25
|
+
#
|
26
|
+
# 生成する
|
27
|
+
#
|
28
|
+
# @param [Context] context 暦コンテキスト
|
29
|
+
# @param [Japan::Calendar] date 和暦日
|
30
|
+
#
|
31
|
+
# @return [Result::Single] 一日検索結果(和暦日)
|
32
|
+
#
|
33
|
+
def self.get(context:, date: Japan::Calendar.new)
|
34
|
+
years = get_full_range_years(context: context, date: date)
|
35
|
+
|
36
|
+
data = get_data(context: context, years: years, date: date)
|
37
|
+
|
38
|
+
western_date = data.day.western_date
|
39
|
+
operation = get_operation(years: years, date: western_date)
|
40
|
+
|
41
|
+
Result::Single.new(
|
42
|
+
data: data,
|
43
|
+
operation: operation
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
#
|
48
|
+
# 完全範囲を取得する
|
49
|
+
#
|
50
|
+
# @param [Context] context 暦コンテキスト
|
51
|
+
# @param [Japan::Calendar] date 和暦日
|
52
|
+
#
|
53
|
+
# @return [Array<Base::Year>] 完全範囲
|
54
|
+
#
|
55
|
+
def self.get_full_range_years(context:, date: Japan::Calendar.new)
|
56
|
+
full_range = Calculation::Range::NamedFullRange.new(
|
57
|
+
context: context, start_name: date.gengou
|
58
|
+
)
|
59
|
+
full_range.get
|
60
|
+
end
|
61
|
+
private_class_method :get_full_range_years
|
62
|
+
|
63
|
+
#
|
64
|
+
# 1日を取得する
|
65
|
+
#
|
66
|
+
# @param [Context] context 暦コンテキスト
|
67
|
+
# @param [Array<Base::Year>] years 完全範囲
|
68
|
+
# @param [Japan::Calendar] date 和暦日
|
69
|
+
#
|
70
|
+
# @return [Data::SingleDay] 1日
|
71
|
+
#
|
72
|
+
def self.get_data(context:, years:, date: Japan::Calendar.new)
|
73
|
+
operated_years = get_operation_range_years(context: context, years: years, date: date)
|
74
|
+
|
75
|
+
Specifier::SingleDay.get(
|
76
|
+
years: operated_years, date: date
|
77
|
+
)
|
78
|
+
end
|
79
|
+
private_class_method :get_data
|
80
|
+
|
81
|
+
#
|
82
|
+
# 運用結果範囲を取得する
|
83
|
+
#
|
84
|
+
# @param [Context] context 暦コンテキスト
|
85
|
+
# @param [Array<Base::Year>] years 完全範囲
|
86
|
+
# @param [Japan::Calendar] date 和暦日
|
87
|
+
#
|
88
|
+
# @return [Array<Base::OperatedYear>] 運用結果範囲
|
89
|
+
#
|
90
|
+
def self.get_operation_range_years(context:, years:, date: Japan::Calendar.new)
|
91
|
+
operation_range = Calculation::Range::NamedOperationRange.new(
|
92
|
+
context: context, start_name: date.gengou, years: years
|
93
|
+
)
|
94
|
+
operation_range.get
|
95
|
+
end
|
96
|
+
private_class_method :get_operation_range_years
|
97
|
+
|
98
|
+
#
|
99
|
+
# 完全範囲を取得する
|
100
|
+
#
|
101
|
+
# @param [Context] context 暦コンテキスト
|
102
|
+
# @param [Western::Calendar] date 和暦日
|
103
|
+
#
|
104
|
+
# @return [Array<Base::Year>] 完全範囲
|
105
|
+
#
|
106
|
+
def self.get_operation(years:, date: Western::Calendar.new)
|
107
|
+
calc_date = Western::Specifier::SingleDay.get(
|
108
|
+
years: years, date: date
|
109
|
+
)
|
110
|
+
|
111
|
+
Operation.create(calc_date: calc_date)
|
112
|
+
end
|
113
|
+
private_class_method :get_operation
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|