when_exe 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (144) hide show
  1. checksums.yaml +5 -5
  2. data/LICENSE.ja.txt +8 -21
  3. data/LICENSE.txt +5 -27
  4. data/README.md +25 -79
  5. data/bin/.pryrc +9 -0
  6. data/bin/make_ttl.rb +3 -2
  7. data/bin/make_ttl.rb.config +3 -3
  8. data/lib/when_exe.rb +101 -5
  9. data/lib/when_exe/basictypes.rb +47 -16
  10. data/lib/when_exe/calendarnote.rb +27 -18
  11. data/lib/when_exe/calendartypes.rb +12 -50
  12. data/lib/when_exe/coordinates.rb +37 -391
  13. data/lib/when_exe/ephemeris.rb +53 -14
  14. data/lib/when_exe/ephemeris/eclipse.rb +8 -8
  15. data/lib/when_exe/ephemeris/moon.rb +333 -333
  16. data/lib/when_exe/ephemeris/notes.rb +29 -17
  17. data/lib/when_exe/ephemeris/phase_table.rb +825 -0
  18. data/lib/when_exe/ephemeris/term_table.rb +603 -0
  19. data/lib/when_exe/events.rb +1888 -0
  20. data/lib/when_exe/google_api.rb +26 -31
  21. data/lib/when_exe/icalendar.rb +129 -12
  22. data/lib/when_exe/inspect.rb +5 -5
  23. data/lib/when_exe/linkeddata.rb +43 -23
  24. data/lib/when_exe/locales/akt.rb +63 -0
  25. data/lib/when_exe/locales/encoding_conversion.rb +134 -134
  26. data/lib/when_exe/locales/iast.rb +90 -90
  27. data/lib/when_exe/locales/locale.rb +88 -18
  28. data/lib/when_exe/locales/transliteration_table.rb +62 -62
  29. data/lib/when_exe/mini_application.rb +14 -8
  30. data/lib/when_exe/namespace.rb +42 -0
  31. data/lib/when_exe/parts/enumerator.rb +16 -5
  32. data/lib/when_exe/parts/geometric_complex.rb +52 -2
  33. data/lib/when_exe/parts/method_cash.rb +229 -224
  34. data/lib/when_exe/parts/resource.rb +65 -35
  35. data/lib/when_exe/parts/timezone.rb +25 -34
  36. data/lib/when_exe/region/balinese.rb +5 -3
  37. data/lib/when_exe/region/chinese.rb +39 -11
  38. data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
  39. data/lib/when_exe/region/chinese/epochs.rb +7 -7
  40. data/lib/when_exe/region/chinese/notes.rb +3 -3
  41. data/lib/when_exe/region/chinese/twins.rb +134 -11
  42. data/lib/when_exe/region/dee.rb +4 -4
  43. data/lib/when_exe/region/discordian.rb +1 -1
  44. data/lib/when_exe/region/geologicalage.rb +139 -128
  45. data/lib/when_exe/region/hanke_henry.rb +4 -4
  46. data/lib/when_exe/region/indian.rb +77 -8
  47. data/lib/when_exe/region/international_fixed.rb +3 -3
  48. data/lib/when_exe/region/islamic.rb +1 -1
  49. data/lib/when_exe/region/japanese.rb +12 -8
  50. data/lib/when_exe/region/japanese/calendars.rb +397 -397
  51. data/lib/when_exe/region/japanese/eclipses.rb +1194 -1194
  52. data/lib/when_exe/region/japanese/epochs.rb +8 -4
  53. data/lib/when_exe/region/japanese/location.rb +93 -0
  54. data/lib/when_exe/region/japanese/nihon_shoki.rb +70 -70
  55. data/lib/when_exe/region/japanese/notes.rb +57 -18
  56. data/lib/when_exe/region/japanese/residues.rb +33 -11
  57. data/lib/when_exe/region/japanese/twins.rb +27 -14
  58. data/lib/when_exe/region/japanese/weeks.rb +7 -7
  59. data/lib/when_exe/region/korean.rb +384 -384
  60. data/lib/when_exe/region/location.rb +40 -0
  61. data/lib/when_exe/region/martian.rb +1 -1
  62. data/lib/when_exe/region/mayan.rb +2 -2
  63. data/lib/when_exe/region/roman.rb +2 -2
  64. data/lib/when_exe/region/ryukyu.rb +101 -101
  65. data/lib/when_exe/region/saudi_arabian.rb +57 -0
  66. data/lib/when_exe/region/shire.rb +1 -1
  67. data/lib/when_exe/region/world.rb +3 -3
  68. data/lib/when_exe/region/zoroastrian.rb +1 -1
  69. data/lib/when_exe/spatial.rb +611 -0
  70. data/lib/when_exe/timestandard.rb +9 -7
  71. data/lib/when_exe/tmobjects.rb +34 -2
  72. data/lib/when_exe/tmposition.rb +225 -1322
  73. data/lib/when_exe/tmptypes.rb +1279 -0
  74. data/lib/when_exe/tmreference.rb +42 -7
  75. data/lib/when_exe/version.rb +3 -3
  76. data/test/events/example-datasets +6 -0
  77. data/test/events/history-dataset.csv +22 -0
  78. data/test/events/japanese-holiday-index.csv +28 -0
  79. data/test/events/japanese-holiday.csv +94 -0
  80. data/test/events/japanese-holiday.ttl +948 -0
  81. data/test/events/make_events_ttl.rb +18 -0
  82. data/test/events/mori_wikichoshi.csv +14 -0
  83. data/test/events/ndl_koyomi.csv +220 -0
  84. data/test/events/ndl_koyomi_index.csv +44 -0
  85. data/test/events/primeminister-dataset.csv +19 -0
  86. data/test/events/shogun-dataset.csv +22 -0
  87. data/test/events/test-history-dataset-edge-sparql.csv +26 -0
  88. data/test/events/test-history-dataset-edge.csv +27 -0
  89. data/test/events/test-history-dataset-sparql.csv +22 -0
  90. data/test/events/test-history-dataset.csv +23 -0
  91. data/test/events/test-history-events-edge.ttl +89 -0
  92. data/test/events/test-history-events.csv +6 -0
  93. data/test/examples/JapanHolidays.ics +2 -2
  94. data/test/examples/JapanHolidaysRFC6350.ics +3 -3
  95. data/test/examples/Residue.m17n +2 -2
  96. data/test/examples/Spatial.m17n +3 -3
  97. data/test/examples/Terms.m17n +3 -3
  98. data/test/scripts/8.ext.rb +6 -6
  99. data/test/scripts/8.rb +6 -6
  100. data/test/scripts/geometric_complex.rb +41 -41
  101. data/test/scripts/korea.rb +59 -59
  102. data/test/scripts/thai.rb +36 -36
  103. data/test/test.rb +6 -0
  104. data/test/test/basictypes.rb +431 -431
  105. data/test/test/calendarnote.rb +86 -86
  106. data/test/test/calendartypes.rb +97 -97
  107. data/test/test/coordinates.rb +399 -397
  108. data/test/test/ephemeris.rb +115 -115
  109. data/test/test/ephemeris/moon.rb +14 -14
  110. data/test/test/ephemeris/planets.rb +14 -14
  111. data/test/test/ephemeris/sun.rb +14 -14
  112. data/test/test/events.rb +32 -0
  113. data/test/test/google_api.rb +45 -32
  114. data/test/test/inspect.rb +153 -153
  115. data/test/test/parts.rb +488 -488
  116. data/test/test/region/armenian.rb +20 -20
  117. data/test/test/region/bahai.rb +58 -58
  118. data/test/test/region/balinese.rb +34 -34
  119. data/test/test/region/chinese.rb +229 -229
  120. data/test/test/region/christian.rb +226 -226
  121. data/test/test/region/coptic.rb +27 -27
  122. data/test/test/region/discordian.rb +20 -20
  123. data/test/test/region/french.rb +33 -33
  124. data/test/test/region/geologicalage.rb +17 -17
  125. data/test/test/region/indian.rb +14 -1
  126. data/test/test/region/iran.rb +54 -54
  127. data/test/test/region/islamic.rb +64 -54
  128. data/test/test/region/japanese.rb +281 -261
  129. data/test/test/region/jewish.rb +63 -63
  130. data/test/test/region/m17n.rb +21 -21
  131. data/test/test/region/mayan.rb +17 -16
  132. data/test/test/region/reforms.rb +2 -2
  133. data/test/test/region/residue.rb +7 -7
  134. data/test/test/region/shire.rb +58 -58
  135. data/test/test/region/swedish.rb +45 -45
  136. data/test/test/region/thai.rb +116 -116
  137. data/test/test/region/tibetan.rb +30 -30
  138. data/test/test/region/vietnamese.rb +102 -102
  139. data/test/test/region/zoroastrian.rb +58 -58
  140. data/test/test/timestandard.rb +81 -81
  141. data/test/test/tmobjects.rb +402 -402
  142. data/test/test/tmposition.rb +66 -4
  143. data/test/test/tmreference.rb +157 -157
  144. metadata +36 -93
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: b40bf07a801ef6ae19fa3821c5768cda89f95e7e
4
- data.tar.gz: acafb3787334e8a37dca4d7429489b6d390ed17a
2
+ SHA256:
3
+ metadata.gz: e033cac66a5dfbe35abf7e1ded44ddd7775c8cb6c523d9942261e863b45be2ea
4
+ data.tar.gz: 445721eaa7db250aa97e4e95c12f173195cd229119fc60ff7c77dec0b8dba195
5
5
  SHA512:
