zakuro 0.1.0 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -12
- data/doc/operation/csv/month.csv +202 -202
- data/doc/operation/operation.xlsx +0 -0
- data/doc/operation/transfer.rb +6 -2
- data/lib/zakuro/calculation/base/multi_gengou.rb +101 -0
- data/lib/zakuro/calculation/base/multi_gengou_roller.rb +218 -0
- data/lib/zakuro/calculation/base/year.rb +107 -0
- data/lib/zakuro/calculation/cycle/abstract_remainder.rb +471 -0
- data/lib/zakuro/calculation/cycle/abstract_solar_term.rb +173 -0
- data/lib/zakuro/calculation/cycle/zodiac.rb +106 -0
- data/lib/zakuro/calculation/monthly/first_day.rb +45 -0
- data/lib/zakuro/calculation/monthly/initialized_month.rb +125 -0
- data/lib/zakuro/calculation/monthly/month.rb +187 -0
- data/lib/zakuro/calculation/monthly/month_label.rb +88 -0
- data/lib/zakuro/calculation/monthly/operated_month.rb +209 -0
- data/lib/zakuro/calculation/range/full_range.rb +210 -0
- data/lib/zakuro/calculation/range/operated_range.rb +144 -0
- data/lib/zakuro/calculation/range/operated_solar_terms.rb +201 -0
- data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +82 -0
- data/lib/zakuro/calculation/range/transfer/year_boundary.rb +146 -0
- data/lib/zakuro/calculation/specifier/single_day.rb +109 -0
- data/lib/zakuro/calculation/summary/single.rb +129 -0
- data/lib/zakuro/condition.rb +16 -13
- data/lib/zakuro/era/japan/gengou/parser.rb +1 -3
- data/lib/zakuro/era/japan/gengou/type.rb +3 -3
- data/lib/zakuro/era/japan/gengou/validator.rb +15 -13
- data/lib/zakuro/merchant.rb +2 -2
- data/lib/zakuro/operation/month/parser.rb +132 -36
- data/lib/zakuro/operation/month/type.rb +11 -10
- data/lib/zakuro/operation/month/validator.rb +332 -28
- data/lib/zakuro/operation/operation.rb +21 -0
- data/lib/zakuro/operation/yaml/month.yaml +1 -1
- data/lib/zakuro/output/error.rb +7 -6
- data/lib/zakuro/output/logger.rb +50 -49
- data/lib/zakuro/output/response.rb +145 -144
- data/lib/zakuro/result/operation.rb +64 -36
- data/lib/zakuro/tools/stringifier.rb +2 -2
- data/lib/zakuro/tools/typeof.rb +2 -2
- data/lib/zakuro/version.rb +1 -1
- data/lib/zakuro/version/abstract_version.rb +1 -1
- data/lib/zakuro/version/context.rb +23 -0
- data/lib/zakuro/version/senmyou/const/number.rb +51 -0
- data/lib/zakuro/version/senmyou/const/remainder.rb +43 -0
- data/lib/zakuro/version/senmyou/cycle/remainder.rb +61 -0
- data/lib/zakuro/version/senmyou/cycle/solar_term.rb +31 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +166 -181
- data/lib/zakuro/version/senmyou/range/annual_range.rb +86 -159
- data/lib/zakuro/version/senmyou/senmyou.rb +10 -4
- data/lib/zakuro/version/senmyou/stella/lunar/adjustment.rb +237 -0
- data/lib/zakuro/version/senmyou/stella/lunar/localization.rb +45 -0
- data/lib/zakuro/version/senmyou/stella/lunar/location.rb +108 -0
- data/lib/zakuro/version/senmyou/stella/lunar/value.rb +89 -0
- data/lib/zakuro/version/senmyou/stella/origin/average_november.rb +34 -0
- data/lib/zakuro/version/senmyou/stella/origin/lunar_age.rb +62 -0
- data/lib/zakuro/version/senmyou/stella/origin/winter_solstice.rb +55 -0
- data/lib/zakuro/version/senmyou/stella/solar/adjustment.rb +93 -0
- data/lib/zakuro/version/senmyou/stella/solar/average.rb +175 -0
- data/lib/zakuro/version/senmyou/stella/solar/interval.rb +103 -0
- data/lib/zakuro/version/senmyou/stella/solar/location.rb +164 -0
- data/lib/zakuro/version/senmyou/stella/solar/value.rb +138 -0
- data/lib/zakuro/version/version_class_resolver.rb +62 -0
- data/lib/zakuro/version_factory.rb +2 -2
- metadata +38 -24
- data/lib/zakuro/cycle/abstract_remainder.rb +0 -456
- data/lib/zakuro/cycle/zodiac.rb +0 -103
- data/lib/zakuro/version/senmyou/base/era.rb +0 -83
- data/lib/zakuro/version/senmyou/base/multi_gengou.rb +0 -98
- data/lib/zakuro/version/senmyou/base/multi_gengou_roller.rb +0 -217
- data/lib/zakuro/version/senmyou/base/remainder.rb +0 -60
- data/lib/zakuro/version/senmyou/base/solar_term.rb +0 -76
- data/lib/zakuro/version/senmyou/base/year.rb +0 -104
- data/lib/zakuro/version/senmyou/monthly/first_day.rb +0 -44
- data/lib/zakuro/version/senmyou/monthly/initialized_month.rb +0 -48
- data/lib/zakuro/version/senmyou/monthly/month.rb +0 -181
- data/lib/zakuro/version/senmyou/monthly/month_label.rb +0 -87
- data/lib/zakuro/version/senmyou/monthly/operated_month.rb +0 -167
- data/lib/zakuro/version/senmyou/range/full_range.rb +0 -324
- data/lib/zakuro/version/senmyou/range/operated_range.rb +0 -105
- data/lib/zakuro/version/senmyou/range/operated_solar_terms.rb +0 -163
- data/lib/zakuro/version/senmyou/specifier/single_day_specifier.rb +0 -99
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +0 -332
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +0 -214
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +0 -394
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +0 -106
- data/lib/zakuro/version/senmyou/summary/single.rb +0 -71
@@ -25,6 +25,8 @@ module Zakuro
|
|
25
25
|
MONTH_HISTORIES
|
26
26
|
end
|
27
27
|
|
28
|
+
# :reek:ControlParameter
|
29
|
+
|
28
30
|
#
|
29
31
|
# 変更履歴を特定する
|
30
32
|
#
|
@@ -41,5 +43,24 @@ module Zakuro
|
|
41
43
|
|
42
44
|
Operation::MonthHistory.new
|
43
45
|
end
|
46
|
+
|
47
|
+
# :reek:ControlParameter
|
48
|
+
|
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
|
58
|
+
|
59
|
+
month_histroies.each do |history|
|
60
|
+
return history if id == history.id
|
61
|
+
end
|
62
|
+
|
63
|
+
Operation::MonthHistory.new
|
64
|
+
end
|
44
65
|
end
|
45
66
|
end
|
data/lib/zakuro/output/error.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# TODO: outputモジュール内にする
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
# :nodoc:
|
6
|
+
module Output
|
7
|
+
#
|
8
|
+
# ZakuroError ライブラリ内エラー
|
9
|
+
#
|
10
|
+
class ZakuroError < StandardError
|
11
|
+
end
|
11
12
|
end
|
12
13
|
end
|
data/lib/zakuro/output/logger.rb
CHANGED
@@ -1,65 +1,66 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# TODO: outputモジュール内にする
|
4
|
-
|
5
3
|
# :nodoc:
|
6
4
|
module Zakuro
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
5
|
+
# :nodoc:
|
6
|
+
module Output
|
7
|
+
#
|
8
|
+
# 軽量なロガー
|
9
|
+
# @note 本番では使用しない
|
10
|
+
#
|
11
|
+
class Logger
|
12
|
+
LEVELS = {
|
13
|
+
none: -1,
|
14
|
+
debug: 0,
|
15
|
+
info: 1
|
16
|
+
# warn : 2,
|
17
|
+
# error : 3,
|
18
|
+
}.freeze
|
19
19
|
|
20
|
-
|
20
|
+
LEVEL = LEVELS[:none]
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
# @return [String] 呼び出し位置
|
23
|
+
attr_reader :location
|
24
24
|
|
25
|
-
|
26
|
-
|
27
|
-
|
25
|
+
def initialize(location:)
|
26
|
+
@location = location
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
#
|
30
|
+
# DEBUGレベルの標準出力を行う
|
31
|
+
#
|
32
|
+
# @param [String] messages メッセージ
|
33
|
+
#
|
34
|
+
def debug(*messages)
|
35
|
+
return if LEVEL < LEVELS[:debug]
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
output('DEBUG', *messages)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
#
|
41
|
+
# INFOレベルの標準出力を行う
|
42
|
+
#
|
43
|
+
# @param [String] messages メッセージ
|
44
|
+
#
|
45
|
+
def info(*messages)
|
46
|
+
return if LEVEL < LEVELS[:info]
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
output('INFO', *messages)
|
49
|
+
end
|
50
50
|
|
51
|
-
|
51
|
+
private
|
52
52
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
53
|
+
#
|
54
|
+
# 標準出力を行う
|
55
|
+
#
|
56
|
+
# @param [String] level ログレベル
|
57
|
+
# @param [String] messages メッセージ
|
58
|
+
#
|
59
|
+
def output(level, *messages)
|
60
|
+
messages.each do |message|
|
61
|
+
# :#{Thread.current.backtrace[5]}
|
62
|
+
p "[#{level}] #{@location}: #{message}"
|
63
|
+
end
|
63
64
|
end
|
64
65
|
end
|
65
66
|
end
|
@@ -2,171 +2,172 @@
|
|
2
2
|
|
3
3
|
require_relative '../result/result'
|
4
4
|
|
5
|
-
# TODO: outputモジュール内にする
|
6
|
-
|
7
5
|
# :nodoc:
|
8
6
|
module Zakuro
|
9
|
-
#
|
10
|
-
|
11
|
-
#
|
12
|
-
module Response
|
7
|
+
# :nodoc:
|
8
|
+
module Output
|
13
9
|
#
|
14
|
-
#
|
10
|
+
# Response 返却値
|
15
11
|
#
|
16
|
-
module
|
12
|
+
module Response
|
17
13
|
#
|
18
|
-
#
|
14
|
+
# SingleDay 1日データ
|
19
15
|
#
|
20
|
-
|
21
|
-
#
|
22
|
-
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
16
|
+
module SingleDay
|
17
|
+
#
|
18
|
+
# Param 引数
|
19
|
+
#
|
20
|
+
class Param
|
21
|
+
# @return [Year] 年情報(各暦のデータ型)
|
22
|
+
attr_reader :year
|
23
|
+
# @return [Month] 月情報(各暦のデータ型)
|
24
|
+
attr_reader :month
|
25
|
+
# @return [Western::Calendar] 年月日情報(西暦)
|
26
|
+
attr_reader :date
|
27
|
+
# @return [Integer] 日数(月初日から指定日までの日数)
|
28
|
+
attr_reader :days
|
29
|
+
|
30
|
+
#
|
31
|
+
# 初期化
|
32
|
+
#
|
33
|
+
# @param [Year] year 年情報(各暦のデータ型)
|
34
|
+
# @param [Month] month 月情報(各暦のデータ型)
|
35
|
+
# @param [Western::Calendar] date 年月日情報(西暦)
|
36
|
+
# @param [Integer] days 日数(月初日から指定日までの日数)
|
37
|
+
#
|
38
|
+
def initialize(year:, month:, date:, days:)
|
39
|
+
@year = year
|
40
|
+
@month = month
|
41
|
+
@date = date
|
42
|
+
@days = days
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# 1日データを生成する
|
48
|
+
#
|
49
|
+
# @param [Parameter] param 引数
|
50
|
+
#
|
51
|
+
# @return [SingleDay] 1日データ
|
52
|
+
#
|
53
|
+
def self.save_single_day(param:)
|
54
|
+
year = param.year
|
55
|
+
month = param.month
|
56
|
+
date = param.date
|
57
|
+
days = param.days
|
58
|
+
Result::Data::SingleDay.new(
|
59
|
+
year: save_year(year: year),
|
60
|
+
month: save_month(month: month, date: date, days: days),
|
61
|
+
day: save_day(month: month, date: date, days: days)
|
62
|
+
)
|
63
|
+
end
|
29
64
|
|
30
65
|
#
|
31
|
-
#
|
66
|
+
# 年データを保存する
|
32
67
|
#
|
33
68
|
# @param [Year] year 年情報(各暦のデータ型)
|
69
|
+
#
|
70
|
+
# @return [Result::Year] 年データ
|
71
|
+
#
|
72
|
+
def self.save_year(year:)
|
73
|
+
multi_gengou = year.multi_gengou
|
74
|
+
first = multi_gengou.first_line
|
75
|
+
second = multi_gengou.second_line
|
76
|
+
Result::Data::Year.new(
|
77
|
+
first_gengou:
|
78
|
+
Result::Data::Gengou.new(name: first.name, number: first.year),
|
79
|
+
second_gengou:
|
80
|
+
Result::Data::Gengou.new(name: second.name, number: second.year),
|
81
|
+
zodiac_name: year.zodiac_name, total_days: year.total_days
|
82
|
+
)
|
83
|
+
end
|
84
|
+
private_class_method :save_year
|
85
|
+
|
86
|
+
#
|
87
|
+
# 月データを保存する
|
88
|
+
#
|
34
89
|
# @param [Month] month 月情報(各暦のデータ型)
|
35
90
|
# @param [Western::Calendar] date 年月日情報(西暦)
|
36
91
|
# @param [Integer] days 日数(月初日から指定日までの日数)
|
37
92
|
#
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
93
|
+
# @return [Result::Month] 月データ
|
94
|
+
#
|
95
|
+
def self.save_month(month:, date:, days:)
|
96
|
+
Result::Data::Month.new(
|
97
|
+
number: month.number, leaped: month.leaped?, days_name: month.days_name,
|
98
|
+
first_day: save_first_day(remainder: month.remainder,
|
99
|
+
date: date, days: days),
|
100
|
+
odd_solar_terms: save_solar_term(term: month.odd_term),
|
101
|
+
even_solar_terms: save_solar_term(term: month.even_term)
|
102
|
+
)
|
43
103
|
end
|
44
|
-
|
45
|
-
|
46
|
-
#
|
47
|
-
# 1日データを生成する
|
48
|
-
#
|
49
|
-
# @param [Parameter] param 引数
|
50
|
-
#
|
51
|
-
# @return [SingleDay] 1日データ
|
52
|
-
#
|
53
|
-
def self.save_single_day(param:)
|
54
|
-
year = param.year
|
55
|
-
month = param.month
|
56
|
-
date = param.date
|
57
|
-
days = param.days
|
58
|
-
Result::Data::SingleDay.new(
|
59
|
-
year: save_year(year: year),
|
60
|
-
month: save_month(month: month, date: date, days: days),
|
61
|
-
day: save_day(month: month, date: date, days: days)
|
62
|
-
)
|
63
|
-
end
|
104
|
+
private_class_method :save_month
|
64
105
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
private_class_method :save_year
|
85
|
-
|
86
|
-
#
|
87
|
-
# 月データを保存する
|
88
|
-
#
|
89
|
-
# @param [Month] month 月情報(各暦のデータ型)
|
90
|
-
# @param [Western::Calendar] date 年月日情報(西暦)
|
91
|
-
# @param [Integer] days 日数(月初日から指定日までの日数)
|
92
|
-
#
|
93
|
-
# @return [Result::Month] 月データ
|
94
|
-
#
|
95
|
-
def self.save_month(month:, date:, days:)
|
96
|
-
Result::Data::Month.new(
|
97
|
-
number: month.number, leaped: month.leaped?, days_name: month.days_name,
|
98
|
-
first_day: save_first_day(remainder: month.remainder,
|
99
|
-
date: date, days: days),
|
100
|
-
odd_solar_terms: save_solar_term(term: month.odd_term),
|
101
|
-
even_solar_terms: save_solar_term(term: month.even_term)
|
102
|
-
)
|
103
|
-
end
|
104
|
-
private_class_method :save_month
|
106
|
+
#
|
107
|
+
# 月初日データを保存する
|
108
|
+
#
|
109
|
+
# @param [Cycle::AbstractRemainder] remainder 大余小余情報
|
110
|
+
# @param [Western::Calendar] date 年月日情報(西暦)
|
111
|
+
# @param [Integer] days 日数(月初日から指定日までの日数)
|
112
|
+
#
|
113
|
+
# @return [Result::Day] 日データ
|
114
|
+
#
|
115
|
+
def self.save_first_day(remainder:, date:, days:)
|
116
|
+
western_date = date.clone - days
|
117
|
+
Result::Data::Day.new(
|
118
|
+
number: 1,
|
119
|
+
zodiac_name: remainder.zodiac_name,
|
120
|
+
remainder: remainder,
|
121
|
+
western_date: western_date
|
122
|
+
)
|
123
|
+
end
|
124
|
+
private_class_method :save_first_day
|
105
125
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
Result::Data::Day.new(
|
118
|
-
number: 1,
|
119
|
-
zodiac_name: remainder.zodiac_name,
|
120
|
-
remainder: remainder,
|
121
|
-
western_date: western_date
|
122
|
-
)
|
123
|
-
end
|
124
|
-
private_class_method :save_first_day
|
126
|
+
#
|
127
|
+
# 二十四節気データを保存する
|
128
|
+
#
|
129
|
+
# @note 今は宣明暦に合わせている。江戸期以降の暦には対応していない(複数の中気節気を指定できない)
|
130
|
+
#
|
131
|
+
# @param [SolarTerm] term 二十四節気情報(各暦のデータ型)
|
132
|
+
#
|
133
|
+
# @return [Array<Result::SolarTerm>] 二十四節気データ
|
134
|
+
#
|
135
|
+
def self.save_solar_term(term:)
|
136
|
+
return [] if term.invalid?
|
125
137
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
#
|
135
|
-
def self.save_solar_term(term:)
|
136
|
-
return [] if term.invalid?
|
138
|
+
[
|
139
|
+
Result::Data::SolarTerm.new(
|
140
|
+
index: term.index,
|
141
|
+
remainder: term.remainder
|
142
|
+
)
|
143
|
+
]
|
144
|
+
end
|
145
|
+
private_class_method :save_solar_term
|
137
146
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
147
|
+
#
|
148
|
+
# 日データを保存する
|
149
|
+
#
|
150
|
+
# @param [Month] month 月情報(各暦のデータ型)
|
151
|
+
# @param [Western::Calendar] date 年月日情報(西暦)
|
152
|
+
# @param [Integer] days 日数(月初日から指定日までの日数)
|
153
|
+
#
|
154
|
+
# @return [Result::Day] 日データ
|
155
|
+
#
|
156
|
+
def self.save_day(month:, date:, days:)
|
157
|
+
remainder = month.remainder
|
158
|
+
remainder = remainder.add(
|
159
|
+
# 常に参照元のRemainderクラスで生成する
|
160
|
+
remainder.class.new(day: days, minute: 0, second: 0)
|
142
161
|
)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
# @param [Western::Calendar] date 年月日情報(西暦)
|
152
|
-
# @param [Integer] days 日数(月初日から指定日までの日数)
|
153
|
-
#
|
154
|
-
# @return [Result::Day] 日データ
|
155
|
-
#
|
156
|
-
def self.save_day(month:, date:, days:)
|
157
|
-
remainder = month.remainder
|
158
|
-
remainder = remainder.add(
|
159
|
-
# 常に参照元のRemainderクラスで生成する
|
160
|
-
remainder.class.new(day: days, minute: 0, second: 0)
|
161
|
-
)
|
162
|
-
Result::Data::Day.new(
|
163
|
-
number: (days + 1),
|
164
|
-
zodiac_name: remainder.zodiac_name,
|
165
|
-
remainder: remainder,
|
166
|
-
western_date: date
|
167
|
-
)
|
162
|
+
Result::Data::Day.new(
|
163
|
+
number: (days + 1),
|
164
|
+
zodiac_name: remainder.zodiac_name,
|
165
|
+
remainder: remainder,
|
166
|
+
western_date: date
|
167
|
+
)
|
168
|
+
end
|
169
|
+
private_class_method :save_day
|
168
170
|
end
|
169
|
-
private_class_method :save_day
|
170
171
|
end
|
171
172
|
end
|
172
173
|
end
|