zakuro 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.editorconfig +9 -0
- data/.gitignore +69 -0
- data/.rspec +3 -0
- data/.rubocop.yml +14 -0
- data/.travis.yml +6 -0
- data/Gemfile +19 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +20 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/images/12/346/234/210/344/273/245/351/231/215/343/201/256/345/205/245/345/256/232/346/260/227.png +0 -0
- data/images/12/346/234/210/344/273/245/351/231/215/343/201/256/346/234/210/343/201/256/351/200/262/351/200/200.png +0 -0
- data/images/source/description.numbers +0 -0
- data/images//345/205/245/345/256/232/346/260/227/343/201/256/350/265/267/347/256/227.png +0 -0
- data/images//345/220/204/346/234/210/343/201/256/346/261/202/343/202/201/346/226/271.png +0 -0
- data/images//345/244/252/351/231/275/343/201/250/346/234/210.png +0 -0
- data/lib/zakuro.rb +9 -0
- data/lib/zakuro/condition.rb +239 -0
- data/lib/zakuro/cycle/abstract_remainder.rb +457 -0
- data/lib/zakuro/cycle/zodiac.rb +103 -0
- data/lib/zakuro/era/gengou/set-001-until-south.yaml +375 -0
- data/lib/zakuro/era/gengou/set-002-from-north.yaml +166 -0
- data/lib/zakuro/era/gengou/set-003-modern.yaml +12 -0
- data/lib/zakuro/era/japan.rb +630 -0
- data/lib/zakuro/era/western.rb +412 -0
- data/lib/zakuro/merchant.rb +57 -0
- data/lib/zakuro/output/error.rb +10 -0
- data/lib/zakuro/output/logger.rb +64 -0
- data/lib/zakuro/output/response.rb +170 -0
- data/lib/zakuro/output/result.rb +219 -0
- data/lib/zakuro/output/stringifier.rb +62 -0
- data/lib/zakuro/version.rb +7 -0
- data/lib/zakuro/version/abstract_version.rb +29 -0
- data/lib/zakuro/version/genka/genka.rb +19 -0
- data/lib/zakuro/version/gihou/gihou.rb +19 -0
- data/lib/zakuro/version/gregorio/gregorio.rb +19 -0
- data/lib/zakuro/version/houryaku/houryaku.rb +19 -0
- data/lib/zakuro/version/joukyou/joukyou.rb +19 -0
- data/lib/zakuro/version/kansei/kansei.rb +19 -0
- data/lib/zakuro/version/senmyou/README.md +586 -0
- data/lib/zakuro/version/senmyou/base/era.rb +81 -0
- data/lib/zakuro/version/senmyou/base/gengou.rb +210 -0
- data/lib/zakuro/version/senmyou/base/remainder.rb +60 -0
- data/lib/zakuro/version/senmyou/base/solar_term.rb +66 -0
- data/lib/zakuro/version/senmyou/base/year.rb +58 -0
- data/lib/zakuro/version/senmyou/monthly/lunar_phase.rb +220 -0
- data/lib/zakuro/version/senmyou/monthly/month.rb +112 -0
- data/lib/zakuro/version/senmyou/senmyou.rb +34 -0
- data/lib/zakuro/version/senmyou/stella/lunar_orbit.rb +332 -0
- data/lib/zakuro/version/senmyou/stella/solar_average.rb +192 -0
- data/lib/zakuro/version/senmyou/stella/solar_orbit.rb +398 -0
- data/lib/zakuro/version/senmyou/stella/winter_solstice.rb +106 -0
- data/lib/zakuro/version/senmyou/summary/annual_data.rb +186 -0
- data/lib/zakuro/version/senmyou/summary/gengou_data.rb +294 -0
- data/lib/zakuro/version/taien/taien.rb +19 -0
- data/lib/zakuro/version/tenpou/tenpou.rb +19 -0
- data/lib/zakuro/version_factory.rb +59 -0
- data/zakuro.gemspec +31 -0
- metadata +106 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d9e107ac002193a5088e0032f75db259107f4cd760dadde20e673df6c8570f25
|
4
|
+
data.tar.gz: 45c517c9fba696f0a6cb28f0122b6e61d5ce5c530ac1a0f86cd7cd0846b223c9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 411685cb4aecbef4a5a202367dec76077ae8f08b0d8a960673a6b42e1bdb5b762d2061c8235ab30a1382a59562e12a3b5b1de6c61bfb4d0fba048b554724c32b
|
7
|
+
data.tar.gz: 6c81db37443b42bb747a1943b32bf52a0c94893ad642eef4157c7d10aefb1b06ca17829abafe23302d9c01d8ae1e8f34b1720dfa6cc1d61557fbdf78e593c71f
|
data/.editorconfig
ADDED
data/.gitignore
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
### https://raw.github.com/github/gitignore/baf13553d070d1d85d6c873235eb529077c35aaf/Ruby.gitignore
|
2
|
+
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
|
15
|
+
# Used by dotenv library to load environment variables.
|
16
|
+
# .env
|
17
|
+
|
18
|
+
# Ignore Byebug command history file.
|
19
|
+
.byebug_history
|
20
|
+
|
21
|
+
## Specific to RubyMotion:
|
22
|
+
.dat*
|
23
|
+
.repl_history
|
24
|
+
build/
|
25
|
+
*.bridgesupport
|
26
|
+
build-iPhoneOS/
|
27
|
+
build-iPhoneSimulator/
|
28
|
+
|
29
|
+
## Specific to RubyMotion (use of CocoaPods):
|
30
|
+
#
|
31
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
32
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
33
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
34
|
+
#
|
35
|
+
# vendor/Pods/
|
36
|
+
|
37
|
+
## Documentation cache and generated files:
|
38
|
+
/.yardoc/
|
39
|
+
/_yardoc/
|
40
|
+
/doc/
|
41
|
+
/rdoc/
|
42
|
+
|
43
|
+
## Environment normalization:
|
44
|
+
/.bundle/
|
45
|
+
/vendor/bundle
|
46
|
+
/lib/bundler/man/
|
47
|
+
|
48
|
+
# for a library or gem, you might want to ignore these files since the code is
|
49
|
+
# intended to run in multiple environments; otherwise, check them in:
|
50
|
+
# Gemfile.lock
|
51
|
+
# .ruby-version
|
52
|
+
# .ruby-gemset
|
53
|
+
|
54
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
55
|
+
.rvmrc
|
56
|
+
|
57
|
+
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
|
58
|
+
# .rubocop-https?--*
|
59
|
+
|
60
|
+
*.log
|
61
|
+
|
62
|
+
# Visual Studio Code setting
|
63
|
+
.solargraph.yml
|
64
|
+
|
65
|
+
# unlocked gem version
|
66
|
+
Gemfile.lock
|
67
|
+
|
68
|
+
# Mac
|
69
|
+
.DS_Store
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in zakuro.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'rspec'
|
12
|
+
end
|
13
|
+
|
14
|
+
group :development do
|
15
|
+
gem 'reek'
|
16
|
+
gem 'rubocop-performance'
|
17
|
+
gem 'solargraph'
|
18
|
+
gem 'yard'
|
19
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 ty
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Zakuro - 石榴
|
2
|
+
zakuro は日本の暦を扱う暦算ライブラリです
|
3
|
+
|
4
|
+
# 前掲
|
5
|
+
石榴(ざくろ)は古来より珍重され、シルクロードを通じて洋の東西に広く伝播した落葉小高木です。
|
6
|
+
|
7
|
+
すなわち、中華世界においては太陰太陽暦、地中海世界においては太陽暦のもとで育ち、これら東西の暦はシルクロードの東端たる日本に深い影響を与えております。
|
8
|
+
|
9
|
+
日本の暦は中国に端を発しますが、江戸時代以降は西洋の文物からも深く学び、日本人は暦算を自らのものとしました。
|
10
|
+
|
11
|
+
石榴はただ伝来しただけでなく、日本の地に根づいております。これを日本の暦になぞらえ、和名の「ざくろ」を冠することと致します。
|
12
|
+
|
13
|
+
## 導入
|
14
|
+
|
15
|
+
Add this line to your application's Gemfile:
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
gem 'zakuro'
|
19
|
+
```
|
20
|
+
|
21
|
+
And then execute:
|
22
|
+
|
23
|
+
$ bundle install
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
$ gem install zakuro
|
28
|
+
|
29
|
+
# 使用方法
|
30
|
+
|
31
|
+
TODO: sample
|
32
|
+
|
33
|
+
# 準拠
|
34
|
+
『日本暦日原典』を範とします。
|
35
|
+
|
36
|
+
# 暦算
|
37
|
+
|
38
|
+
[宣明暦](./lib/zakuro/version/senmyou/README.md) のみ記載しています
|
39
|
+
|
40
|
+
# 進捗
|
41
|
+
|
42
|
+
開発途中です。
|
43
|
+
|
44
|
+
現時点では宣明暦の暦日の1日検索のみ対応しております。
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'yard'
|
7
|
+
require 'yard/rake/yardoc_task'
|
8
|
+
|
9
|
+
# rake spec
|
10
|
+
RSpec::Core::RakeTask.new('spec')
|
11
|
+
task default: :spec
|
12
|
+
|
13
|
+
# rake yard
|
14
|
+
YARD::Rake::YardocTask.new do |t|
|
15
|
+
t.files = %w[
|
16
|
+
lib/**/*.rb
|
17
|
+
]
|
18
|
+
t.options = []
|
19
|
+
# t.options = %w[--debug --verbose] if $trace
|
20
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "zakuro"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/zakuro.rb
ADDED
@@ -0,0 +1,239 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
# :nodoc:
|
6
|
+
module Zakuro
|
7
|
+
#
|
8
|
+
# Catalog 目録
|
9
|
+
#
|
10
|
+
module Catalog
|
11
|
+
#
|
12
|
+
# BasisDate 基準日
|
13
|
+
#
|
14
|
+
class BasisDate
|
15
|
+
# @return [Date] 西暦日
|
16
|
+
attr_reader :date
|
17
|
+
|
18
|
+
#
|
19
|
+
# 初期化
|
20
|
+
#
|
21
|
+
# @param [Date] date 西暦日
|
22
|
+
#
|
23
|
+
def initialize(date:)
|
24
|
+
# TODO: 和暦日(String)から西暦日(Date)への変換
|
25
|
+
@date = date
|
26
|
+
end
|
27
|
+
|
28
|
+
# :reek:NilCheck
|
29
|
+
|
30
|
+
#
|
31
|
+
# 検証する
|
32
|
+
#
|
33
|
+
# @param [Date] date 日付
|
34
|
+
#
|
35
|
+
# @return [Array<String>] エラーメッセージ
|
36
|
+
#
|
37
|
+
def self.validate(date:)
|
38
|
+
failed = []
|
39
|
+
return failed if date.nil? || date.is_a?(Date) || date.is_a?(String)
|
40
|
+
|
41
|
+
failed.push("invalid date: #{date}")
|
42
|
+
failed
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Range 範囲(開始日-終了日)
|
48
|
+
#
|
49
|
+
class Range
|
50
|
+
# @return [Date] 開始日
|
51
|
+
attr_reader :start
|
52
|
+
# @return [Date] 終了日
|
53
|
+
attr_reader :last
|
54
|
+
|
55
|
+
#
|
56
|
+
# 初期化
|
57
|
+
#
|
58
|
+
# @param [Hash<Symbol>] hash パラメータ
|
59
|
+
# @option hash [Symbol] :start 開始日
|
60
|
+
# @option hash [Symbol] :start 終了日
|
61
|
+
#
|
62
|
+
def initialize(hash: {})
|
63
|
+
@start = hash[:start]
|
64
|
+
@last = hash[:last]
|
65
|
+
end
|
66
|
+
|
67
|
+
# :reek:TooManyStatements { max_statements: 7 } and :reek:NilCheck
|
68
|
+
|
69
|
+
#
|
70
|
+
# 検証する
|
71
|
+
#
|
72
|
+
# @param [Hash<Symbol>] hash パラメータ
|
73
|
+
#
|
74
|
+
# @return [Array<String>] エラーメッセージ
|
75
|
+
#
|
76
|
+
def self.validate(hash:)
|
77
|
+
failed = []
|
78
|
+
return failed if hash.nil?
|
79
|
+
|
80
|
+
unless hash.is_a?(Hash)
|
81
|
+
failed.push("invalid range type. #{hash}. should be hash")
|
82
|
+
return failed
|
83
|
+
end
|
84
|
+
|
85
|
+
failed.concat(BasisDate.validate(date: hash[:start]))
|
86
|
+
failed.concat(BasisDate.validate(date: hash[:last]))
|
87
|
+
|
88
|
+
failed
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
#
|
93
|
+
# Columns 特定の列(フィールド)
|
94
|
+
# @note 指定された列のみ出力する
|
95
|
+
#
|
96
|
+
class Columns
|
97
|
+
# @return [Array<String>] 列
|
98
|
+
attr_reader :columns
|
99
|
+
|
100
|
+
#
|
101
|
+
# 初期化
|
102
|
+
#
|
103
|
+
# @param [Array<String>] columns 列
|
104
|
+
#
|
105
|
+
def initialize(columns: [])
|
106
|
+
@columns = columns
|
107
|
+
end
|
108
|
+
|
109
|
+
# :reek:NilCheck
|
110
|
+
|
111
|
+
#
|
112
|
+
# 検証する
|
113
|
+
#
|
114
|
+
# @param [Array<String>] columns 列
|
115
|
+
#
|
116
|
+
# @return [Array<String>] エラーメッセージ
|
117
|
+
#
|
118
|
+
def self.validate(columns:)
|
119
|
+
# TODO: 列内容のバリデーション
|
120
|
+
failed = []
|
121
|
+
return failed if columns.nil? || columns.is_a?(Array)
|
122
|
+
|
123
|
+
failed.push("invalid columns type. #{columns}. should be array")
|
124
|
+
|
125
|
+
failed
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
#
|
130
|
+
# Options オプション
|
131
|
+
# 取得内容を変更する
|
132
|
+
#
|
133
|
+
# * unit: 年/月/日
|
134
|
+
# * lost_days: 没日あり
|
135
|
+
# * seasons: 四季あり
|
136
|
+
#
|
137
|
+
class Options
|
138
|
+
# @return [Array<String>] オプション
|
139
|
+
attr_reader :options
|
140
|
+
#
|
141
|
+
# 初期化
|
142
|
+
#
|
143
|
+
# @param [Array<String>] options オプション
|
144
|
+
#
|
145
|
+
def initialize(options: [])
|
146
|
+
@options = options
|
147
|
+
end
|
148
|
+
|
149
|
+
# TODO: オプションキーのバリデーション
|
150
|
+
# :reek:NilCheck
|
151
|
+
|
152
|
+
#
|
153
|
+
# 検証する
|
154
|
+
#
|
155
|
+
# @param [Array<String>] options オプション
|
156
|
+
#
|
157
|
+
# @return [Array<String>] エラーメッセージ
|
158
|
+
#
|
159
|
+
def self.validate(options:)
|
160
|
+
failed = []
|
161
|
+
return failed if options.nil? || options.is_a?(Hash)
|
162
|
+
|
163
|
+
failed.push("invalid options type. #{options}. should be hash")
|
164
|
+
|
165
|
+
failed
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
#
|
171
|
+
# Condition 条件
|
172
|
+
#
|
173
|
+
class Condition
|
174
|
+
# @return [Date] 基準日
|
175
|
+
attr_reader :date
|
176
|
+
# @return [Hash<Symbol>] 範囲
|
177
|
+
attr_reader :range
|
178
|
+
# @return [Array<String>] 列
|
179
|
+
attr_reader :columns
|
180
|
+
# @return [Array<String>] オプション
|
181
|
+
attr_reader :options
|
182
|
+
|
183
|
+
#
|
184
|
+
# 初期化
|
185
|
+
#
|
186
|
+
# @param [Hash<Symbol, Object>] hash パラメータ
|
187
|
+
# @option hash [Date] :date 基準日
|
188
|
+
# @option hash [Hash<Symbol>] :range 範囲
|
189
|
+
# @option hash [Array<String>] :columns 列
|
190
|
+
# @option hash [Array<String>] :options オプション
|
191
|
+
#
|
192
|
+
def initialize(hash: {})
|
193
|
+
@date = hash[:date]
|
194
|
+
@range = hash[:range]
|
195
|
+
@columns = hash[:columns]
|
196
|
+
@options = hash[:options]
|
197
|
+
end
|
198
|
+
|
199
|
+
# :reek:TooManyStatements { max_statements: 8 }
|
200
|
+
|
201
|
+
#
|
202
|
+
# 検証する
|
203
|
+
#
|
204
|
+
# @param [Hash<Symbol, Object>] hash パラメータ
|
205
|
+
#
|
206
|
+
# @return [Array<String>] エラーメッセージ
|
207
|
+
#
|
208
|
+
def self.validate(hash:)
|
209
|
+
failed = []
|
210
|
+
|
211
|
+
unless hash.is_a?(Hash)
|
212
|
+
failed.push("invalid condition type. #{hash}. should be hash")
|
213
|
+
return failed
|
214
|
+
end
|
215
|
+
|
216
|
+
failed.concat(Catalog::BasisDate.validate(date: hash[:date]))
|
217
|
+
failed.concat(Catalog::Range.validate(hash: hash[:range]))
|
218
|
+
failed.concat(Catalog::Columns.validate(columns: hash[:columns]))
|
219
|
+
failed.concat(Catalog::Options.validate(options: hash[:options]))
|
220
|
+
|
221
|
+
failed
|
222
|
+
end
|
223
|
+
|
224
|
+
# :reek:NilCheck
|
225
|
+
|
226
|
+
#
|
227
|
+
# 上書きする
|
228
|
+
#
|
229
|
+
# @param [Hash<Symbol, Object>] hash パラメータ
|
230
|
+
#
|
231
|
+
def rewrite(hash: {})
|
232
|
+
instance_variables.each do |var|
|
233
|
+
key = var.to_s.delete('@')
|
234
|
+
val = hash[key.intern]
|
235
|
+
instance_variable_set(var, val) unless val.nil?
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|