zakuro 0.5.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. checksums.yaml +4 -4
  2. data/Makefile +3 -0
  3. data/README.md +22 -7
  4. data/VERSION +1 -0
  5. data/doc/operation/transfer.rb +8 -8
  6. data/lib/zakuro/calculation/base/gengou.rb +128 -0
  7. data/lib/zakuro/calculation/base/linear_gengou.rb +76 -0
  8. data/lib/zakuro/calculation/base/operated_year.rb +5 -15
  9. data/lib/zakuro/calculation/base/year.rb +26 -14
  10. data/lib/zakuro/calculation/era/gengou/abstract_scroll.rb +209 -0
  11. data/lib/zakuro/calculation/era/gengou/dated_scroll.rb +30 -0
  12. data/lib/zakuro/calculation/era/gengou/internal/connector.rb +107 -0
  13. data/lib/zakuro/calculation/era/gengou/internal/counter.rb +214 -0
  14. data/lib/zakuro/calculation/era/gengou/internal/publisher.rb +104 -0
  15. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_list.rb +230 -0
  16. data/lib/zakuro/calculation/era/gengou/internal/reserve/abstract_range.rb +193 -0
  17. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_list.rb +48 -0
  18. data/lib/zakuro/calculation/era/gengou/internal/reserve/dated_range.rb +30 -0
  19. data/lib/zakuro/calculation/era/gengou/internal/reserve/empty_link.rb +158 -0
  20. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_list.rb +125 -0
  21. data/lib/zakuro/calculation/era/gengou/internal/reserve/named_range.rb +75 -0
  22. data/lib/zakuro/calculation/era/gengou/internal/reserve.rb +41 -0
  23. data/lib/zakuro/calculation/era/gengou/named_scroll.rb +30 -0
  24. data/lib/zakuro/calculation/era/version/internal/crawler.rb +51 -0
  25. data/lib/zakuro/calculation/era/version/internal/range.rb +39 -0
  26. data/lib/zakuro/calculation/era/version/version.rb +24 -0
  27. data/lib/zakuro/calculation/monthly/first_day.rb +3 -2
  28. data/lib/zakuro/calculation/monthly/month.rb +88 -2
  29. data/lib/zakuro/calculation/monthly/operated_month.rb +3 -3
  30. data/lib/zakuro/calculation/range/abstract_full_range.rb +172 -0
  31. data/lib/zakuro/calculation/range/{operated_range.rb → abstract_operation_range.rb} +17 -15
  32. data/lib/zakuro/calculation/range/dated_full_range.rb +32 -0
  33. data/lib/zakuro/calculation/range/dated_operation_range.rb +33 -0
  34. data/lib/zakuro/calculation/range/named_full_range.rb +38 -0
  35. data/lib/zakuro/calculation/range/named_operation_range.rb +36 -0
  36. data/lib/zakuro/calculation/range/operated_solar_terms.rb +36 -19
  37. data/lib/zakuro/calculation/range/transfer/gengou_scroller.rb +54 -0
  38. data/lib/zakuro/calculation/range/transfer/year_boundary.rb +25 -21
  39. data/lib/zakuro/calculation/summary/internal/month.rb +84 -0
  40. data/lib/zakuro/calculation/summary/{single.rb → internal/operation.rb} +6 -37
  41. data/lib/zakuro/calculation/summary/japan/range.rb +152 -0
  42. data/lib/zakuro/calculation/summary/japan/single.rb +118 -0
  43. data/lib/zakuro/calculation/summary/japan/specifier/single_day.rb +91 -0
  44. data/lib/zakuro/calculation/summary/western/range.rb +124 -0
  45. data/lib/zakuro/calculation/summary/western/single.rb +113 -0
  46. data/lib/zakuro/calculation/summary/western/specifier/multiple_day.rb +169 -0
  47. data/lib/zakuro/calculation/summary/western/specifier/single_day.rb +93 -0
  48. data/lib/zakuro/condition.rb +15 -2
  49. data/lib/zakuro/era/japan/calendar.rb +133 -0
  50. data/lib/zakuro/era/japan/gengou/alignment/aligner.rb +121 -0
  51. data/lib/zakuro/era/japan/gengou/alignment/division.rb +168 -0
  52. data/lib/zakuro/era/japan/gengou/alignment/line.rb +175 -0
  53. data/lib/zakuro/era/japan/gengou/alignment/linear_gengou.rb +187 -0
  54. data/lib/zakuro/era/japan/gengou/alignment.rb +55 -0
  55. data/lib/zakuro/era/japan/gengou/resource/parser.rb +243 -0
  56. data/lib/zakuro/era/japan/gengou/resource/type.rb +293 -0
  57. data/lib/zakuro/era/japan/gengou/resource/validator.rb +347 -0
  58. data/lib/zakuro/era/japan/gengou/resource/yaml/set-001-until-south.yaml +1870 -0
  59. data/lib/zakuro/era/japan/gengou/resource/yaml/set-002-from-north.yaml +810 -0
  60. data/lib/zakuro/era/japan/gengou/resource/yaml/set-003-modern.yaml +50 -0
  61. data/lib/zakuro/era/japan/gengou/resource.rb +33 -0
  62. data/lib/zakuro/era/japan/gengou.rb +26 -80
  63. data/lib/zakuro/era/japan/version.rb +151 -0
  64. data/lib/zakuro/era/{western.rb → western/calendar.rb} +9 -9
  65. data/lib/zakuro/exception/case/pattern.rb +35 -0
  66. data/lib/zakuro/exception/case/preset.rb +51 -0
  67. data/lib/zakuro/exception/case/template.rb +48 -0
  68. data/lib/zakuro/exception/cause.rb +28 -0
  69. data/lib/zakuro/exception/exception.rb +37 -0
  70. data/lib/zakuro/exception/zakuro_error.rb +28 -0
  71. data/lib/zakuro/gateway/locale/date.rb +127 -0
  72. data/lib/zakuro/gateway/locale/range.rb +67 -0
  73. data/lib/zakuro/gateway/range.rb +99 -0
  74. data/lib/zakuro/gateway/single.rb +70 -0
  75. data/lib/zakuro/merchant.rb +15 -4
  76. data/lib/zakuro/operation/month/parser.rb +10 -10
  77. data/lib/zakuro/operation/month/type.rb +32 -32
  78. data/lib/zakuro/operation/month/validator.rb +51 -51
  79. data/lib/zakuro/operation/yaml/month.yaml +3736 -3736
  80. data/lib/zakuro/output/logger.rb +17 -3
  81. data/lib/zakuro/output/response.rb +5 -5
  82. data/lib/zakuro/result/data/day.rb +43 -0
  83. data/lib/zakuro/result/data/gengou.rb +35 -0
  84. data/lib/zakuro/result/data/month.rb +63 -0
  85. data/lib/zakuro/result/data/single_day.rb +48 -0
  86. data/lib/zakuro/result/data/solar_term.rb +35 -0
  87. data/lib/zakuro/result/data/year.rb +45 -0
  88. data/lib/zakuro/result/operation/month/annotation.rb +40 -0
  89. data/lib/zakuro/result/operation/month/bundle.rb +36 -0
  90. data/lib/zakuro/result/operation/month/history.rb +54 -0
  91. data/lib/zakuro/result/operation/operation.rb +44 -0
  92. data/lib/zakuro/result/result.rb +21 -2
  93. data/lib/zakuro/tools/typeconv.rb +38 -0
  94. data/lib/zakuro/tools/typeof.rb +4 -1
  95. data/lib/zakuro/version/context.rb +24 -3
  96. data/lib/zakuro/version/daien/daien.rb +1 -26
  97. data/lib/zakuro/version/genka/genka.rb +1 -26
  98. data/lib/zakuro/version/gihou/gihou.rb +1 -30
  99. data/lib/zakuro/version/gregorio/gregorio.rb +1 -9
  100. data/lib/zakuro/version/houryaku/houryaku.rb +1 -9
  101. data/lib/zakuro/version/joukyou/joukyou.rb +1 -9
  102. data/lib/zakuro/version/kansei/kansei.rb +1 -9
  103. data/lib/zakuro/version/senmyou/README.md +11 -7
  104. data/lib/zakuro/version/senmyou/senmyou.rb +1 -30
  105. data/lib/zakuro/version/tenpou/tenpou.rb +1 -9
  106. data/zakuro.gemspec +1 -3
  107. metadata +74 -22
  108. data/lib/zakuro/calculation/base/multi_gengou.rb +0 -101
  109. data/lib/zakuro/calculation/base/multi_gengou_roller.rb +0 -218
  110. data/lib/zakuro/calculation/range/full_range.rb +0 -210
  111. data/lib/zakuro/calculation/range/transfer/western_date_allocation.rb +0 -82
  112. data/lib/zakuro/calculation/specifier/single_day.rb +0 -109
  113. data/lib/zakuro/era/japan/gengou/parser.rb +0 -167
  114. data/lib/zakuro/era/japan/gengou/type.rb +0 -178
  115. data/lib/zakuro/era/japan/gengou/validator.rb +0 -236
  116. data/lib/zakuro/era/japan/reki.rb +0 -91
  117. data/lib/zakuro/era/japan/yaml/set-001-until-south.yaml +0 -1121
  118. data/lib/zakuro/era/japan/yaml/set-002-from-north.yaml +0 -485
  119. data/lib/zakuro/era/japan/yaml/set-003-modern.yaml +0 -28
  120. data/lib/zakuro/result/data.rb +0 -187
  121. data/lib/zakuro/result/operation.rb +0 -114
  122. data/lib/zakuro/version/abstract_version.rb +0 -29
  123. data/lib/zakuro/version.rb +0 -7
  124. data/lib/zakuro/version_factory.rb +0 -59
