cowa 0.1.1 → 0.1.2
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 +4 -4
- data/lib/cowa/version.rb +1 -1
- data/lib/cowa/weather_hacks.rb +8 -10
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0030c12b197adb6993b0507245894cbf1189dfab
|
|
4
|
+
data.tar.gz: 12a5b6983f55a37733fdf4e74c70f94e465a86bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 974aa0dcd022189dc9e15229c582157f7ed1a0769d60b4e8f5c99051eb092e0e8b2cdf4ce64b3c310a825a43f7ace6cf4c37a8404889f6b3b45ff8ebe0c042fb
|
|
7
|
+
data.tar.gz: cc654a75ca14905bde6de638ff833660214e5e96895e298f1672f35cd892709027fb3614c9ce33e3465e647d5183e0fe1fdf2257a03d8b1c02cd3df2cba7af1b
|
data/lib/cowa/version.rb
CHANGED
data/lib/cowa/weather_hacks.rb
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
require 'open-uri'
|
|
2
2
|
require 'json'
|
|
3
|
-
require 'active_support'
|
|
4
|
-
require 'active_support/core_ext'
|
|
5
3
|
require 'yapi'
|
|
6
4
|
|
|
7
5
|
module Cowa
|
|
8
6
|
class WeatherHacks
|
|
9
7
|
attr_accessor :rss
|
|
10
|
-
|
|
8
|
+
|
|
11
9
|
def initialize(api_key)
|
|
12
10
|
@contentsgeocoder = Yapi::OpenLocalPlatform::ContentsGeoCoder.new(api_key)
|
|
13
11
|
self.rss = xml_to_json(open(URI.encode("http://weather.livedoor.com/forecast/rss/primary_area.xml")).read)[:rss][:channel][:source][:pref]
|
|
14
12
|
end
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
def xml_to_json xml
|
|
17
15
|
doc = Hash.from_xml xml
|
|
18
16
|
return JSON.parse(doc.to_json, symbolize_names: true)
|
|
19
17
|
end
|
|
20
|
-
|
|
18
|
+
|
|
21
19
|
def locationToRss location
|
|
22
20
|
pref = get_pref location
|
|
23
21
|
return nil if pref.nil?
|
|
@@ -40,13 +38,13 @@ module Cowa
|
|
|
40
38
|
id = get_id(city, location)
|
|
41
39
|
return id
|
|
42
40
|
end
|
|
43
|
-
|
|
41
|
+
|
|
44
42
|
def get_pref location
|
|
45
43
|
json = @contentsgeocoder.contentsGeoCoder(location)
|
|
46
44
|
return nil if json[:YDF][:ResultInfo][:Count] == "0"
|
|
47
45
|
return json[:YDF][:Feature][:Property][:AddressElement]
|
|
48
46
|
end
|
|
49
|
-
|
|
47
|
+
|
|
50
48
|
def get_city pref
|
|
51
49
|
self.rss().each do |t|
|
|
52
50
|
if t[:title] == pref
|
|
@@ -55,7 +53,7 @@ module Cowa
|
|
|
55
53
|
end
|
|
56
54
|
return nil
|
|
57
55
|
end
|
|
58
|
-
|
|
56
|
+
|
|
59
57
|
def get_id(city, location)
|
|
60
58
|
unless city.nil?
|
|
61
59
|
city.each do |c|
|
|
@@ -66,11 +64,11 @@ module Cowa
|
|
|
66
64
|
return nil
|
|
67
65
|
end
|
|
68
66
|
end
|
|
69
|
-
|
|
67
|
+
|
|
70
68
|
def client url
|
|
71
69
|
return open(URI.encode(url)).read
|
|
72
70
|
end
|
|
73
|
-
|
|
71
|
+
|
|
74
72
|
def forecast location
|
|
75
73
|
rss = locationToRss(location)
|
|
76
74
|
return nil if rss.nil?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cowa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- flum1025
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-
|
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|