6
- metadata.gz: c4be4641f8831f194acab492a26170ebe4f54fb00f5c98dd1dfc5982f88ea3bea077a6ce5778f5691f02a3b8d95e9538826191ebcd88235490d967a3a6efda44
7
- data.tar.gz: e4d27604acb85c99db321ec99bfc04b456f99656439aecfcd9534e54ae6fb1e6ab844673a2b10d8369a3b0f18968bb9ffc6faa9be1136ffa202d360b559c462f
6
+ metadata.gz: 33cf89beed3b1194a9eeb47ad6b7f58fc1feebedabb2353e72a906ad4888b8ea4d6f6edb3abdb872f197df55aca0cf84899e6c5c52aedb4c244559fcb1919011
7
+ data.tar.gz: b05ba8ebd6b49ba2b70e15dd3a84b877765f45a1f0afd654b6ed27cc755d809b37a6cb583e762a74ebd9c688219755cf086dfbf56ba95e14c5e13f3b9318ce24
data/LICENSE.ja.txt CHANGED
@@ -1,25 +1,12 @@
1
- When.exe: A multicultural and multilingualized calendar library
1
+ The MIT License (MIT)
2
2
 
3
- 本プログラムの著作権は須賀隆 <suchowan@box.email.ne.jp> にあります。
3
+ Copyright (c) 2011 Takashi SUGA <suchowan@box.email.ne.jp>.
4
4
 
5
- 本プログラムは,下記の条件で使用できます.
5
+ 以下に定める条件に従い、本ソフトウェアおよび関連文書のファイル(以下「ソフトウェア」)の複製を取得するすべての人に対し、ソフトウェアを無制限に扱うことを無償で許可します。
6
+ これには、ソフトウェアの複製を使用、複写、変更、結合、掲載、頒布、サブライセンス、および/または販売する権利、およびソフトウェアを提供する相手に同じことを許可する権利も無制限に含まれます。
6
7
 
7
- 1. 必ず、著作権表示や免責事項を含めて、制限なく自由に複製できます.
8
+ 上記の著作権表示および本許諾表示を、ソフトウェアのすべての複製または重要な部分に記載するものとします。
8
9
 
9
- 2. 以下の条件のいずれかを満たす時に本プログラムを自由に変更できます.
10
-
11
- (a) 変更した本プログラムを自分だけで使う.
12
-
13
- (b) その他の変更条件を作者と書面により合意する.
14
-
15
- 3. 本プログラム,変更した本プログラム及び本プログラムから生成した実行形式は,
16
- 作者との書面による合意がなければ配布できません.
17
-
18
- 4. 他のプログラムとの併合はいかなる目的であれ自由です.
19
-
20
- 5. 本プログラムへの入力となるデータおよび本プログラムからの出力の権利は
21
- 本プログラムの作者ではなく,それぞれの入出力を生成した人に属します.
22
-
23
- 6. 本プログラムは無保証です.作者は本プログラムをサポートする意志はありますが,
24
- プログラム自身のバグあるいは本プログラムの実行などから発生するいかなる損害に
25
- 対しても責任を持ちません.
10
+ ソフトウェアは「現状のまま」で、明示であるか暗黙であるかを問わず、何らの保証もなく提供されます。
11
+ ここでいう保証とは、商品性、特定の目的への適合性、および権利非侵害についての保証も含みますが、それに限定されるものではありません。
12
+ 作者または著作権者は、契約行為、不法行為、またはそれ以外であろうと、ソフトウェアに起因または関連し、あるいはソフトウェアの使用またはその他の扱いによって生じる一切の請求、損害、その他の義務について何らの責任も負わないものとします。
data/LICENSE.txt CHANGED
@@ -1,31 +1,9 @@
1
- When.exe: A multicultural and multilingualized calendar library
1
+ The MIT License (MIT)
2
2
 
3
- This library is copyrighted free software by Takashi SUGA <suchowan@box.email.ne.jp>.
3
+ Copyright (c) 2011 Takashi SUGA <suchowan@box.email.ne.jp>.
4
4
 
5
- You can use and/or modify the software under the conditions below:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6
 
7
- 1. You may make verbatim copies of the software without restriction, provided
8
- that you duplicate all of the original copyright notices and associated
9
- disclaimers.
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
8
 
11
- 2. You may modify your copy of the software in any way, provided that
12
- you do at least ONE of the following:
13
-
14
- a) place your modifications in your private domain.
15
-
16
- b) make other written arrangements with the author.
17
-
18
- 3. You cannot distribute the software with/without modification or
19
- derived executable binary form without written arrangements with the author.
20
-
21
- 4. You may modify and include the part of the software into any other
22
- software.
23
-
24
- 5. The data supplied as input to or produced as output from the software
25
- do not automatically fall under the copyright of the software,
26
- but belong to whomever generated them.
27
-
28
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
29
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
30
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
31
- PURPOSE.
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -3,7 +3,7 @@ when_exe - A multicultural and multilingualized calendar library
3
3
 
