lita-onewheel-moonphase 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 160599d169949c19a781203bb0e25315e37c5330
4
- data.tar.gz: a1cf4b6776b011b68566bf9c2b2b0c8ee4064426
3
+ metadata.gz: 9b601c31654b9f635df46a9e42fa8c6c41e00e0d
4
+ data.tar.gz: d1d2585d746d61aa58a0b1bc043f48e70904fc4b
5
5
  SHA512:
6
- metadata.gz: c4b5dc93d71d16154308c5599500f4183b77e495433a8e9af7c4d3b24f3aac124e5458bfc69c823d8065178c8d58af74ff10b0b843f3d2729845523e8b0b57c7
7
- data.tar.gz: d97944a364b3996eb9930b60028907aeba37f86832912d62ba5941dca5d4a8904abcf2b09f1c11adbd5c9376600d2c72251d1ab76bc4803206c3f1c574db3b57
6
+ metadata.gz: 54ebd8c8590fbd07da4fbe89c3fe91a4764cde116914124f74e1613093b6d40504da3b5a5a698e4c967ceb841e12756dec9f57a77a78f0d182c709ec64209444
7
+ data.tar.gz: a5cc314cca06a484062af7c42371ab7adfaeb6b6eb2f85e11832f44fdc01da177b4b368c6d0d8d5a604b38e4e2d94c0b83c77e940e7d8f9f09a3b0c82296b5c8
@@ -9,44 +9,38 @@ module Lita
9
9
  help: {'moon [location]' => 'Get Moon phase data'}
10
10
 
11
11
  def moon(response)
12
- location = response.matches[0][0]
12
+ location = get_location(response)
13
13
 
14
- if location.empty?
15
- location = '45.5230622,-122.6764816'
16
- end
14
+ moon = get_data(location)
15
+
16
+ # today = Time.now
17
+ rise_time = Time.parse moon['moondata']['rise']
18
+ set_time = Time.parse moon['moondata']['set']
19
+
20
+ reply = "Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}. "
21
+ reply += "Rise: #{rise_time.strftime("%H:%M")} Set: #{set_time.strftime('%H:%M')}"
22
+ Lita.logger.debug "Replying with #{reply}"
23
+ response.reply reply
24
+ end
17
25
 
26
+ def get_data(location)
18
27
  Lita.logger.debug "Getting Moon data for #{location}"
19
28
  uri = "https://j8jqi56gye.execute-api.us-west-2.amazonaws.com/prod/moon?loc=#{URI.encode location}"
20
29
  Lita.logger.debug uri
21
- moon = JSON.parse(RestClient.get(uri))
30
+ JSON.parse(RestClient.get(uri))
31
+ end
22
32
 
23
- reply = "Moon phase #{moon['moondata']['fracillum']}, #{moon['moondata']['curphase']}."
24
- Lita.logger.debug "Replying with #{reply}"
25
- response.reply reply
33
+ def get_location(response)
34
+ location = response.matches[0][0]
35
+
36
+ if location.empty?
37
+ location = '45.5230622,-122.6764816'
38
+ end
39
+
40
+ location
26
41
  end
27
42
 
28
43
  Lita.register_handler(self)
29
44
  end
30
45
  end
31
46
  end
32
- {
33
- "year": 2016,
34
- "month": 11,
35
- "day": 18,
36
- "dayOfWeek": "Friday",
37
- "lng": -122.186048,
38
- "lat": 45.205518,
39
- "tz": -8,
40
- "sundata": {
41
- "civilRise": "06:40",
42
- "rise": "07:12",
43
- "transit": "11:54",
44
- "set": "16:36",
45
- "civilSet": "17:08"
46
- },
47
- "moondata": {
48
- "transit": "03:45",
49
- "set": "11:16",
50
- "rise": "21:14"
51
- }
52
- }
@@ -1,10 +1,10 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-moonphase'
3
- spec.version = '0.0.0'
3
+ spec.version = '1.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.}
7
- spec.summary = %q{See above.}
7
+ spec.summary = spec.description
8
8
  spec.homepage = 'https://github.com/onewheelskyward/lita-onewheel-moonphase'
9
9
  spec.license = 'MIT'
10
10
  spec.metadata = { 'lita_plugin_type' => 'handler' }
@@ -1,23 +1,25 @@
1
1
  {
2
- "year": 2016,
3
- "month": 11,
4
- "day": 18,
5
- "dayOfWeek": "Friday",
6
- "lng": -122.186048,
7
- "lat": 45.205518,
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",
8
10
  "tz": -8,
9
11
  "sundata": {
10
- "civilRise": "06:40",
11
- "rise": "07:12",
12
- "transit": "11:54",
13
- "set": "16:36",
14
- "civilSet": "17:08"
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"
15
17
  },
16
18
  "moondata": {
17
- "fracillum": "76%",
18
- "curphase": "Waning Gibbous",
19
- "transit": "03:45",
20
- "set": "11:16",
21
- "rise": "21:14"
19
+ "fracillum": "36%",
20
+ "curphase": "Waxing 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"
22
24
  }
23
25
  }
@@ -8,6 +8,6 @@ describe Lita::Handlers::OnewheelMoonphase, lita_handler: true do
8
8
  mock = File.open('spec/fixtures/moon.json').read
9
9
  allow(RestClient).to receive(:get) { mock }
10
10
  send_command 'moon'
11
- expect(replies.last).to eq("Moon phase 76%, Waning Gibbous.")
11
+ expect(replies.last).to eq('Moon phase 36%, Waxing Crescent. Rise: 11:45 Set: 22:16')
12
12
  end
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-moonphase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-18 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -162,10 +162,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  requirements: []
164
164
  rubyforge_project:
165
- rubygems_version: 2.5.1
165
+ rubygems_version: 2.5.2
166
166
  signing_key:
167
167
  specification_version: 4
168
- summary: See above.
168
+ summary: Lita interface to a lambda representing Moon phase data.
169
169
  test_files:
170
170
  - spec/fixtures/moon.json
171
171
  - spec/lita/handlers/onewheel_moonphase_spec.rb