cowa 0.1.0 → 0.1.1

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: 7221473f7e42737b6fa859fd5166b264ae1a8433
4
- data.tar.gz: 69376f4ec6eb2aab52ffce0c38e49428a70c35c6
3
+ metadata.gz: c78333a21c50c9e97a78f485bca73b7af3f82939
4
+ data.tar.gz: 7cb93ca574d6bc43b446ef090b556cccb55c6e00
5
5
  SHA512:
6
- metadata.gz: c9dfdd96de9352959d9e4a775e371cfaa1c9227d33edb8a18da59b9e3f6f6529cf20fa2b52524ee07c98077b289dd4f5a79b511c002eebd6b72c890151265f03
7
- data.tar.gz: 21ab63906fb61de7bc5a49cd4aa8948fd4061caa2e37670ca9e600a6d2dcc84c4fa45dd34970b2d684cf4936a5e3ba26297d9329f8117d3429120c1e885643e6
6
+ metadata.gz: e0da50b61f9e103592b537fb58bd669549a3342ba7b1198fff603fc421d30fe511db667064b805136821feb356469d6fe776b43d3a2076aa7a9916236a6590bc
7
+ data.tar.gz: 0e5e737825c59c7d8746ff72c93f57f3be6c7fd4af469bf5dfe606c93f89c0068e6e27099ec1e52ebee3fae089df343bae085e554f0c746547dc1183d6870e4b
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /**/.DS_Store
data/example/cowa.rb CHANGED
@@ -2,12 +2,14 @@
2
2
  lib = File.expand_path('../../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'cowa'
5
+ require 'pry'
5
6
 
6
7
  open_weathermap_api_key = ""
7
- info = Cowa::OpenWeatherMap.new(open_weathermap_api_key)
8
+ yahoo_api_key = ""
9
+ info = Cowa::OpenWeatherMap.new(open_weathermap_api_key, yahoo_api_key)
8
10
  puts info.get_information_place("千葉")
9
11
  puts info.get_information_latlon(35,140)
12
+ exit
10
13
 
11
- yahoo_api_key = ""
12
14
  fore = Cowa::WeatherHacks.new(yahoo_api_key)
13
- puts fore.forecast("千代田区")
15
+ puts fore.forecast("千代田区")
@@ -3,28 +3,33 @@ require 'json'
3
3
 
4
4
  module Cowa
5
5
  class OpenWeatherMap
6
+ NotFound = Class.new(StandardError)
7
+
6
8
  attr_accessor :api_key
7
-
8
- def initialize(api_key)
9
- @api_key = api_key
9
+
10
+ def initialize(open_weathermap_api_key, yahoo_api_key)
11
+ @contentsgeocoder = Yapi::OpenLocalPlatform::ContentsGeoCoder.new(yahoo_api_key)
12
+ @api_key = open_weathermap_api_key
10
13
  end
11
-
14
+
12
15
  def client url
13
- return open(URI.encode(url)).read
16
+ open(URI.encode(url)).read
14
17
  end
15
-
18
+
16
19
  def get_icon icon
17
- return open("http://openweathermap.org/img/w/#{icon}.png")
20
+ open("http://openweathermap.org/img/w/#{icon}.png")
18
21
  end
19
-
22
+
20
23
  def get_information_place location
21
- req_url = "http://api.openweathermap.org/data/2.5/weather?q=#{location}&APPID=#{@api_key}"
22
- return JSON.parse(client(req_url), symbolize_names: true)
24
+ json = @contentsgeocoder.contentsGeoCoder(location)
25
+ raise NotFound if json[:YDF][:ResultInfo][:Count] == "0"
26
+ lon, lat = json[:YDF][:Feature][:Geometry][:Coordinates].split(',')
27
+ get_information_latlon lat, lon
23
28
  end
24
-
29
+
25
30
  def get_information_latlon lat, lon
26
31
  req_url = "http://api.openweathermap.org/data/2.5/weather?lat=#{lat}&lon=#{lon}&APPID=#{@api_key}"
27
- return JSON.parse(client(req_url), symbolize_names: true)
32
+ JSON.parse(client(req_url), symbolize_names: true)
28
33
  end
29
34
  end
30
35
  end
data/lib/cowa/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Cowa
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,83 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cowa
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
  - flum1025
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-17 00:00:00.000000000 Z
11
+ date: 2017-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.9'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.9'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: yapi
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: activesupport
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: composite library for weather api
@@ -87,9 +87,9 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - .gitignore
91
- - .project
92
- - .travis.yml
90
+ - ".gitignore"
91
+ - ".project"
92
+ - ".travis.yml"
93
93
  - Gemfile
94
94
  - README.md
95
95
  - Rakefile
@@ -110,17 +110,17 @@ require_paths:
110
110
  - lib
111
111
  required_ruby_version: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - '>='
113
+ - - ">="
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  requirements:
118
- - - '>='
118
+ - - ">="
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project:
123
- rubygems_version: 2.5.2
123
+ rubygems_version: 2.6.8
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: composite library for weather api