4
4
  [![Gem Version](https://badge.fury.io/rb/when_exe.svg)](http://badge.fury.io/rb/when_exe)
5
5
 
6
- [when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601](http://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350). [JSON-LD](http://www.w3.org/TR/json-ld/) formats for TemporalPosition and TemporalReferenceSystem are available.
6
+ [when_exe](http://rubygems.org/gems/when_exe) is a multicultural and multilingualized calendar library based on [ISO 8601:2004](https://en.wikipedia.org/wiki/ISO_8601), [ISO 19108](http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=26013), [RFC 5545(iCalendar)](http://tools.ietf.org/html/rfc5545) and [RFC6350](http://tools.ietf.org/html/rfc6350). [JSON-LD](http://www.w3.org/TR/json-ld/) formats for TemporalPosition and TemporalReferenceSystem are available.
7
7
 
8
8
  [<img alt='Architecture' title='display this figure at actual size' src='https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png' width='637' height='408'/>](https://raw.githubusercontent.com/suchowan/when_exe/f7bb8b51259f0c1653c6c37b3ce20bd2a6ab7914/architecture.png)
9
9
 
@@ -44,9 +44,9 @@ For further detail, please refer to the [when_exe Wiki](http://www2u.biglobe.ne.
44
44
  License
45
45
  -------
46
46
 
47
- This beta version's license is limited. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt) for details.
47
+ This beta version's license is the MIT license. Please see [LICENSE.txt](https://github.com/suchowan/when_exe/blob/master/LICENSE.txt).
48
48
 
49
- Data sets [TemporalPositionDataSet](http://hosi.org/tp.rdf) and [TemporalReferenceSystemDataSet](http://hosi.org/When.rdf) should be used according to [CC-BY-ND](http://creativecommons.org/licenses/by-nd/4.0/) license.
49
+ Data sets [TemporalPositionDataSet](http://hosi.org/tp.rdf) and [TemporalReferenceSystemDataSet](http://hosi.org/When.rdf) should be used according to [CC-BY](http://creativecommons.org/licenses/by/4.0/) license.
50
50
 
51
51
 
52
52
  Source Code
@@ -142,34 +142,18 @@ Example Usage
142
142
  # retrieve JSON, JSON-LD, Turtle response from http://hosi.org:3000 (when_exe demonstration web server)
143
143
  # (Notation3, RDF/XML, N-Triples and XML formats are also available.)
144
144
  require 'open-uri'
145
- open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
145
+ URI.open('http://hosi.org:3000/Date/2014-04-20.json') do |json|
146
146
  puts json.read #=> newlines and blanks are inserted for readability.
147
147
  # {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
148
148
  # "precision": 0,
149
149
  # "location" : "http://hosi.org/When/Coordinates/Spatial?long=139.4441E&lat=35.3916N&alt=0.0",
150
150
  # "sdn" : 2456768,
151
151
  # "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
152
- # "notes" : [[{"note":"Month","value":"April"}],
153
- # [{"note":"Week","value":"Sunday(6)"}]],
154
- # "clock" : "Asia/Tokyo+09:00",
155
- # "clk_time" : [2456768,0,0,0],
156
- # "dynamical": 1397919667.184082,
157
- # "universal": 1397919600.0,
158
- # "cal_date" : [2014,4,20]}
159
- end
160
-
161
- open('http://hosi.org/tp/2014-04-20.json') do |json| # redirected from http://hosi.org to http://hosi.org:3000
162
- puts json.read #=> newlines and blanks are inserted for readability.
163
- # {"frame" : "http://hosi.org/When/CalendarTypes/Gregorian",
164
- # "precision": 0,
165
- # "sdn" : 2456768,
166
- # "calendar" : ["http://hosi.org/When/CalendarTypes/Gregorian"],
167
- # "notes" : [[{"note":"Month","value":"April"}],
168
- # [{"note":"Week","value":"Sunday(6)"}]],
152
+ # <..snip..>
169
153
  # "cal_date" : [2014,4,20]}
170
154
  end
171
155
 
172
- open('http://hosi.org/tp/2014-04-20.jsonld') do |jsonld| # redirected from http://hosi.org to http://hosi.org:3000
156
+ URI.open('http://hosi.org/tp/2014-04-20.jsonld') do |jsonld| # redirected from http://hosi.org to http://hosi.org:3000
173
157
  puts jsonld.read #=> newlines and blanks are inserted for readability.
174
158
  # {"@context":
175
159
  # {"xsd" :"http://www.w3.org/2001/XMLSchema",
@@ -196,7 +180,7 @@ Example Usage
196
180
  # }
197
181
  end
198
182
 
199
- open('http://hosi.org/tp/2014-04-20.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
183
+ URI.open('http://hosi.org/tp/2014-04-20.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
200
184
  puts ttl.read
201
185
  # @prefix Week: <http://hosi.org/When/Coordinates/Common::Week::> .
202
186
  # @prefix day: <http://hosi.org/When/CalendarNote/Christian/Notes::day::> .
@@ -216,7 +200,7 @@ Example Usage
216
200
  # ts:sdn 2456768 .
217
201
  end
218
202
 
219
- open('http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
203
+ URI.open('http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge.ttl') do |ttl| # redirected from http://hosi.org to http://hosi.org:3000
220
204
  puts ttl.read
221
205
  # @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
222
206
  # @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@@ -224,23 +208,24 @@ Example Usage
224
208
  # @prefix xsd: <http://www.w3.org/2001/XMLSchema> .
225
209
  #
226
210
  # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge> a <http://hosi.org/ts/When/TM/OrdinalReferenceSystem>;
227
- # rdfs:member <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::冥王代>,
228
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::始生代>,
229
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代>,
230
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::顕生代> .
211
+ # rdfs:member <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Hadean>,
212
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean>,
213
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Proterozoic>,
214
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Phanerozoic> .
231
215
  #
232
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::冥王代> a <http://hosi.org/ts/When/TM/OrdinalEra>;
233
- # ts:begin "-4600000000";
234
- # ts:end "-4000000000";
235
- # ts:label <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::冥王代::冥王代> .
216
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean> a <http://hosi.org/ts/When/TM/OrdinalEra>;
217
+ # ts:begin "-4000000000";
218
+ # ts:end "-2500000000";
219
+ # ts:label <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Archean>;
220
+ # rdfs:member <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Eoarchean>,
221
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Paleoarchean>,
222
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Mesoarchean>,
223
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Neoarchean> .
236
224
  #
237
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代> a <http://hosi.org/ts/When/TM/OrdinalEra>;
238
- # ts:begin "-2500000000";
239
- # ts:end "-542000000";
240
- # ts:label <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代::原生代>;
241
- # rdfs:member <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代::前期>,
242
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代::中期>,
243
- # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::原生代::後期> .
225
+ # <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Eoarchean> a <http://hosi.org/ts/When/TM/OrdinalEra>;
226
+ # ts:begin "-4000000000";
227
+ # ts:end "-3600000000";
228
+ # ts:label <http://hosi.org/When/TM/OrdinalReferenceSystem/GeologicalAge::Archean::Eoarchean::Eoarchean> .
244
229
  # <..snip..>
245
230
  end
246
231
 
@@ -249,7 +234,7 @@ Example Usage
249
234
  # https://rubygems.org/gems/sparql is required for this section's operations.
250
235
  # Please install sparql before operation.
251
236
 
252
- require 'sparql'
237
+ require 'sparql/client'
253
238
  PREFIXES = When::Parts::Resource.namespace_prefixes(
254
239
  '_co:Common', '_co:Common?V=0618', '_m:Calendar', '_m:Japanese', '_n:Japanese/Notes')
255
240
 
@@ -295,42 +280,3 @@ Example Usage
295
280
  p When.when?('TZID=America/New_York:1997-10-26T02:30') #=> 1997-10-26T02:30-05:00
296
281
  p When.when?('TZID=America/New_York:1997-10-26T03:30') #=> 1997-10-26T03:30-05:00
297
282
 
298
- #
299
- # Google Calendar ------------------------------
300
- # https://rubygems.org/gems/google-api-client is required for this section's operations.
301
- # Please install google-api-client and add authorization file 'google-api.yaml' before operation.
302
-
303
- require 'google/api_client'
304
- require "yaml"
305
- oauth_yaml = YAML.load_file('google-api.yaml')
306
- client = Google::APIClient.new(:application_name => "when_exe",
307
- :application_version => When::VERSION)
308
- client.authorization.client_id = oauth_yaml["client_id"]
309
- client.authorization.client_secret = oauth_yaml["client_secret"]
310
- client.authorization.scope = oauth_yaml["scope"]
311
- client.authorization.refresh_token = oauth_yaml["refresh_token"]
312
- client.authorization.access_token = oauth_yaml["access_token"]
313
- service = client.discovered_api('calendar', 'v3')
314
- calendar = When::GoogleAPI::Calendar.list(client, service,
315
- 'en.japanese#holiday@group.v.calendar.google.com')
316
- calendar.enum_for(When.when?('20150101/1231')).each do |date|
317
- p [date, date.events[0].summary] #=>
318
- # [2015-01-01, "New Year's Day"]
319
- # [2015-01-12, "Coming of Age Day"]
320
- # [2015-02-11, "National Foundation Day"]
321
- # [2015-03-21, "Spring Equinox"]
322
- # [2015-04-29, "Shōwa Day"]
323
- # [2015-05-03, "Constitution Memorial Day"]
324
- # [2015-05-04, "Greenery Day"]
325
- # [2015-05-05, "Children's Day"]
326
- # [2015-05-06, "Constitution Memorial Day observed"]
327
- # [2015-07-20, "Sea Day"]
328
- # [2015-09-21, "Respect for the Aged Day"]
329
- # [2015-09-22, "Bridge Public holiday"]
330
- # [2015-09-23, "Autumn Equinox"]
331
- # [2015-10-12, "Sports Day"]
332
- # [2015-11-03, "Culture Day"]
333
- # [2015-11-23, "Labor Thanksgiving Day"]
334
- # [2015-12-23, "Emperor's Birthday"]
335
- end
336
-
data/bin/.pryrc ADDED
@@ -0,0 +1,9 @@
1
+ require 'pp'
2
+ require 'date'
3
+ require 'when_exe'
4
+ require 'when_exe/core/extension'
5
+ require 'when_exe/mini_application'
6
+ include When
7
+ Pry.hooks.add_hook :after_read, :hack_encoding do |str, _|
8
+ str.force_encoding STDIN.external_encoding
9
+ end
data/bin/make_ttl.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2014 Takashi SUGA
3
+ Copyright (C) 2014-2019 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license
6
6
  described in the LICENSE.txt file included in this archive.
@@ -24,7 +24,8 @@ File.open(config['file'], 'w') do |file|
24
24
  CONTEXT.each_pair do |key, value|
25
25
  file.puts "@prefix #{key}: <#{value}> ."
26
26
  end
27
- (when?(config['begin'])..when?(config['end'])).each do |date|
27
+ (config['begin'].to_i..config['end'].to_i).each do |year|
28
+ date = when?("#{year}^^#{year < 1873 ? 'Japanese' : 'Gregorian?note=Japanese'}")
28
29
  graph = RDF::Graph.new <<
29
30
  JSON::LD::API.toRdf(date.rdf_graph(
30
31
  {'@context'=>CONTEXT, :prefixes=>PREFIXES, :included=>true, :include=>true}))
@@ -1,6 +1,6 @@
1
- {"begin" : "593^^Japanese",
2
- "end" : "1872^^Japanese",
3
- "file" : "japanese.ttl",
1
+ {"begin" : "593",
2
+ "end" : "2051",
3
+ "file" : "notes_data_japan.ttl",
4
4
  "resource" : [
5
5
  "_co:Common",
6
6
  "_co:Common?V=0618",
data/lib/when_exe.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  =begin
3
- Copyright (C) 2011-2015 Takashi SUGA
3
+ Copyright (C) 2011-2019 Takashi SUGA
4
4
 
5
5
  You may use and/or modify this file according to the license described in the LICENSE.txt file included in this archive.
6
6
  =end
@@ -19,11 +19,12 @@ begin
19
19
  rescue LoadError, NoMethodError
20
20
  end
21
21
 
22
- autoload :URI, 'uri'
22
+ autoload :CGI, 'cgi'
23
23
  autoload :OpenURI, 'open-uri'
24
24
  autoload :OpenSSL, 'openssl'
25
25
  autoload :FileUtils, 'fileutils'
26
26
  autoload :REXML, 'rexml/document'
27
+ autoload :CSV, 'csv'
27
28
  autoload :Mutex, 'thread' unless Object.const_defined?(:Mutex)
28
29
 
29
30
  #
@@ -60,6 +61,8 @@ module When
60
61
  # @option options [Numeric] :wikipedia_interval Wikipedia の連続的な参照を抑制するための遅延時間/秒
61
62
  # @option options [Array<String>] :order CalendarEra の検索順序 ([ IRI of When::TM::CalendarEra ])
62
63
  # @option options [Hash{String=>Array, String}] :format strftime で用いる記号の定義 ({ 記号=>[ 書式,項目名 ] or 記号列 })
64
+ # @option options [false, nil] :table_off 高精度テーブル使用の指定 - 使用する
65
+ # @option options [true] :table_off 高精度テーブル使用の指定 - 使用しない
63
66
  # @option options [Array<Array>] :leap_seconds 閏秒の挿入記録 ([ [JD, TAI-UTC, (MJD, OFFSET)] ])
64
67
  # @option options [String] :base_uri Base URI for When_exe Resources (Default When::SourceURI)
65
68
  # @option options [Hash<String=>String>] :additional_namespaces User defined namespaces (Default {})
@@ -89,6 +92,7 @@ module When
89
92
  TM::Calendar._setup_
90
93
  TM::Clock._setup_(options[:local])
91
94
  TM::TemporalPosition._setup_(options[:format])
95
+ CalendarNote::LuniSolarPositions._setup_(options[:table_off])
92
96
  V::Event._setup_(options[:until])
93
97
  V::Timezone._setup_
94
98
  Parts::Timezone._setup_
@@ -108,6 +112,7 @@ module When
108
112
  update(TM::CalendarEra._setup_info).
109
113
  update(TM::Clock._setup_info).
110
114
  update(TM::TemporalPosition._setup_info).
115
+ update(CalendarNote::LuniSolarPositions._setup_info).
111
116
  update(V::Event._setup_info).
112
117
  update(TimeStandard._setup_info)
113
118
  end
@@ -157,6 +162,7 @@ module When
157
162
 
158
163
  require 'when_exe/locales/locale'
159
164
  require 'when_exe/locales/autoload'
165
+ require 'when_exe/namespace'
160
166
  require 'when_exe/parts/enumerator'
161
167
  require 'when_exe/parts/resource'
162
168
  require 'when_exe/parts/geometric_complex'
@@ -165,11 +171,13 @@ module When
165
171
  require 'when_exe/basictypes'
166
172
  require 'when_exe/ephemeris'
167
173
  require 'when_exe/coordinates'
174
+ require 'when_exe/spatial'
168
175
  require 'when_exe/icalendar'
169
176
  require 'when_exe/google_api'
170
177
  require 'when_exe/tmobjects'
171
178
  require 'when_exe/timestandard'
172
179
  require 'when_exe/tmposition'
180
+ require 'when_exe/tmptypes'
173
181
  require 'when_exe/tmreference'
174
182
  require 'when_exe/calendartypes'
175
183
  require 'when_exe/calendarnote'
@@ -228,6 +236,14 @@ module When
228
236
  # eucJP encoding
229
237
  EUCJP = '.eucJP'
230
238
 
239
+ module Events
240
+ autoload :TS, 'when_exe/events'
241
+ autoload :DataSets, 'when_exe/events'
242
+ autoload :DataSet, 'when_exe/events'
243
+ autoload :Event, 'when_exe/events'
244
+ autoload :Range, 'when_exe/events'
245
+ end
246
+
231
247
  class BasicTypes::M17n
232
248
  autoload :Japanese, 'when_exe/region/japanese'
233
249
  autoload :JapaneseHoliday, 'when_exe/region/japanese'
@@ -244,6 +260,7 @@ module When
244
260
  autoload :Iranian, 'when_exe/region/iranian'
245
261
  autoload :Bahai, 'when_exe/region/bahai'
246
262
  autoload :Islamic, 'when_exe/region/islamic'
263
+ autoload :SaudiArabia, 'when_exe/region/saudi_arabian'
247
264
  autoload :Jewish, 'when_exe/region/jewish'
248
265
  autoload :AncientOrient, 'when_exe/region/babylonian'
249
266
  autoload :Armenian, 'when_exe/region/armenian'
@@ -272,6 +289,20 @@ module When
272
289
  autoload :IAST, 'when_exe/locales/iast'
273
290
  autoload :IASTR, 'when_exe/locales/iast'
274
291
  autoload :AKT, 'when_exe/locales/akt'
292
+ autoload :NumRExp3, 'when_exe/locales/akt'
293
+
294
+ sb = (When::Parts::Resource._instance('_co:Common::干支::*') +
295
+ When::Parts::Resource._instance('_co:Common::干::*') +
296
+ When::Parts::Resource._instance('_co:Common::支::*')).map {|r| r.label.to_s}.join('|')
297
+ DigitParser = [[:NumRExp3]]
298
+ TimeParser = [[/閏(\d+)時/, 'T\1='], [/(\d+)時/, 'T\1:'], [/(\d+)分/, '\1:'], [/(\d+)秒/, '\1']]
299
+ DateParser = [[/(#{sb})/, '{1\1}', true], [/([^\d])\{/, '\11{', true],
300
+ [/元年/, '1-'], [/(\d+|\})[年|載|歳]/, '\1-'], [/閏(\d+)月/, '\1='], [/(\d+)月/, '\1-'],
301
+ [/(\d+)日/, '\1']]
302
+ EasternParser = DigitParser + DateParser + TimeParser
303
+ JapaneseParser = [[/\A(\d+)/, '日本\1']] + EasternParser
304
+ KoreanParser = [[/\A(\d+)/, '朝鮮\1']] + EasternParser
305
+ ChineseParser = [[/\A(\d+)/, '中国\1']] + EasternParser
275
306
  end
276
307
 
277
308
  module CalendarTypes
@@ -294,6 +325,8 @@ module When
294
325
  autoload :IndianNationalSolar, 'when_exe/region/indian'
295
326
  autoload :Nanakshahi, 'when_exe/region/indian'
296
327
  autoload :RevisedBengali, 'when_exe/region/indian'
328
+ autoload :VikramSambatSolar, 'when_exe/region/indian'
329
+ autoload :VikramSamvatSolar, 'when_exe/region/indian'
297
330
  autoload :HinduLuniSolar, 'when_exe/region/indian'
298
331
  autoload :HinduSolar, 'when_exe/region/indian'
299
332
  autoload :Jalali, 'when_exe/region/iranian'
@@ -309,6 +342,7 @@ module When
309
342
  autoload :Bahai, 'when_exe/region/bahai'
310
343
  autoload :TabularIslamic, 'when_exe/region/islamic'
311
344
  autoload :EphemerisBasedIslamic, 'when_exe/region/islamic'
345
+ autoload :UmmalquraSolar, 'when_exe/region/saudi_arabian'
312
346
  autoload :Jewish, 'when_exe/region/jewish'
313
347
  autoload :Hebrew, 'when_exe/region/jewish'
314
348
  autoload :Armenian, 'when_exe/region/armenian'
@@ -360,6 +394,7 @@ module When
360
394
  end
361
395
 
362
396
  class CalendarNote
397
+ autoload :LuniSolarPositions, 'when_exe/ephemeris/notes'
363
398
  autoload :SolarTerms, 'when_exe/ephemeris/notes'
364
399
  autoload :LunarPhases, 'when_exe/ephemeris/notes'
365
400
  autoload :Ephemeris, 'when_exe/ephemeris/notes'
@@ -404,6 +439,7 @@ module When
404
439
  autoload :Russian, 'when_exe/region/russian'
405
440
  autoload :Roman, 'when_exe/region/roman'
406
441
  autoload :Mayan, 'when_exe/region/mayan'
442
+ autoload :LocationTable, 'when_exe/region/location'
407
443
 
408
444
  # default index for day coordinate
409
445
  DefaultDayIndex = Index.new
@@ -497,7 +533,8 @@ module When
497
533
  ['[M=,alias:明=ja:%%<明治>]6.01.01', '@CR', '1873-01-01^Gregorian?note=Default'],
498
534
  ['[T=,alias:大=ja:%%<大正>]1.07.30', '@A', '1912-07-30'],
499
535
  ['[S=,alias:昭=ja:%%<昭和>]1.12.25', '@A', '1926-12-25'],
500
- ['[H=,alias:平=ja:%%<平成>]1.01.08', '@A', '1989-01-08']
536
+ ['[H=,alias:平=ja:%%<平成>]1.01.08', '@A', '1989-01-08'],
537
+ ['[R=,alias:令=ja:%%<令和>]1.05.01', '@A', '2019-05-01']
501
538
  ]]
502
539
  end
503
540
  end
@@ -528,7 +565,7 @@ module When
528
565
  when Array ; begin options = TM::TemporalPosition._options(options) ; specification.map {|e| when?(e, options)} end
529
566
  when /\Atoday((\^|%5E){1,2}(.+))?\z/i ; today($3 ? {:frame=>$3}.update(options) : options)
530
567
  when /\Anow((\^|%5E){1,2}(.+))?\z/i ; now( $3 ? {:frame=>$3}.update(options) : options)
531
- when /(JDN|MJD|SDN|CEP)(\z|\^|%5E)/i ; TM::JulianDate.parse(specification, options)
568
+ when /(JDN|MJD|SDN|CEP|DTB)(\z|\^|%5E)/i ; TM::JulianDate.parse(specification, options)
532
569
  when /[\n\r]+/ ; when?(specification.split(/[\n\r]+/), options)
533
570
  when String ; TM::TemporalPosition._instance(EncodingConversion.to_internal_encoding(specification), options)
534
571
  when Numeric ; TM::JulianDate.new(+specification, TM::TemporalPosition._options(options))
@@ -561,6 +598,40 @@ module When
561
598
  alias :tm_pos :TemporalPosition
562
599
  module_function :tm_pos
563
600
 
601
+ # 書式文字列に従った When::TM::TemporalPosition の生成
602
+ #
603
+ # @param [String] date_time 日時を表す文字列
604
+ # @param [String] format その書式
605
+ # @param [Hash] options 暦法や時法などの指定
606
+ # @option options [String] :locale 言語指定
607
+ # @option options [Object] :その他 When::TM::TemporalPosition._instance に渡す
608
+ # @see When::TM::TemporalPosition._instance
609
+ #
610
+ # @return [When::TM::TemporalPosition]
611
+ # @raise [ArgumentError]
612
+ # options[ :invalid ] が :raise で、日時が存在しない場合
613
+ #
614
+ # see {strptime}[link:http://docs.ruby-lang.org/ja/search/query:strptime/]
615
+ #
616
+ def strptime(date_time, format, options={})
617
+ h = When::Locale._to_date_time_hash(date_time, format, options[:locale])
618
+ frame = options[:frame] ? When.Calendar(options[:frame]) : When::Gregorian
619
+ abbr_y, abbr_m, abbr_d, = options[:abbr].kind_of?(When::TimeValue) ?
620
+ (frame ^ options[:abbr]).cal_date : options[:abbr]
621
+ args = [h[:year] || abbr_y || ::Date.today.year]
622
+ args << (h[:mon] || abbr_m || 1) if h[:hour] || h[:mon]
623
+ args << (h[:mday] || abbr_d || 1) if h[:hour] || (h[:mon] && h[:mday])
624
+ args << h[:hour] if h[:hour]
625
+ args << h[:min] if h[:hour] && h[:min]
626
+ args << h[:sec] if h[:hour] && h[:min] && h[:sec]
627
+ args << options.dup
628
+ args[-1].delete(:locale)
629
+ args[-1].delete(:abbr)
630
+ args[-1].update({:parse=>{:residue=>{frame.indices.length=>When.Residue((h[:wday]-1)%7)}}}) if h[:wday]
631
+ args[-1].update({:clock=>When::TM::Clock.to_hms(h[:offset])}) if h[:offset]
632
+ TM::TemporalPosition._temporal_position(*args)
633
+ end
634
+
564
635
  # 指定日時に対応する When::TM::TemporalPosition の生成
565
636
  # (When::TM::DateAndTime of specified Time)
566
637
  #
@@ -709,6 +780,20 @@ module When
709
780
  TM::CalendarEra._instance(*args)
710
781
  end
711
782
 
783
+ # When::TM::TemporalPosition または When::TM::CalendarEraの検索
784
+ #
785
+ # @param [Array<Object>] args when? または era にそのまま渡される
786
+ #
787
+ # @return [When::TM::TemporalPosition or When::TM::CalendarEra]
788
+ #
789
+ def date_or_era(*args)
790
+ begin
791
+ when?(*args)
792
+ rescue
793
+ era(*args).first
794
+ end
795
+ end
796
+
712
797
  # When::TM::Clock の生成/参照
713
798
  #
714
799
  # @param [When::Parts::Timezone::Base] clock なにもせず clock をそのまま返す
@@ -782,6 +867,17 @@ module When
782
867
  Parts::Resource._instance(iri)
783
868
  end
784
869
 
870
+
871
+ # 地名を空間座標化する
872
+ #
873
+ # @param [String] name 地名または座標
874
+ #
875
+ # @return [When::Coordinates::Spatial or When::Coordinates::Spatial::Range]
876
+ #
877
+ def where?(name)
878
+ When::Coordinates::Spatial::Range[name]
879
+ end
880
+
785
881
  # When::Coordinates::Border の生成/参照
786
882
  #
787
883
  # @param [String] border 年/日境界を表す文字列
@@ -879,7 +975,7 @@ module When
879
975
  locale = options.delete(:locale) || 'en'
880
976
  title = EncodingConversion.to_internal_encoding(title)
881
977
  entry, query = title.split('?', 2)
882
- url = "http://#{locale}.wikipedia.org/wiki/#{URI.encode(entry).gsub(' ', '_')}"
978
+ url = "https://#{locale}.wikipedia.org/wiki/#{CGI.escape(entry).gsub(' ', '_')}"
883
979
  Locale.send(:wikipedia_object, url, options) unless options.empty?
884
980
  url += '?' + query if query
885
981
  object = Parts::Resource._instance(url)