@@ -1,114 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nodoc:
4
- module Zakuro
5
- #
6
- # Result 演算結果
7
- #
8
- module Result
9
- #
10
- # 運用情報
11
- #
12
- module Operation
13
- #
14
- # Bundle 運用情報
15
- #
16
- class Bundle
17
- # @return [True] 運用あり
18
- # @return [False] 運用なし
19
- attr_reader :operated
20
- # @return [Month::Bundle] 月別履歴情報
21
- attr_reader :month
22
- # @return [Data::SingleDay] 計算値
23
- attr_reader :original
24
-
25
- #
26
- # 初期化
27
- #
28
- # @param [True, False] operated 運用有無
29
- # @param [Month::Bundle] month 月別履歴情報
30
- # @param [Data::SingleDay] original 計算値
31
- #
32
- def initialize(operated:, month:, original:)
33
- @operated = operated
34
- @month = month
35
- @original = original
36
- end
37
- end
38
-
39
- #
40
- # Month 運用情報(月)
41
- #
42
- module Month
43
- #
44
- # Bundle 月履歴集約情報
45
- #
46
- class Bundle
47
- # @return [History] 月別履歴情報(当月)
48
- attr_reader :current
49
- # @return [History] 月別履歴情報(影響を与えた月)
50
- attr_reader :parent
51
-
52
- def initialize(current: History.new, parent: History.new)
53
- @current = current
54
- @parent = parent
55
- end
56
- end
57
-
58
- #
59
- # History 月別履歴情報
60
- #
61
- class History
62
- # @return [String] ID
63
- attr_reader :id
64
- # @return [String] 月初日の西暦日
65
- attr_reader :western_date
66
- # @return [Integer] 原文頁数
67
- attr_reader :page
68
- # @return [Integer] 原文注釈番号
69
- attr_reader :number
70
- # @return [Array<Zakuro::Result::Operation::Annotation>] 注釈
71
- attr_reader :annotations
72
-
73
- #
74
- # 初期化
75
- #
76
- # @param [String] id ID
77
- # @param [String] western_date 月初日の西暦日
78
- # @param [Integer] page 原文頁数
79
- # @param [Integer] number 原文注釈番号
80
- # @param [Array<Annotation>] annotations 注釈
81
- #
82
- def initialize(id: '', western_date: '', page: -1, number: -1, annotations: [])
83
- @id = id
84
- @western_date = western_date
85
- @page = page
86
- @number = number
87
- @annotations = annotations
88
- end
89
- end
90
-
91
- #
92
- # Annotation 注釈
93
- #
94
- class Annotation
95
- # @return [String] 注釈内容
96
- attr_reader :description
97
- # @return [String] 注釈補記
98
- attr_reader :note
99
-
100
- #
101
- # 初期化
102
- #
103
- # @param [String] description 注釈内容
104
- # @param [<Type>] note 注釈補記
105
- #
106
- def initialize(description:, note:)
107
- @description = description
108
- @note = note
109
- end
110
- end
111
- end
112
- end
113
- end
114
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nodoc:
4
- module Zakuro
5
- #
6
- # AbstractVersion 暦インターフェース
7
- #
8
- # @abstract 暦日を引き当てるためのインターフェース
9
- #
10
- class AbstractVersion
11
- # @return [True] 暦の使用可
12
- # @return [False] 暦の使用不可
13
- RELEASE = false
14
-
15
- #
16
- # 西暦日から和暦日に変換する
17
- #
18
- # @param [Date] western_date 西暦日
19
- #
20
- # @return [Result::Single] 和暦日
21
- #
22
- # @raise [NotImplementedError] オーバーライドなし
23
- #
24
- def self.to_japan_date(western_date:)
25
- raise NotImplementedError,
26
- "must be implemented on #{self.class}##{__method__}(#{western_date})"
27
- end
28
- end
29
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nodoc:
4
- module Zakuro
5
- # @return [String] library version
6
- VERSION = '0.5.0'
7
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative './era/japan/reki'
4
- require_relative './era/western'
5
- require_relative './version/genka/genka'
6
- require_relative './version/gihou/gihou'
7
- require_relative './version/daien/daien'
8
- require_relative './version/senmyou/senmyou'
9
- require_relative './version/joukyou/joukyou'
10
- require_relative './version/houryaku/houryaku'
11
- require_relative './version/kansei/kansei'
12
- require_relative './version/tenpou/tenpou'
13
- require_relative './version/gregorio/gregorio'
14
-
15
- # :nodoc:
16
- module Zakuro
17
- #
18
- # VersionFactory 暦生成
19
- #
20
- class VersionFactory
21
- # :reek:TooManyStatements { max_statements: 6 }
22
- # :reek:UncommunicativeVariableName {accept: e}
23
-
24
- #
25
- # 実行可能な暦を取得する
26
- #
27
- # @param [Date] date 西暦日
28
- #
29
- # @return [AbstractVersion] 暦クラス
30
- #
31
- def self.get_runnable_constant(date:)
32
- class_name = Japan::Reki.class_name(
33
- date: Western::Calendar.create(date: date)
34
- )
35
- constant = Object.const_get(class_name)
36
- raise ArgumentError, 'unreleased version' unless constant::RELEASE
37
-
38
- constant
39
- rescue StandardError => e
40
- raise e
41
- end
42
-
43
- # :reek:UncommunicativeVariableName {accept: e}
44
-
45
- #
46
- # 西暦日から和暦日に変換する
47
- #
48
- # @param [Date] western_date 西暦日
49
- #
50
- # @return [Result::Single] 和暦日
51
- #
52
- def self.to_japan_date(western_date:)
53
- runnable = VersionFactory.get_runnable_constant(date: western_date)
54
- runnable.to_japan_date(western_date: western_date)
55
- rescue StandardError => e
56
- raise Output::ZakuroError, e.message
57
- end
58
- end
59
- end