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.
- checksums.yaml +5 -5
- data/LICENSE.ja.txt +8 -21
- data/LICENSE.txt +5 -27
- data/README.md +25 -79
- data/bin/.pryrc +9 -0
- data/bin/make_ttl.rb +3 -2
- data/bin/make_ttl.rb.config +3 -3
- data/lib/when_exe.rb +101 -5
- data/lib/when_exe/basictypes.rb +47 -16
- data/lib/when_exe/calendarnote.rb +27 -18
- data/lib/when_exe/calendartypes.rb +12 -50
- data/lib/when_exe/coordinates.rb +37 -391
- data/lib/when_exe/ephemeris.rb +53 -14
- data/lib/when_exe/ephemeris/eclipse.rb +8 -8
- data/lib/when_exe/ephemeris/moon.rb +333 -333
- data/lib/when_exe/ephemeris/notes.rb +29 -17
- data/lib/when_exe/ephemeris/phase_table.rb +825 -0
- data/lib/when_exe/ephemeris/term_table.rb +603 -0
- data/lib/when_exe/events.rb +1888 -0
- data/lib/when_exe/google_api.rb +26 -31
- data/lib/when_exe/icalendar.rb +129 -12
- data/lib/when_exe/inspect.rb +5 -5
- data/lib/when_exe/linkeddata.rb +43 -23
- data/lib/when_exe/locales/akt.rb +63 -0
- data/lib/when_exe/locales/encoding_conversion.rb +134 -134
- data/lib/when_exe/locales/iast.rb +90 -90
- data/lib/when_exe/locales/locale.rb +88 -18
- data/lib/when_exe/locales/transliteration_table.rb +62 -62
- data/lib/when_exe/mini_application.rb +14 -8
- data/lib/when_exe/namespace.rb +42 -0
- data/lib/when_exe/parts/enumerator.rb +16 -5
- data/lib/when_exe/parts/geometric_complex.rb +52 -2
- data/lib/when_exe/parts/method_cash.rb +229 -224
- data/lib/when_exe/parts/resource.rb +65 -35
- data/lib/when_exe/parts/timezone.rb +25 -34
- data/lib/when_exe/region/balinese.rb +5 -3
- data/lib/when_exe/region/chinese.rb +39 -11
- data/lib/when_exe/region/chinese/calendars.rb +1016 -1016
- data/lib/when_exe/region/chinese/epochs.rb +7 -7
- data/lib/when_exe/region/chinese/notes.rb +3 -3
- data/lib/when_exe/region/chinese/twins.rb +134 -11
- data/lib/when_exe/region/dee.rb +4 -4
- data/lib/when_exe/region/discordian.rb +1 -1
- data/lib/when_exe/region/geologicalage.rb +139 -128
- data/lib/when_exe/region/hanke_henry.rb +4 -4
- data/lib/when_exe/region/indian.rb +77 -8
- data/lib/when_exe/region/international_fixed.rb +3 -3
- data/lib/when_exe/region/islamic.rb +1 -1
- data/lib/when_exe/region/japanese.rb +12 -8
- data/lib/when_exe/region/japanese/calendars.rb +397 -397
- data/lib/when_exe/region/japanese/eclipses.rb +1194 -1194
- data/lib/when_exe/region/japanese/epochs.rb +8 -4
- data/lib/when_exe/region/japanese/location.rb +93 -0
- data/lib/when_exe/region/japanese/nihon_shoki.rb +70 -70
- data/lib/when_exe/region/japanese/notes.rb +57 -18
- data/lib/when_exe/region/japanese/residues.rb +33 -11
- data/lib/when_exe/region/japanese/twins.rb +27 -14
- data/lib/when_exe/region/japanese/weeks.rb +7 -7
- data/lib/when_exe/region/korean.rb +384 -384
- data/lib/when_exe/region/location.rb +40 -0
- data/lib/when_exe/region/martian.rb +1 -1
- data/lib/when_exe/region/mayan.rb +2 -2
- data/lib/when_exe/region/roman.rb +2 -2
- data/lib/when_exe/region/ryukyu.rb +101 -101
- data/lib/when_exe/region/saudi_arabian.rb +57 -0
- data/lib/when_exe/region/shire.rb +1 -1
- data/lib/when_exe/region/world.rb +3 -3
- data/lib/when_exe/region/zoroastrian.rb +1 -1
- data/lib/when_exe/spatial.rb +611 -0
- data/lib/when_exe/timestandard.rb +9 -7
- data/lib/when_exe/tmobjects.rb +34 -2
- data/lib/when_exe/tmposition.rb +225 -1322
- data/lib/when_exe/tmptypes.rb +1279 -0
- data/lib/when_exe/tmreference.rb +42 -7
- data/lib/when_exe/version.rb +3 -3
- data/test/events/example-datasets +6 -0
- data/test/events/history-dataset.csv +22 -0
- data/test/events/japanese-holiday-index.csv +28 -0
- data/test/events/japanese-holiday.csv +94 -0
- data/test/events/japanese-holiday.ttl +948 -0
- data/test/events/make_events_ttl.rb +18 -0
- data/test/events/mori_wikichoshi.csv +14 -0
- data/test/events/ndl_koyomi.csv +220 -0
- data/test/events/ndl_koyomi_index.csv +44 -0
- data/test/events/primeminister-dataset.csv +19 -0
- data/test/events/shogun-dataset.csv +22 -0
- data/test/events/test-history-dataset-edge-sparql.csv +26 -0
- data/test/events/test-history-dataset-edge.csv +27 -0
- data/test/events/test-history-dataset-sparql.csv +22 -0
- data/test/events/test-history-dataset.csv +23 -0
- data/test/events/test-history-events-edge.ttl +89 -0
- data/test/events/test-history-events.csv +6 -0
- data/test/examples/JapanHolidays.ics +2 -2
- data/test/examples/JapanHolidaysRFC6350.ics +3 -3
- data/test/examples/Residue.m17n +2 -2
- data/test/examples/Spatial.m17n +3 -3
- data/test/examples/Terms.m17n +3 -3
- data/test/scripts/8.ext.rb +6 -6
- data/test/scripts/8.rb +6 -6
- data/test/scripts/geometric_complex.rb +41 -41
- data/test/scripts/korea.rb +59 -59
- data/test/scripts/thai.rb +36 -36
- data/test/test.rb +6 -0
- data/test/test/basictypes.rb +431 -431
- data/test/test/calendarnote.rb +86 -86
- data/test/test/calendartypes.rb +97 -97
- data/test/test/coordinates.rb +399 -397
- data/test/test/ephemeris.rb +115 -115
- data/test/test/ephemeris/moon.rb +14 -14
- data/test/test/ephemeris/planets.rb +14 -14
- data/test/test/ephemeris/sun.rb +14 -14
- data/test/test/events.rb +32 -0
- data/test/test/google_api.rb +45 -32
- data/test/test/inspect.rb +153 -153
- data/test/test/parts.rb +488 -488
- data/test/test/region/armenian.rb +20 -20
- data/test/test/region/bahai.rb +58 -58
- data/test/test/region/balinese.rb +34 -34
- data/test/test/region/chinese.rb +229 -229
- data/test/test/region/christian.rb +226 -226
- data/test/test/region/coptic.rb +27 -27
- data/test/test/region/discordian.rb +20 -20
- data/test/test/region/french.rb +33 -33
- data/test/test/region/geologicalage.rb +17 -17
- data/test/test/region/indian.rb +14 -1
- data/test/test/region/iran.rb +54 -54
- data/test/test/region/islamic.rb +64 -54
- data/test/test/region/japanese.rb +281 -261
- data/test/test/region/jewish.rb +63 -63
- data/test/test/region/m17n.rb +21 -21
- data/test/test/region/mayan.rb +17 -16
- data/test/test/region/reforms.rb +2 -2
- data/test/test/region/residue.rb +7 -7
- data/test/test/region/shire.rb +58 -58
- data/test/test/region/swedish.rb +45 -45
- data/test/test/region/thai.rb +116 -116
- data/test/test/region/tibetan.rb +30 -30
- data/test/test/region/vietnamese.rb +102 -102
- data/test/test/region/zoroastrian.rb +58 -58
- data/test/test/timestandard.rb +81 -81
- data/test/test/tmobjects.rb +402 -402
- data/test/test/tmposition.rb +66 -4
- data/test/test/tmreference.rb +157 -157
- metadata +36 -93
data/test/test/ephemeris.rb
CHANGED
@@ -1,115 +1,115 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011-
|
4
|
-
|
5
|
-
You may use and/or modify this file according to the license
|
6
|
-
described in the LICENSE.txt file included in this archive.
|
7
|
-
=end
|
8
|
-
|
9
|
-
module MiniTest::Ephemeris
|
10
|
-
|
11
|
-
class Ephemeris < MiniTest::TestCase
|
12
|
-
def test_nothing
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class CelestialObject < MiniTest::TestCase
|
17
|
-
def test_nothing
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Star < MiniTest::TestCase
|
22
|
-
|
23
|
-
def test_nothing
|
24
|
-
end
|
25
|
-
|
26
|
-
# 恒星
|
27
|
-
class Fixed < MiniTest::TestCase
|
28
|
-
def test__access_hr
|
29
|
-
polaris = When::Resource('_sc:HR0424')
|
30
|
-
assert_equal("Alp UMi", polaris.bayer_name)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# 春分点
|
35
|
-
class Vernal < MiniTest::TestCase
|
36
|
-
def test_nothing
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
# 北極
|
41
|
-
class Pole < MiniTest::TestCase
|
42
|
-
def test_nothing
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
class Planet < MiniTest::TestCase
|
48
|
-
def test_nothing
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
class Coords < MiniTest::TestCase
|
53
|
-
def test_nothing
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
class Formula < MiniTest::TestCase
|
58
|
-
def test__sunrise
|
59
|
-
|
60
|
-
assert_raises(NoMethodError) { When.when?('2012-11-15').sunrise }
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
if Object.const_defined?(:TZInfo)
|
65
|
-
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15', :tz=>'Asia/Tokyo').sunrise.to_s)
|
66
|
-
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15', :tz=>'Asia/Tokyo', :location=>'_l:long=139.7414&lat=35.6581').sunrise.to_s)
|
67
|
-
else
|
68
|
-
puts
|
69
|
-
puts "Tests for TZInfo have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
70
|
-
end
|
71
|
-
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15T+09:00', :long=>139.7414, :lat=>35.6581).sunrise.to_s)
|
72
|
-
assert_equal(0, /2012-11-14T21:16/ =~ When.when?('2012-11-15', :long=>139.7414, :lat=>35.6581).sunrise.to_s)
|
73
|
-
|
74
|
-
today = '2014-3-4'
|
75
|
-
|
76
|
-
location = When.Location('long=139.413012E&lat=35.412222N')
|
77
|
-
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today, {:location=>location}).sunrise.to_s)
|
78
|
-
|
79
|
-
When::Coordinates::Spatial.default_location = location
|
80
|
-
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today).sunrise.to_s)
|
81
|
-
|
82
|
-
When::TM::Clock.local_time = '+09:00'
|
83
|
-
assert_equal(0, /2014-03-04T06:07/ =~ When.when?(today).sunrise.to_s)
|
84
|
-
end
|
85
|
-
|
86
|
-
def test__lunisolar_location
|
87
|
-
formula1 = When.Resource('_ep:Formula?formula=1L')
|
88
|
-
formula2 = When.Resource('_ep:Formula?formula=12S')
|
89
|
-
date = When.when?('2014-08-01', :clock=>'+09:00')
|
90
|
-
assert_equal('2014-07-27T07:41+09:00', formula1.nearest_past(date).floor(When::MINUTE).to_s)
|
91
|
-
assert_equal('2014-07-23T06:41+09:00', formula2.nearest_past(date).floor(When::MINUTE).to_s)
|
92
|
-
assert_equal('2014-07-07T13:15+09:00', formula2.nearest_past(date, 0.5).floor(When::MINUTE).to_s)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
if Object.const_defined?(:TZInfo)
|
97
|
-
class Note < MiniTest::TestCase
|
98
|
-
def test__tide
|
99
|
-
|
100
|
-
sample = [%w(2013-10-02T02:58+09:00 _n:Ephemeris/Notes::day::Tide::Low_Tide),
|
101
|
-
%w(2013-10-02T09:09+09:00 _n:Ephemeris/Notes::day::Tide::High_Tide),
|
102
|
-
%w(2013-10-02T15:20+09:00 _n:Ephemeris/Notes::day::Tide::Low_Tide),
|
103
|
-
%w(2013-10-02T21:32+09:00 _n:Ephemeris/Notes::day::Tide::High_Tide)]
|
104
|
-
|
105
|
-
note = When.CalendarNote('Ephemeris?interval=0.0')
|
106
|
-
date = When.when?('2013-10-02', :tz=>'Asia/Tokyo')
|
107
|
-
note.tide(date).each do |d|
|
108
|
-
assert_equal(sample.shift, [d.floor(When::MINUTE).to_s, d.events[0].iri(true)])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
else
|
113
|
-
puts "Tests for TZInfo have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
114
|
-
end
|
115
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011-2020 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module MiniTest::Ephemeris
|
10
|
+
|
11
|
+
class Ephemeris < MiniTest::TestCase
|
12
|
+
def test_nothing
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class CelestialObject < MiniTest::TestCase
|
17
|
+
def test_nothing
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Star < MiniTest::TestCase
|
22
|
+
|
23
|
+
def test_nothing
|
24
|
+
end
|
25
|
+
|
26
|
+
# 恒星
|
27
|
+
class Fixed < MiniTest::TestCase
|
28
|
+
def test__access_hr
|
29
|
+
polaris = When::Resource('_sc:HR0424')
|
30
|
+
assert_equal("Alp UMi", polaris.bayer_name)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# 春分点
|
35
|
+
class Vernal < MiniTest::TestCase
|
36
|
+
def test_nothing
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# 北極
|
41
|
+
class Pole < MiniTest::TestCase
|
42
|
+
def test_nothing
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class Planet < MiniTest::TestCase
|
48
|
+
def test_nothing
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class Coords < MiniTest::TestCase
|
53
|
+
def test_nothing
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
class Formula < MiniTest::TestCase
|
58
|
+
def test__sunrise
|
59
|
+
|
60
|
+
assert_raises(NoMethodError) { When.when?('2012-11-15').sunrise }
|
61
|
+
|
62
|
+
assert_nil(When.when?('2013-06-21T+09:00', :long=>135, :lat=>70).sunrise)
|
63
|
+
|
64
|
+
if Object.const_defined?(:TZInfo)
|
65
|
+
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15', :tz=>'Asia/Tokyo').sunrise.to_s)
|
66
|
+
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15', :tz=>'Asia/Tokyo', :location=>'_l:long=139.7414&lat=35.6581').sunrise.to_s)
|
67
|
+
else
|
68
|
+
puts
|
69
|
+
puts "Tests for TZInfo have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
70
|
+
end
|
71
|
+
assert_equal(0, /2012-11-15T06:16/ =~ When.when?('2012-11-15T+09:00', :long=>139.7414, :lat=>35.6581).sunrise.to_s)
|
72
|
+
assert_equal(0, /2012-11-14T21:16/ =~ When.when?('2012-11-15', :long=>139.7414, :lat=>35.6581).sunrise.to_s)
|
73
|
+
|
74
|
+
today = '2014-3-4'
|
75
|
+
|
76
|
+
location = When.Location('long=139.413012E&lat=35.412222N')
|
77
|
+
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today, {:location=>location}).sunrise.to_s)
|
78
|
+
|
79
|
+
When::Coordinates::Spatial.default_location = location
|
80
|
+
assert_equal(0, /2014-03-03T21:07/ =~ When.when?(today).sunrise.to_s)
|
81
|
+
|
82
|
+
When::TM::Clock.local_time = '+09:00'
|
83
|
+
assert_equal(0, /2014-03-04T06:07/ =~ When.when?(today).sunrise.to_s)
|
84
|
+
end
|
85
|
+
|
86
|
+
def test__lunisolar_location
|
87
|
+
formula1 = When.Resource('_ep:Formula?formula=1L')
|
88
|
+
formula2 = When.Resource('_ep:Formula?formula=12S')
|
89
|
+
date = When.when?('2014-08-01', :clock=>'+09:00')
|
90
|
+
assert_equal('2014-07-27T07:41+09:00', formula1.nearest_past(date).floor(When::MINUTE).to_s)
|
91
|
+
assert_equal('2014-07-23T06:41+09:00', formula2.nearest_past(date).floor(When::MINUTE).to_s)
|
92
|
+
assert_equal('2014-07-07T13:15+09:00', formula2.nearest_past(date, 0.5).floor(When::MINUTE).to_s)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
if Object.const_defined?(:TZInfo)
|
97
|
+
class Note < MiniTest::TestCase
|
98
|
+
def test__tide
|
99
|
+
|
100
|
+
sample = [%w(2013-10-02T02:58+09:00 _n:Ephemeris/Notes::day::Tide::Low_Tide),
|
101
|
+
%w(2013-10-02T09:09+09:00 _n:Ephemeris/Notes::day::Tide::High_Tide),
|
102
|
+
%w(2013-10-02T15:20+09:00 _n:Ephemeris/Notes::day::Tide::Low_Tide),
|
103
|
+
%w(2013-10-02T21:32+09:00 _n:Ephemeris/Notes::day::Tide::High_Tide)]
|
104
|
+
|
105
|
+
note = When.CalendarNote('Ephemeris?interval=0.0')
|
106
|
+
date = When.when?('2013-10-02', :tz=>'Asia/Tokyo')
|
107
|
+
note.tide(date).each do |d|
|
108
|
+
assert_equal(sample.shift, [d.floor(When::MINUTE).to_s, d.events[0].iri(true)])
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
else
|
113
|
+
puts "Tests for TZInfo have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
114
|
+
end
|
115
|
+
end
|
data/test/test/ephemeris/moon.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011 Takashi SUGA
|
4
|
-
|
5
|
-
You may use and/or modify this file according to the license
|
6
|
-
described in the LICENSE.txt file included in this archive.
|
7
|
-
=end
|
8
|
-
|
9
|
-
module MiniTest::Ephemeris
|
10
|
-
class Moon < MiniTest::TestCase
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module MiniTest::Ephemeris
|
10
|
+
class Moon < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011 Takashi SUGA
|
4
|
-
|
5
|
-
You may use and/or modify this file according to the license
|
6
|
-
described in the LICENSE.txt file included in this archive.
|
7
|
-
=end
|
8
|
-
|
9
|
-
module MiniTest::Ephemeris
|
10
|
-
class Planets < MiniTest::TestCase
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module MiniTest::Ephemeris
|
10
|
+
class Planets < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/test/ephemeris/sun.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
=begin
|
3
|
-
Copyright (C) 2011 Takashi SUGA
|
4
|
-
|
5
|
-
You may use and/or modify this file according to the license
|
6
|
-
described in the LICENSE.txt file included in this archive.
|
7
|
-
=end
|
8
|
-
|
9
|
-
module MiniTest::Ephemeris
|
10
|
-
class Sun < MiniTest::TestCase
|
11
|
-
def test_nothing
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2011 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module MiniTest::Ephemeris
|
10
|
+
class Sun < MiniTest::TestCase
|
11
|
+
def test_nothing
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/test/test/events.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
=begin
|
3
|
+
Copyright (C) 2015-2016 Takashi SUGA
|
4
|
+
|
5
|
+
You may use and/or modify this file according to the license
|
6
|
+
described in the LICENSE.txt file included in this archive.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module MiniTest::CalendarTypes
|
10
|
+
|
11
|
+
class DataSet < MiniTest::TestCase
|
12
|
+
if (RUBY_VERSION.split('.').map {|v| v.to_i} <=> [1,9]) >= 0
|
13
|
+
def test__dataset
|
14
|
+
datasets = When.Resource('events/test-history-dataset.csv')
|
15
|
+
dataset = datasets.dataset('en')
|
16
|
+
assert_equal([5], dataset.index[When::Events::WHAT_DAY][[false, 1, 2]])
|
17
|
+
assert_equal([5, 1], dataset.edge_included(When::Events::START, When.when?('-Infinity...1256-11-23^^Japanese')))
|
18
|
+
assert_equal([5, 1, 2], dataset.edge_included(When::Events::START, When.when?('-Infinity..1256-11-23^^Japanese')))
|
19
|
+
assert_equal([1], dataset.edge_included(When::Events::START, When.when?('1256-11-22...1256-11-23^^Japanese')))
|
20
|
+
assert_equal([1, 2], dataset.edge_included(When::Events::START, When.when?('1256-11-22/23^^Japanese')))
|
21
|
+
assert_equal([2], dataset.edge_included(When::Events::START, When.when?('1256-11-23...1555-10-01^^Japanese')))
|
22
|
+
assert_equal([2, 3], dataset.edge_included(When::Events::START, When.when?('1256-11-23..1555-10-01^^Japanese')))
|
23
|
+
assert_equal([2, 3, 4], dataset.edge_included(When::Events::START, When.when?('1256-11-23..+Infinity^^Japanese')))
|
24
|
+
end
|
25
|
+
else
|
26
|
+
def test__dataset
|
27
|
+
end
|
28
|
+
puts "Tests for event DataSet have been skipped at line #{__LINE__} of #{__FILE__.split(/\//)[-1]}."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/test/test/google_api.rb
CHANGED
@@ -1,56 +1,69 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
=begin
|
3
|
-
Copyright (C) 2015 Takashi SUGA
|
3
|
+
Copyright (C) 2015-2021 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.
|
7
|
+
|
8
|
+
Before running this script, please create "credentials.json" and "token.yaml" by
|
9
|
+
running quickstart.rb according to the Quick Start description at the URL below,
|
10
|
+
and place them in the same directory as test.rb.
|
11
|
+
|
12
|
+
https://developers.google.com/calendar/quickstart/ruby
|
13
|
+
|
7
14
|
=end
|
8
15
|
|
9
16
|
require 'fileutils'
|
10
|
-
|
11
|
-
require
|
17
|
+
if FileTest.exist?("token.yaml")
|
18
|
+
require "google/apis/calendar_v3"
|
19
|
+
require "googleauth"
|
20
|
+
require "googleauth/stores/file_token_store"
|
21
|
+
end
|
12
22
|
|
13
23
|
module MiniTest
|
14
24
|
|
15
25
|
class GoogleAPI < MiniTest::TestCase
|
16
26
|
|
17
27
|
HOLIDAYS = [
|
18
|
-
["
|
19
|
-
["
|
20
|
-
["
|
21
|
-
["
|
22
|
-
["
|
23
|
-
["
|
24
|
-
["
|
25
|
-
["
|
26
|
-
["
|
27
|
-
["
|
28
|
-
["
|
29
|
-
["
|
30
|
-
["
|
31
|
-
["
|
32
|
-
["
|
33
|
-
["
|
34
|
-
["
|
28
|
+
["2021-01-01", "New Year's Day"],
|
29
|
+
["2021-01-11", "Coming of Age Day"],
|
30
|
+
["2021-02-11", "National Foundation Day"],
|
31
|
+
["2021-02-23", "Emperor's Birthday"],
|
32
|
+
["2021-03-20", "Spring Equinox"],
|
33
|
+
["2021-04-29", "Shōwa Day"],
|
34
|
+
["2021-05-03", "Constitution Memorial Day"],
|
35
|
+
["2021-05-04", "Greenery Day"],
|
36
|
+
["2021-05-05", "Children's Day"],
|
37
|
+
["2021-07-22", "Sea Day"],
|
38
|
+
["2021-07-23", "Sports Day"],
|
39
|
+
["2021-08-08", "Mountain Day"],
|
40
|
+
["2021-08-09", "Day off for Mountain Day"],
|
41
|
+
["2021-09-20", "Respect for the Aged Day"],
|
42
|
+
["2021-09-23", "Autumn Equinox"],
|
43
|
+
["2021-11-03", "Culture Day"],
|
44
|
+
["2021-11-23", "Labor Thanksgiving Day"]
|
35
45
|
]
|
36
46
|
|
37
|
-
|
47
|
+
def authorize
|
48
|
+
client_id = Google::Auth::ClientId.from_file "credentials.json"
|
49
|
+
scope = Google::Apis::CalendarV3::AUTH_CALENDAR_READONLY
|
50
|
+
token_store = Google::Auth::Stores::FileTokenStore.new file: "token.yaml"
|
51
|
+
authorizer = Google::Auth::UserAuthorizer.new client_id, scope, token_store
|
52
|
+
authorizer.get_credentials "default"
|
53
|
+
end
|
54
|
+
|
55
|
+
if FileTest.exist?("token.yaml")
|
38
56
|
|
39
57
|
def test__enum_for
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
client.authorization.scope = oauth_yaml["scope"]
|
46
|
-
client.authorization.refresh_token = oauth_yaml["refresh_token"]
|
47
|
-
client.authorization.access_token = oauth_yaml["access_token"]
|
48
|
-
service = client.discovered_api('calendar', 'v3')
|
49
|
-
calendar = When::GoogleAPI::Calendar.list(client, service,
|
58
|
+
service = Google::Apis::CalendarV3::CalendarService.new
|
59
|
+
service.client_options.application_name = "Google Calendar API Ruby Test"
|
60
|
+
service.authorization = authorize
|
61
|
+
|
62
|
+
calendar = When::GoogleAPI::Calendar.list(service,
|
50
63
|
'en.japanese#holiday@group.v.calendar.google.com')
|
51
64
|
assert_equal(calendar.calendar_id, 'en.japanese#holiday@group.v.calendar.google.com')
|
52
65
|
holidays = HOLIDAYS.dup
|
53
|
-
calendar.enum_for(When.when?('
|
66
|
+
calendar.enum_for(When.when?('20210101/1231')).each do |date|
|
54
67
|
assert_equal(holidays.shift, [date.to_s, date.events[0].summary])
|
55
68
|
end
|
56
69
|
assert_equal([], holidays)
|