ruboty-rainfall_jp 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruboty/rainfall_jp/version.rb +1 -1
- data/lib/ruboty/rainfall_jp.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8c100261aa4226111cf2b240f56e1a18d88611c
|
4
|
+
data.tar.gz: 31c9f112f0752823f753497645772186448d8696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 691b08476e8ae4e09a500bbf4e26981630df863c9b954fb45c5838c1be9ad20577fd50739fcf8a3ae1735c27bf7e64f887076ad3659d9f50a0eb2fef8240ea57
|
7
|
+
data.tar.gz: 3da18a0c0e9870d95da481c875d81845a1d9776b508ed9afd8d850f190a7e6eab203b92ec81f08eb64f19a6fbef6a344643f6a55b941bda2857b44971f706863
|
data/lib/ruboty/rainfall_jp.rb
CHANGED
@@ -20,7 +20,7 @@ module Ruboty
|
|
20
20
|
end
|
21
21
|
|
22
22
|
query = message.match_data['query'] || DEFAULT_LOCATION
|
23
|
-
geometry =
|
23
|
+
name, geometry = fetch_location_name_and_coodinated_geometry(query)
|
24
24
|
|
25
25
|
if geometry.nil?
|
26
26
|
message.reply('ಠ_ಠ')
|
@@ -29,7 +29,7 @@ module Ruboty
|
|
29
29
|
end
|
30
30
|
|
31
31
|
result = fetch_rainfall(geometry)
|
32
|
-
message.reply("Rainfall forecast: #{
|
32
|
+
message.reply("Rainfall forecast: #{name} (l/l: #{geometry})")
|
33
33
|
message.reply(result)
|
34
34
|
rescue Exception => e
|
35
35
|
message.reply('ಠ_ಠ')
|
@@ -39,14 +39,14 @@ module Ruboty
|
|
39
39
|
|
40
40
|
private
|
41
41
|
|
42
|
-
def
|
42
|
+
def fetch_location_name_and_coodinated_geometry(query)
|
43
43
|
url = "http://geo.search.olp.yahooapis.jp/OpenLocalPlatform/V1/geoCoder?appid=#{YAHOO_JAPAN_APP_ID}&output=json&query=#{CGI.escape(query)}"
|
44
44
|
response = JSON.parse(open(url).read)
|
45
45
|
features = response["Feature"]
|
46
46
|
if features.nil? || features.first.nil?
|
47
47
|
return nil
|
48
48
|
end
|
49
|
-
features.first["Geometry"]["Coordinates"]
|
49
|
+
[features.first["Name"], features.first["Geometry"]["Coordinates"]]
|
50
50
|
end
|
51
51
|
|
52
52
|
def fetch_rainfall(geometry)
|