lita-onewheel-moonphase 1.0.0 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b601c31654b9f635df46a9e42fa8c6c41e00e0d
4
- data.tar.gz: d1d2585d746d61aa58a0b1bc043f48e70904fc4b
3
+ metadata.gz: 183a754e5ff2c25a117568596c0caa002e62b8fe
4
+ data.tar.gz: fc8f1303613a395dcfb0fe0b18c921ff0f6d5c0a
5
5
  SHA512:
6
- metadata.gz: 54ebd8c8590fbd07da4fbe89c3fe91a4764cde116914124f74e1613093b6d40504da3b5a5a698e4c967ceb841e12756dec9f57a77a78f0d182c709ec64209444
7
- data.tar.gz: a5cc314cca06a484062af7c42371ab7adfaeb6b6eb2f85e11832f44fdc01da177b4b368c6d0d8d5a604b38e4e2d94c0b83c77e940e7d8f9f09a3b0c82296b5c8
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 = '1.0.0'
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
+ }
@@ -16,7 +16,7 @@
16
16
  "civilSet": "2017-8-27T19:28:00-8"
17
17
  },
18
18
  "moondata": {
19
- "fracillum": "36%",
19
+ "fracillum": "13%",
20
20
  "curphase": "Waxing Crescent",
21
21
  "rise": "2017-8-27T11:45:00-8",
22
22
  "transit": "2017-8-27T17:03:00-8",
@@ -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
- it 'shows the current moon phase.' do
8
- mock = File.open('spec/fixtures/moon.json').read
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 36%, Waxing Crescent. Rise: 11:45 Set: 22:16')
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: 1.0.0
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/moon.json
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/moon.json
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