cowa 0.1.1 → 0.1.2

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: c78333a21c50c9e97a78f485bca73b7af3f82939
4
- data.tar.gz: 7cb93ca574d6bc43b446ef090b556cccb55c6e00
3
+ metadata.gz: 0030c12b197adb6993b0507245894cbf1189dfab
4
+ data.tar.gz: 12a5b6983f55a37733fdf4e74c70f94e465a86bb
5
5
  SHA512:
6
- metadata.gz: e0da50b61f9e103592b537fb58bd669549a3342ba7b1198fff603fc421d30fe511db667064b805136821feb356469d6fe776b43d3a2076aa7a9916236a6590bc
7
- data.tar.gz: 0e5e737825c59c7d8746ff72c93f57f3be6c7fd4af469bf5dfe606c93f89c0068e6e27099ec1e52ebee3fae089df343bae085e554f0c746547dc1183d6870e4b
6
+ metadata.gz: 974aa0dcd022189dc9e15229c582157f7ed1a0769d60b4e8f5c99051eb092e0e8b2cdf4ce64b3c310a825a43f7ace6cf4c37a8404889f6b3b45ff8ebe0c042fb
7
+ data.tar.gz: cc654a75ca14905bde6de638ff833660214e5e96895e298f1672f35cd892709027fb3614c9ce33e3465e647d5183e0fe1fdf2257a03d8b1c02cd3df2cba7af1b
@@ -1,3 +1,3 @@
1
1
  module Cowa
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -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.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-06-15 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler