lita-onewheel-moonphase 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_moonphase.rb +28 -1
- data/lita-onewheel-moonphase.gemspec +1 -1
- data/spec/fixtures/moon_first_quarter.json +25 -0
- data/spec/fixtures/moon_last_quarter.json +25 -0
- data/spec/fixtures/moon_waning_crescent.json +25 -0
- data/spec/fixtures/moon_waning_gibbous.json +25 -0
- data/spec/fixtures/{moon.json → moon_waxing_crescent.json} +1 -1
- data/spec/fixtures/moon_waxing_gibbous.json +25 -0
- data/spec/lita/handlers/onewheel_moonphase_spec.rb +37 -3
- metadata +13 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 183a754e5ff2c25a117568596c0caa002e62b8fe
|
4
|
+
data.tar.gz: fc8f1303613a395dcfb0fe0b18c921ff0f6d5c0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae62b04972b4b3a0d71fe661d0a0f39b88274b2576188dce8d60bf173fe16605a035532134da5c40650bd13262eac62fa1f2969a8c2f14cba920103841cfd16e
|
7
|
+
data.tar.gz: f4154c2e2296e9ea8a9d88ed9ca587522a05f1f312864ab9b664dd8d0a498b3d8711fc59480733f25c9a4c909a1900cb733b22da69fcbc83974d2481c314e6a7
|
@@ -8,6 +8,9 @@ module Lita
|
|
8
8
|
command: true,
|
9
9
|
help: {'moon [location]' => 'Get Moon phase data'}
|
10
10
|
|
11
|
+
# 🌑🌛
|
12
|
+
# emoonjis = %w(🌚🌘🌗🌔🌕🌖🌓🌒)
|
13
|
+
|
11
14
|
def moon(response)
|
12
15
|
location = get_location(response)
|
13
16
|
|
@@ -17,7 +20,7 @@ module Lita
|
|
17
20
|
rise_time = Time.parse moon['moondata']['rise']
|
18
21
|
set_time = Time.parse moon['moondata']['set']
|
19
22
|
|
20
|
-
reply = "Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}. "
|
23
|
+
reply = "#{get_moonmoji(moon['moondata']['fracillum'], moon['moondata']['curphase'])} Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}. "
|
21
24
|
reply += "Rise: #{rise_time.strftime("%H:%M")} Set: #{set_time.strftime('%H:%M')}"
|
22
25
|
Lita.logger.debug "Replying with #{reply}"
|
23
26
|
response.reply reply
|
@@ -40,6 +43,30 @@ module Lita
|
|
40
43
|
location
|
41
44
|
end
|
42
45
|
|
46
|
+
# Next step, determine waxing or waning.
|
47
|
+
def get_moonmoji(percent_full, phase)
|
48
|
+
moonmoji = ''
|
49
|
+
waning = false
|
50
|
+
|
51
|
+
if phase.match /waning/i
|
52
|
+
waning = true
|
53
|
+
end
|
54
|
+
|
55
|
+
case percent_full.sub('%', '').to_i
|
56
|
+
when 0..1
|
57
|
+
moonmoji = '🌚'
|
58
|
+
when 2..32
|
59
|
+
moonmoji = waning ? '🌘' : '🌒'
|
60
|
+
when 33..62
|
61
|
+
moonmoji = phase.match(/last/i) ? '🌗' : '🌓'
|
62
|
+
when 63..90
|
63
|
+
moonmoji = waning ? '🌖' : '🌔'
|
64
|
+
when 91..100
|
65
|
+
moonmoji = '🌕'
|
66
|
+
end
|
67
|
+
moonmoji
|
68
|
+
end
|
69
|
+
|
43
70
|
Lita.register_handler(self)
|
44
71
|
end
|
45
72
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-moonphase'
|
3
|
-
spec.version = '
|
3
|
+
spec.version = '2.0.0'
|
4
4
|
spec.authors = ['Andrew Kreps']
|
5
5
|
spec.email = ['andrew.kreps@gmail.com']
|
6
6
|
spec.description = %q{Lita interface to a lambda representing Moon phase data.}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"year": 2017,
|
3
|
+
"month": 8,
|
4
|
+
"day": 27,
|
5
|
+
"dayOfWeek": "Sunday",
|
6
|
+
"lng": -122.676552,
|
7
|
+
"lat": 45.523316,
|
8
|
+
"location": "45.5230622,-122.6764816",
|
9
|
+
"address": "11 NW 6th Ave, Portland, OR 97209, USA",
|
10
|
+
"tz": -8,
|
11
|
+
"sundata": {
|
12
|
+
"civilRise": "2017-8-27T04:55:00-8",
|
13
|
+
"rise": "2017-8-27T05:26:00-8",
|
14
|
+
"transit": "2017-8-27T12:12:00-8",
|
15
|
+
"set": "2017-8-27T18:57:00-8",
|
16
|
+
"civilSet": "2017-8-27T19:28:00-8"
|
17
|
+
},
|
18
|
+
"moondata": {
|
19
|
+
"fracillum": "35%",
|
20
|
+
"curphase": "First Quarter",
|
21
|
+
"rise": "2017-8-27T11:45:00-8",
|
22
|
+
"transit": "2017-8-27T17:03:00-8",
|
23
|
+
"set": "2017-8-27T22:16:00-8"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"year": 2017,
|
3
|
+
"month": 8,
|
4
|
+
"day": 27,
|
5
|
+
"dayOfWeek": "Sunday",
|
6
|
+
"lng": -122.676552,
|
7
|
+
"lat": 45.523316,
|
8
|
+
"location": "45.5230622,-122.6764816",
|
9
|
+
"address": "11 NW 6th Ave, Portland, OR 97209, USA",
|
10
|
+
"tz": -8,
|
11
|
+
"sundata": {
|
12
|
+
"civilRise": "2017-8-27T04:55:00-8",
|
13
|
+
"rise": "2017-8-27T05:26:00-8",
|
14
|
+
"transit": "2017-8-27T12:12:00-8",
|
15
|
+
"set": "2017-8-27T18:57:00-8",
|
16
|
+
"civilSet": "2017-8-27T19:28:00-8"
|
17
|
+
},
|
18
|
+
"moondata": {
|
19
|
+
"fracillum": "35%",
|
20
|
+
"curphase": "Last Quarter",
|
21
|
+
"rise": "2017-8-27T11:45:00-8",
|
22
|
+
"transit": "2017-8-27T17:03:00-8",
|
23
|
+
"set": "2017-8-27T22:16:00-8"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"year": 2017,
|
3
|
+
"month": 8,
|
4
|
+
"day": 27,
|
5
|
+
"dayOfWeek": "Sunday",
|
6
|
+
"lng": -122.676552,
|
7
|
+
"lat": 45.523316,
|
8
|
+
"location": "45.5230622,-122.6764816",
|
9
|
+
"address": "11 NW 6th Ave, Portland, OR 97209, USA",
|
10
|
+
"tz": -8,
|
11
|
+
"sundata": {
|
12
|
+
"civilRise": "2017-8-27T04:55:00-8",
|
13
|
+
"rise": "2017-8-27T05:26:00-8",
|
14
|
+
"transit": "2017-8-27T12:12:00-8",
|
15
|
+
"set": "2017-8-27T18:57:00-8",
|
16
|
+
"civilSet": "2017-8-27T19:28:00-8"
|
17
|
+
},
|
18
|
+
"moondata": {
|
19
|
+
"fracillum": "15%",
|
20
|
+
"curphase": "Waning Crescent",
|
21
|
+
"rise": "2017-8-27T11:45:00-8",
|
22
|
+
"transit": "2017-8-27T17:03:00-8",
|
23
|
+
"set": "2017-8-27T22:16:00-8"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"year": 2017,
|
3
|
+
"month": 8,
|
4
|
+
"day": 27,
|
5
|
+
"dayOfWeek": "Sunday",
|
6
|
+
"lng": -122.676552,
|
7
|
+
"lat": 45.523316,
|
8
|
+
"location": "45.5230622,-122.6764816",
|
9
|
+
"address": "11 NW 6th Ave, Portland, OR 97209, USA",
|
10
|
+
"tz": -8,
|
11
|
+
"sundata": {
|
12
|
+
"civilRise": "2017-8-27T04:55:00-8",
|
13
|
+
"rise": "2017-8-27T05:26:00-8",
|
14
|
+
"transit": "2017-8-27T12:12:00-8",
|
15
|
+
"set": "2017-8-27T18:57:00-8",
|
16
|
+
"civilSet": "2017-8-27T19:28:00-8"
|
17
|
+
},
|
18
|
+
"moondata": {
|
19
|
+
"fracillum": "75%",
|
20
|
+
"curphase": "Waning Gibbous",
|
21
|
+
"rise": "2017-8-27T11:45:00-8",
|
22
|
+
"transit": "2017-8-27T17:03:00-8",
|
23
|
+
"set": "2017-8-27T22:16:00-8"
|
24
|
+
}
|
25
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"year": 2017,
|
3
|
+
"month": 8,
|
4
|
+
"day": 27,
|
5
|
+
"dayOfWeek": "Sunday",
|
6
|
+
"lng": -122.676552,
|
7
|
+
"lat": 45.523316,
|
8
|
+
"location": "45.5230622,-122.6764816",
|
9
|
+
"address": "11 NW 6th Ave, Portland, OR 97209, USA",
|
10
|
+
"tz": -8,
|
11
|
+
"sundata": {
|
12
|
+
"civilRise": "2017-8-27T04:55:00-8",
|
13
|
+
"rise": "2017-8-27T05:26:00-8",
|
14
|
+
"transit": "2017-8-27T12:12:00-8",
|
15
|
+
"set": "2017-8-27T18:57:00-8",
|
16
|
+
"civilSet": "2017-8-27T19:28:00-8"
|
17
|
+
},
|
18
|
+
"moondata": {
|
19
|
+
"fracillum": "75%",
|
20
|
+
"curphase": "Waxing Gibbous",
|
21
|
+
"rise": "2017-8-27T11:45:00-8",
|
22
|
+
"transit": "2017-8-27T17:03:00-8",
|
23
|
+
"set": "2017-8-27T22:16:00-8"
|
24
|
+
}
|
25
|
+
}
|
@@ -4,10 +4,44 @@ describe Lita::Handlers::OnewheelMoonphase, lita_handler: true do
|
|
4
4
|
it { is_expected.to route_command('moon') }
|
5
5
|
it { is_expected.to route_command('moon portland') }
|
6
6
|
|
7
|
-
|
8
|
-
mock = File.open(
|
7
|
+
def load_mock(file)
|
8
|
+
mock = File.open("spec/fixtures/#{file}.json").read
|
9
9
|
allow(RestClient).to receive(:get) { mock }
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'waning crescent' do
|
13
|
+
load_mock('moon_waning_crescent')
|
14
|
+
send_command 'moon'
|
15
|
+
expect(replies.last).to eq('🌘 Moon phase 15%, Waning Crescent. Rise: 11:45 Set: 22:16')
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'waxing crescent' do
|
19
|
+
load_mock('moon_waxing_crescent')
|
20
|
+
send_command 'moon'
|
21
|
+
expect(replies.last).to eq('🌒 Moon phase 13%, Waxing Crescent. Rise: 11:45 Set: 22:16')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'first_quarter' do
|
25
|
+
load_mock('moon_first_quarter')
|
26
|
+
send_command 'moon'
|
27
|
+
expect(replies.last).to eq('🌓 Moon phase 35%, First Quarter. Rise: 11:45 Set: 22:16')
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'last quarter' do
|
31
|
+
load_mock('moon_last_quarter')
|
32
|
+
send_command 'moon'
|
33
|
+
expect(replies.last).to eq('🌗 Moon phase 35%, Last Quarter. Rise: 11:45 Set: 22:16')
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'waning gibbous' do
|
37
|
+
load_mock('moon_waning_gibbous')
|
38
|
+
send_command 'moon'
|
39
|
+
expect(replies.last).to eq('🌖 Moon phase 75%, Waning Gibbous. Rise: 11:45 Set: 22:16')
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'waxing gibbous' do
|
43
|
+
load_mock('moon_waxing_gibbous')
|
10
44
|
send_command 'moon'
|
11
|
-
expect(replies.last).to eq('Moon phase
|
45
|
+
expect(replies.last).to eq('🌔 Moon phase 75%, Waxing Gibbous. Rise: 11:45 Set: 22:16')
|
12
46
|
end
|
13
47
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-moonphase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
@@ -138,7 +138,12 @@ files:
|
|
138
138
|
- lib/lita-onewheel-moonphase.rb
|
139
139
|
- lib/lita/handlers/onewheel_moonphase.rb
|
140
140
|
- lita-onewheel-moonphase.gemspec
|
141
|
-
- spec/fixtures/
|
141
|
+
- spec/fixtures/moon_first_quarter.json
|
142
|
+
- spec/fixtures/moon_last_quarter.json
|
143
|
+
- spec/fixtures/moon_waning_crescent.json
|
144
|
+
- spec/fixtures/moon_waning_gibbous.json
|
145
|
+
- spec/fixtures/moon_waxing_crescent.json
|
146
|
+
- spec/fixtures/moon_waxing_gibbous.json
|
142
147
|
- spec/lita/handlers/onewheel_moonphase_spec.rb
|
143
148
|
- spec/spec_helper.rb
|
144
149
|
homepage: https://github.com/onewheelskyward/lita-onewheel-moonphase
|
@@ -167,6 +172,11 @@ signing_key:
|
|
167
172
|
specification_version: 4
|
168
173
|
summary: Lita interface to a lambda representing Moon phase data.
|
169
174
|
test_files:
|
170
|
-
- spec/fixtures/
|
175
|
+
- spec/fixtures/moon_first_quarter.json
|
176
|
+
- spec/fixtures/moon_last_quarter.json
|
177
|
+
- spec/fixtures/moon_waning_crescent.json
|
178
|
+
- spec/fixtures/moon_waning_gibbous.json
|
179
|
+
- spec/fixtures/moon_waxing_crescent.json
|
180
|
+
- spec/fixtures/moon_waxing_gibbous.json
|
171
181
|
- spec/lita/handlers/onewheel_moonphase_spec.rb
|
172
182
|
- spec/spec_helper.rb
|