lita-onewheel-forecast-io 0.1.0 → 0.1.1

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: c77c755bedbee74f17703c30b13b7490252e98b4
4
- data.tar.gz: 7da86bdd011f972083d6a4f475aae630cffc7344
3
+ metadata.gz: f4b44a03d3d25a90686c1988820639d662f072cd
4
+ data.tar.gz: a523d787ccd37b49e40658bd372383eec8033735
5
5
  SHA512:
6
- metadata.gz: cbec25862c6ca80d83d771cae2d992bb302279052c071aa7904f42d593a631f07a4f72debc0209de19f3a888b9854395be63040cf084fc1d62eab1e028db8eb0
7
- data.tar.gz: 9238a0aeb45b29ef4d766a80828f187eb98a91c52b9c9d90d9b37ddb797c0adad7631c0dfa8f347d8b1a0290eff02224717e07d8e494d58478414dcd6f4cb0c0
6
+ metadata.gz: d88668247347f49f22d655b7b9b18d9e18038f6751afa8773a55d2fb20fcd890235e3f362fe71e67244f6e052caa794624066799a75831fe536ca8247ce995ee
7
+ data.tar.gz: 03b5fa29ac34e836735a63374322e895fc6475ee329b8e1d7e82f88e873e354cf8fd0909a56e2b51cda4bc4f391db4ac6888d19e2d173cd7627823f19605acc8
@@ -1,3 +1,4 @@
1
+ require 'geocoder'
1
2
  module ForecastIo
2
3
  module Utils
3
4
  REDIS_KEY = 'forecast_io'
@@ -55,8 +56,21 @@ module ForecastIo
55
56
  geocoded
56
57
  end
57
58
 
59
+ # Perform a geocoder lookup based on a) the query or b) the user's serialized state.
60
+ # If neither of those exist, default to Portland.
58
61
  def geo_lookup(user, query)
59
62
  Lita.logger.debug "Performing geolookup for '#{user.name}' for '#{query}'"
63
+
64
+ default_location = {
65
+ 'formatted_address' => 'Portland, OR',
66
+ 'geometry' => {
67
+ 'location' => {
68
+ 'lat' => 45.5230622,
69
+ 'lng' => -122.6764816
70
+ }
71
+ }
72
+ }
73
+
60
74
  if query.nil? or query.empty?
61
75
  Lita.logger.debug "No query specified, pulling from redis #{REDIS_KEY}, #{user.name}"
62
76
  serialized_geocoded = redis.hget(REDIS_KEY, user.name)
@@ -67,9 +81,6 @@ module ForecastIo
67
81
  end
68
82
 
69
83
  Lita.logger.debug "q & g #{query.inspect} #{geocoded.inspect}"
70
- if (query.nil? or query.empty?) and geocoded.nil?
71
- query = 'Portland, OR'
72
- end
73
84
 
74
85
  unless geocoded
75
86
  Lita.logger.debug "Redis hget failed, performing lookup for #{query}"
@@ -78,6 +89,13 @@ module ForecastIo
78
89
  redis.hset(REDIS_KEY, user.name, geocoded.to_json)
79
90
  end
80
91
 
92
+ # Let's set up the defaults in the event that the geocoder fails.
93
+ # See https://github.com/onewheelskyward/lita-onewheel-forecast-io/issues/34
94
+ unless geocoded
95
+ Lita.logger.debug "Geocoded was #{geocoded.inspect}, setting to default."
96
+ geocoded = default_location
97
+ end
98
+
81
99
  Lita.logger.debug "geocoded: '#{geocoded}'"
82
100
 
83
101
  loc = Location.new(
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-forecast-io'
3
- spec.version = '0.1.0'
3
+ spec.version = '0.1.1'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = <<-EOS
@@ -1,4 +1,5 @@
1
1
  require_relative '../../spec_helper'
2
+ require 'geocoder'
2
3
 
3
4
  describe Lita::Handlers::OnewheelForecastIo, lita_handler: true do
4
5
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require 'simplecov'
2
2
  require 'coveralls'
3
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
3
+ SimpleCov.formatters = [
4
4
  SimpleCov::Formatter::HTMLFormatter,
5
5
  Coveralls::SimpleCov::Formatter
6
6
  ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-forecast-io
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-02-15 00:00:00.000000000 Z
11
+ date: 2016-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
- rubygems_version: 2.4.5.1
221
+ rubygems_version: 2.5.1
222
222
  signing_key:
223
223
  specification_version: 4
224
224
  summary: A text-based interactive query engine for http://forecast.io's api.