weatai 0.1.2 → 0.1.3
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/.travis.yml +15 -12
- data/Gemfile.lock +1 -1
- data/README.md +36 -34
- data/bin/weatai +6 -7
- data/cassettes/all_record.yml +78205 -30153
- data/config/credentials.yml.example +4 -1
- data/lib/weatai/cwb.rb +7 -14
- data/lib/weatai/cwb_api.rb +27 -6
- data/lib/weatai/cwb_psi.rb +32 -0
- data/lib/weatai/cwb_rain.rb +37 -0
- data/lib/weatai/instant.rb +50 -0
- data/lib/weatai/version.rb +3 -3
- data/spec/fixtures/data.yml +123 -123
- data/spec/spec_helper.rb +13 -8
- data/spec/weatai_spec.rb +40 -96
- data/weatai.gemspec +2 -2
- metadata +14 -7
- data/spec/test.rb +0 -92
data/lib/weatai/cwb.rb
CHANGED
@@ -4,14 +4,13 @@ module CWB
|
|
4
4
|
class Weather
|
5
5
|
attr_reader :dataid
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@dataid =
|
7
|
+
def initialize(dataid:)
|
8
|
+
@dataid = dataid
|
9
9
|
end
|
10
10
|
|
11
|
-
def instant_weather
|
12
|
-
|
13
|
-
|
14
|
-
all_location = {}
|
11
|
+
def self.instant_weather
|
12
|
+
raw_info = CWB::CWBApi.raw_info1(@dataid)
|
13
|
+
all_location1 = {}
|
15
14
|
raw_info['cwbopendata']['location'].each do |item|
|
16
15
|
location = {}
|
17
16
|
place = item['locationName']
|
@@ -20,15 +19,9 @@ module CWB
|
|
20
19
|
location['town'] = item['parameter'][2]['parameterValue']
|
21
20
|
location['TEMP'] = item['weatherElement'][4]['elementValue']['value']
|
22
21
|
location['HUMD'] = item['weatherElement'][5]['elementValue']['value']
|
23
|
-
|
22
|
+
all_location1.store(place, location)
|
24
23
|
end
|
25
|
-
|
26
|
-
all_location
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.find(dataid:)
|
30
|
-
raw_data = CWB::CWBApi.raw_info(dataid)
|
31
|
-
new(data: raw_data)
|
24
|
+
all_location1
|
32
25
|
end
|
33
26
|
|
34
27
|
def weather_test
|
data/lib/weatai/cwb_api.rb
CHANGED
@@ -5,7 +5,8 @@ require 'http'
|
|
5
5
|
module CWB
|
6
6
|
# Service for all weather API calls
|
7
7
|
class CWBApi
|
8
|
-
|
8
|
+
URL_cwb = 'http://opendata.cwb.gov.tw/opendataapi'
|
9
|
+
URL_psi = 'http://opendata.epa.gov.tw/webapi/api/rest/datastore/355000000I-000001/'
|
9
10
|
|
10
11
|
def self.config=(credentials)
|
11
12
|
@config ? @config.update(credentials) : @config = credentials
|
@@ -13,16 +14,36 @@ module CWB
|
|
13
14
|
|
14
15
|
def self.config
|
15
16
|
return @config if @config
|
16
|
-
@config = {
|
17
|
-
|
17
|
+
@config = { dataid1: ENV['DATA_ID1'],
|
18
|
+
dataid2: ENV['DATA_ID2'],
|
19
|
+
key: ENV['AUTH_KEY'],
|
20
|
+
format: ENV['FORMAT'],
|
21
|
+
token: ENV['TOKEN']}
|
18
22
|
end
|
19
23
|
|
20
|
-
def self.
|
24
|
+
def self.raw_info1(dataid)
|
21
25
|
info_response =
|
22
|
-
HTTP.get(
|
23
|
-
params: { dataid: config[:
|
26
|
+
HTTP.get(URL_cwb,
|
27
|
+
params: { dataid: config[:dataid1],
|
24
28
|
authorizationkey: config[:key]})
|
25
29
|
Hash.from_xml(info_response)
|
26
30
|
end
|
31
|
+
|
32
|
+
def self.raw_info2(dataid)
|
33
|
+
info_response =
|
34
|
+
HTTP.get(URL_cwb,
|
35
|
+
params: { dataid: config[:dataid2],
|
36
|
+
authorizationkey: config[:key]})
|
37
|
+
Hash.from_xml(info_response)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.raw_info3(dataid)
|
41
|
+
info_response =
|
42
|
+
HTTP.get(URL_psi,
|
43
|
+
params: { format: config[:format],
|
44
|
+
token: config[:token]})
|
45
|
+
Hash.from_xml(info_response)
|
46
|
+
end
|
47
|
+
|
27
48
|
end
|
28
49
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require_relative 'cwb_api'
|
2
|
+
require_relative 'cwb'
|
3
|
+
|
4
|
+
module CWB
|
5
|
+
# Class to parse the PSI data
|
6
|
+
class PSI
|
7
|
+
attr_reader :dataid
|
8
|
+
|
9
|
+
def initialize(dataid:)
|
10
|
+
@dataid = dataid
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.instant_psi
|
14
|
+
raw_info = CWB::CWBApi.raw_info3(@dataid)
|
15
|
+
all_location3 = {}
|
16
|
+
raw_info['AQX']['Data'].each do |item|
|
17
|
+
location = {}
|
18
|
+
place = item['County']
|
19
|
+
location['city'] = item['County']
|
20
|
+
location['PSI'] = item['PSI']
|
21
|
+
location['Status'] = item['Status']
|
22
|
+
all_location3.store(place, location)
|
23
|
+
end
|
24
|
+
all_location3
|
25
|
+
end
|
26
|
+
|
27
|
+
def weather_test
|
28
|
+
return 'weather_test_yes'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative 'cwb_api'
|
2
|
+
require_relative 'cwb'
|
3
|
+
module CWB
|
4
|
+
# Class to parse the rain data
|
5
|
+
class Rain
|
6
|
+
attr_reader :dataid
|
7
|
+
|
8
|
+
def initialize(dataid:)
|
9
|
+
@dataid = dataid
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.instant_rain
|
13
|
+
raw_info = CWB::CWBApi.raw_info2(@dataid)
|
14
|
+
all_location2 = {}
|
15
|
+
keys = CWB::Weather.instant_weather.keys
|
16
|
+
raw_info['cwbopendata']['location'].each do |item|
|
17
|
+
location = {}
|
18
|
+
if(item['locationName'].in?(keys))
|
19
|
+
place = item['locationName']
|
20
|
+
location['time'] = item['time']['obsTime']
|
21
|
+
location['city'] = item['parameter'][0]['parameterValue']
|
22
|
+
location['town'] = item['parameter'][2]['parameterValue']
|
23
|
+
location['MIN_10'] = item['weatherElement'][2]['elementValue']['value']
|
24
|
+
location['MIN_10'] = '0.00' if location['MIN_10'].to_f<0
|
25
|
+
location['Daily Accumulated Rainfall'] = item['weatherElement'][7]['elementValue']['value']
|
26
|
+
all_location2.store(place, location)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
all_location2
|
30
|
+
end
|
31
|
+
|
32
|
+
def weather_test
|
33
|
+
return 'weather_test_yes'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative 'cwb_api'
|
2
|
+
require_relative 'cwb'
|
3
|
+
require_relative 'cwb_rain'
|
4
|
+
require_relative 'cwb_psi'
|
5
|
+
module CWB
|
6
|
+
# Class to organize all the data we need
|
7
|
+
class INSTANT
|
8
|
+
attr_reader :dataid
|
9
|
+
|
10
|
+
def initialize(dataid:)
|
11
|
+
@dataid = dataid
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.instant
|
15
|
+
station = CWB::Rain.instant_rain.keys
|
16
|
+
all_location1 = CWB::Weather.instant_weather
|
17
|
+
all_location2 = CWB::Rain.instant_rain
|
18
|
+
all_location3 = CWB::PSI.instant_psi
|
19
|
+
all_location4 = {}
|
20
|
+
station.each do |item|
|
21
|
+
location = {}
|
22
|
+
place = item
|
23
|
+
location['time'] = all_location2[item]['time']
|
24
|
+
location['city'] = all_location2[item]['city']
|
25
|
+
location['town'] = all_location2[item]['town']
|
26
|
+
location['TEMP'] = all_location1[item]['TEMP']
|
27
|
+
location['HUMD'] = all_location1[item]['HUMD']
|
28
|
+
location['MIN_10'] = all_location2[item]['MIN_10']
|
29
|
+
location['Daily Accumulated Rainfall'] = all_location2[item]['Daily Accumulated Rainfall']
|
30
|
+
location['PSI'] = all_location3[location['city']]['PSI'] if location['city'].in?(all_location3.keys.uniq)
|
31
|
+
location['Status'] = all_location3[location['city']]['Status'] if location['city'].in?(all_location3.keys.uniq)
|
32
|
+
all_location4.store(place, location)
|
33
|
+
end
|
34
|
+
all_location4
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.local(position)
|
38
|
+
station = CWB::Rain.instant_rain.keys
|
39
|
+
if (position.in?(station))
|
40
|
+
puts CWB::INSTANT.instant.assoc(position).to_yaml
|
41
|
+
else
|
42
|
+
puts "Please enter a station!"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def weather_test
|
47
|
+
return 'weather_test_yes'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/lib/weatai/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module CWB
|
2
|
-
VERSION = '0.1.
|
3
|
-
end
|
1
|
+
module CWB
|
2
|
+
VERSION = '0.1.3'
|
3
|
+
end
|
data/spec/fixtures/data.yml
CHANGED
@@ -1,253 +1,253 @@
|
|
1
1
|
---
|
2
2
|
基隆:
|
3
|
-
time: '2016-
|
3
|
+
time: '2016-11-04T11:20:00+08:00'
|
4
4
|
city: 基隆市
|
5
5
|
town: 中山區
|
6
|
-
TEMP: '
|
7
|
-
HUMD: '0.
|
6
|
+
TEMP: '21.9'
|
7
|
+
HUMD: '0.79'
|
8
8
|
淡水:
|
9
|
-
time: '2016-
|
9
|
+
time: '2016-11-04T11:20:00+08:00'
|
10
10
|
city: 新北市
|
11
11
|
town: 淡水區
|
12
|
-
TEMP: '22.
|
13
|
-
HUMD: '0.
|
12
|
+
TEMP: '22.8'
|
13
|
+
HUMD: '0.75'
|
14
14
|
板橋:
|
15
|
-
time: '2016-
|
15
|
+
time: '2016-11-04T11:20:00+08:00'
|
16
16
|
city: 新北市
|
17
17
|
town: 板橋區
|
18
|
-
TEMP: '
|
19
|
-
HUMD: '0.
|
18
|
+
TEMP: '21.7'
|
19
|
+
HUMD: '0.77'
|
20
20
|
竹子湖:
|
21
|
-
time: '2016-
|
21
|
+
time: '2016-11-04T11:20:00+08:00'
|
22
22
|
city: 臺北市
|
23
23
|
town: 北投區
|
24
|
-
TEMP: '17.
|
25
|
-
HUMD: '0.
|
24
|
+
TEMP: '17.8'
|
25
|
+
HUMD: '0.90'
|
26
26
|
鞍部:
|
27
|
-
time: '2016-
|
27
|
+
time: '2016-11-04T11:20:00+08:00'
|
28
28
|
city: 臺北市
|
29
29
|
town: 北投區
|
30
|
-
TEMP: '15.
|
30
|
+
TEMP: '15.7'
|
31
31
|
HUMD: '0.99'
|
32
32
|
新竹:
|
33
|
-
time: '2016-
|
33
|
+
time: '2016-11-04T11:20:00+08:00'
|
34
34
|
city: 新竹縣
|
35
35
|
town: 竹北市
|
36
|
-
TEMP: '
|
37
|
-
HUMD: '0.
|
36
|
+
TEMP: '25.4'
|
37
|
+
HUMD: '0.70'
|
38
38
|
臺中:
|
39
|
-
time: '2016-
|
39
|
+
time: '2016-11-04T11:20:00+08:00'
|
40
40
|
city: 臺中市
|
41
41
|
town: 北區
|
42
|
-
TEMP: '
|
43
|
-
HUMD: '0.
|
42
|
+
TEMP: '27.9'
|
43
|
+
HUMD: '0.56'
|
44
44
|
梧棲:
|
45
|
-
time: '2016-
|
45
|
+
time: '2016-11-04T11:20:00+08:00'
|
46
46
|
city: 臺中市
|
47
47
|
town: 梧棲區
|
48
|
-
TEMP: '
|
49
|
-
HUMD: '0.
|
48
|
+
TEMP: '26.4'
|
49
|
+
HUMD: '0.65'
|
50
50
|
澎湖:
|
51
|
-
time: '2016-
|
51
|
+
time: '2016-11-04T11:20:00+08:00'
|
52
52
|
city: 澎湖縣
|
53
53
|
town: 馬公市
|
54
|
-
TEMP: '
|
55
|
-
HUMD: '0.
|
54
|
+
TEMP: '25.5'
|
55
|
+
HUMD: '0.73'
|
56
56
|
日月潭:
|
57
|
-
time: '2016-
|
57
|
+
time: '2016-11-04T11:20:00+08:00'
|
58
58
|
city: 南投縣
|
59
59
|
town: 魚池鄉
|
60
|
-
TEMP: '20.
|
61
|
-
HUMD: '0.
|
60
|
+
TEMP: '20.4'
|
61
|
+
HUMD: '0.72'
|
62
62
|
阿里山:
|
63
|
-
time: '2016-
|
63
|
+
time: '2016-11-04T11:20:00+08:00'
|
64
64
|
city: 嘉義縣
|
65
65
|
town: 阿里山鄉
|
66
|
-
TEMP: '
|
67
|
-
HUMD: '0.
|
66
|
+
TEMP: '11.5'
|
67
|
+
HUMD: '0.82'
|
68
68
|
玉山:
|
69
|
-
time: '2016-
|
69
|
+
time: '2016-11-04T11:20:00+08:00'
|
70
70
|
city: 南投縣
|
71
71
|
town: 信義鄉
|
72
|
-
TEMP: '
|
73
|
-
HUMD: '0.
|
72
|
+
TEMP: '7.8'
|
73
|
+
HUMD: '0.50'
|
74
74
|
嘉義:
|
75
|
-
time: '2016-
|
75
|
+
time: '2016-11-04T11:20:00+08:00'
|
76
76
|
city: 嘉義市
|
77
77
|
town: 西區
|
78
|
-
TEMP: '
|
79
|
-
HUMD: '0.
|
78
|
+
TEMP: '28.7'
|
79
|
+
HUMD: '0.57'
|
80
80
|
高雄:
|
81
|
-
time: '2016-
|
81
|
+
time: '2016-11-04T11:20:00+08:00'
|
82
82
|
city: 高雄市
|
83
83
|
town: 前鎮區
|
84
|
-
TEMP: '
|
85
|
-
HUMD: '0.
|
84
|
+
TEMP: '28.4'
|
85
|
+
HUMD: '0.65'
|
86
86
|
恆春:
|
87
|
-
time: '2016-
|
87
|
+
time: '2016-11-04T11:20:00+08:00'
|
88
88
|
city: 屏東縣
|
89
89
|
town: 恆春鎮
|
90
|
-
TEMP: '
|
91
|
-
HUMD: '0.
|
90
|
+
TEMP: '28.9'
|
91
|
+
HUMD: '0.55'
|
92
92
|
宜蘭:
|
93
|
-
time: '2016-
|
93
|
+
time: '2016-11-04T11:20:00+08:00'
|
94
94
|
city: 宜蘭縣
|
95
95
|
town: 宜蘭市
|
96
|
-
TEMP: '
|
96
|
+
TEMP: '21.0'
|
97
97
|
HUMD: '0.91'
|
98
98
|
蘇澳:
|
99
|
-
time: '2016-
|
99
|
+
time: '2016-11-04T11:20:00+08:00'
|
100
100
|
city: 宜蘭縣
|
101
101
|
town: 蘇澳鎮
|
102
|
-
TEMP: '
|
103
|
-
HUMD: '0.
|
102
|
+
TEMP: '21.0'
|
103
|
+
HUMD: '0.91'
|
104
104
|
花蓮:
|
105
|
-
time: '2016-
|
105
|
+
time: '2016-11-04T11:20:00+08:00'
|
106
106
|
city: 花蓮縣
|
107
107
|
town: 花蓮市
|
108
|
-
TEMP: '
|
109
|
-
HUMD: '0.
|
108
|
+
TEMP: '26.4'
|
109
|
+
HUMD: '0.68'
|
110
110
|
成功:
|
111
|
-
time: '2016-
|
111
|
+
time: '2016-11-04T11:20:00+08:00'
|
112
112
|
city: 臺東縣
|
113
113
|
town: 成功鎮
|
114
|
-
TEMP: '
|
115
|
-
HUMD: '0.
|
114
|
+
TEMP: '26.2'
|
115
|
+
HUMD: '0.69'
|
116
116
|
臺東:
|
117
|
-
time: '2016-
|
117
|
+
time: '2016-11-04T11:20:00+08:00'
|
118
118
|
city: 臺東縣
|
119
119
|
town: 臺東市
|
120
|
-
TEMP: '
|
121
|
-
HUMD: '0.
|
120
|
+
TEMP: '28.3'
|
121
|
+
HUMD: '0.62'
|
122
122
|
大武:
|
123
|
-
time: '2016-
|
123
|
+
time: '2016-11-04T11:20:00+08:00'
|
124
124
|
city: 臺東縣
|
125
125
|
town: 大武鄉
|
126
|
-
TEMP: '
|
127
|
-
HUMD: '0.
|
126
|
+
TEMP: '28.1'
|
127
|
+
HUMD: '0.61'
|
128
128
|
蘭嶼:
|
129
|
-
time: '2016-
|
129
|
+
time: '2016-11-04T11:20:00+08:00'
|
130
130
|
city: 臺東縣
|
131
131
|
town: 蘭嶼鄉
|
132
|
-
TEMP: '
|
133
|
-
HUMD: '0.
|
132
|
+
TEMP: '24.9'
|
133
|
+
HUMD: '0.77'
|
134
134
|
彭佳嶼:
|
135
|
-
time: '2016-
|
135
|
+
time: '2016-11-04T11:20:00+08:00'
|
136
136
|
city: 基隆市
|
137
137
|
town: 中正區
|
138
|
-
TEMP: '
|
139
|
-
HUMD: '0.
|
138
|
+
TEMP: '22.2'
|
139
|
+
HUMD: '0.71'
|
140
140
|
東吉島:
|
141
|
-
time: '2016-
|
141
|
+
time: '2016-11-04T11:20:00+08:00'
|
142
142
|
city: 澎湖縣
|
143
143
|
town: 望安鄉
|
144
|
-
TEMP: '
|
144
|
+
TEMP: '26.3'
|
145
145
|
HUMD: '0.75'
|
146
146
|
永康:
|
147
|
-
time: '2016-
|
147
|
+
time: '2016-11-04T11:20:00+08:00'
|
148
148
|
city: 臺南市
|
149
149
|
town: 永康區
|
150
|
-
TEMP: '
|
151
|
-
HUMD: '0.
|
150
|
+
TEMP: '28.4'
|
151
|
+
HUMD: '0.60'
|
152
152
|
金門(合):
|
153
|
-
time: '2016-
|
153
|
+
time: '2016-11-04T11:20:00+08:00'
|
154
154
|
city: 金門縣
|
155
155
|
town: 金湖鎮
|
156
|
-
TEMP: '
|
157
|
-
HUMD: '0.
|
156
|
+
TEMP: '24.5'
|
157
|
+
HUMD: '0.53'
|
158
158
|
拉拉山:
|
159
|
-
time: '2016-
|
159
|
+
time: '2016-11-04T11:20:00+08:00'
|
160
160
|
city: 桃園市
|
161
161
|
town: 復興區
|
162
|
-
TEMP: '
|
163
|
-
HUMD: '0.
|
162
|
+
TEMP: '17.7'
|
163
|
+
HUMD: '0.74'
|
164
164
|
武陵:
|
165
|
-
time: '2016-
|
165
|
+
time: '2016-11-04T11:20:00+08:00'
|
166
166
|
city: 臺中市
|
167
167
|
town: 和平區
|
168
|
-
TEMP: '
|
169
|
-
HUMD: '0.
|
168
|
+
TEMP: '20.4'
|
169
|
+
HUMD: '0.44'
|
170
170
|
太魯閣:
|
171
|
-
time: '2016-
|
171
|
+
time: '2016-11-04T11:20:00+08:00'
|
172
172
|
city: 花蓮縣
|
173
173
|
town: 秀林鄉
|
174
|
-
TEMP: '
|
175
|
-
HUMD: '0.
|
174
|
+
TEMP: '27.2'
|
175
|
+
HUMD: '0.69'
|
176
176
|
新店:
|
177
|
-
time: '2016-
|
177
|
+
time: '2016-11-04T11:20:00+08:00'
|
178
178
|
city: 新北市
|
179
179
|
town: 新店區
|
180
|
-
TEMP:
|
181
|
-
HUMD:
|
180
|
+
TEMP: '20.8'
|
181
|
+
HUMD: '0.88'
|
182
182
|
臺北:
|
183
|
-
time: '2016-
|
183
|
+
time: '2016-11-04T11:20:00+08:00'
|
184
184
|
city: 臺北市
|
185
185
|
town: 中正區
|
186
|
-
TEMP: '
|
187
|
-
HUMD: '0.
|
186
|
+
TEMP: '21.3'
|
187
|
+
HUMD: '0.83'
|
188
188
|
彰師大:
|
189
|
-
time: '2016-
|
189
|
+
time: '2016-11-04T11:20:00+08:00'
|
190
190
|
city: 彰化縣
|
191
191
|
town: 彰化市
|
192
|
-
TEMP: '
|
193
|
-
HUMD: '0.
|
192
|
+
TEMP: '27.9'
|
193
|
+
HUMD: '0.49'
|
194
194
|
臺南:
|
195
|
-
time: '2016-
|
195
|
+
time: '2016-11-04T11:20:00+08:00'
|
196
196
|
city: 臺南市
|
197
197
|
town: 中區
|
198
|
-
TEMP: '
|
199
|
-
HUMD: '0.
|
198
|
+
TEMP: '28.2'
|
199
|
+
HUMD: '0.57'
|
200
200
|
合歡山莊:
|
201
|
-
time: '2016-
|
201
|
+
time: '2016-11-04T11:20:00+08:00'
|
202
202
|
city: 花蓮縣
|
203
203
|
town: 秀林鄉
|
204
|
-
TEMP: '
|
205
|
-
HUMD: '0.
|
204
|
+
TEMP: '9.8'
|
205
|
+
HUMD: '0.55'
|
206
206
|
吉貝:
|
207
|
-
time: '2016-
|
207
|
+
time: '2016-11-04T11:20:00+08:00'
|
208
208
|
city: 澎湖縣
|
209
209
|
town: 白沙鄉
|
210
|
-
TEMP: '
|
211
|
-
HUMD: '0.
|
210
|
+
TEMP: '22.0'
|
211
|
+
HUMD: '0.82'
|
212
212
|
東沙:
|
213
|
-
time: '2016-
|
213
|
+
time: '2016-11-04T11:20:00+08:00'
|
214
214
|
city: 高雄市
|
215
215
|
town: 東沙島
|
216
|
-
TEMP: '
|
217
|
-
HUMD: '
|
216
|
+
TEMP: '27.1'
|
217
|
+
HUMD: '0.99'
|
218
218
|
金門:
|
219
|
-
time: '2016-
|
219
|
+
time: '2016-11-04T11:20:00+08:00'
|
220
220
|
city: 金門縣
|
221
221
|
town: 金城鎮
|
222
|
-
TEMP: '
|
223
|
-
HUMD: '0.
|
222
|
+
TEMP: '25.2'
|
223
|
+
HUMD: '0.55'
|
224
224
|
馬祖:
|
225
|
-
time: '2016-
|
225
|
+
time: '2016-11-04T11:20:00+08:00'
|
226
226
|
city: 連江縣
|
227
227
|
town: 南竿鄉
|
228
|
-
TEMP: '20.
|
229
|
-
HUMD: '0.
|
228
|
+
TEMP: '20.1'
|
229
|
+
HUMD: '0.68'
|
230
230
|
麥寮:
|
231
|
-
time: '2016-
|
231
|
+
time: '2016-11-04T11:20:00+08:00'
|
232
232
|
city: 雲林縣
|
233
233
|
town: 麥寮鄉
|
234
|
-
TEMP: '
|
235
|
-
HUMD: '0.
|
234
|
+
TEMP: '25.5'
|
235
|
+
HUMD: '0.87'
|
236
236
|
新屋:
|
237
|
-
time: '2016-
|
237
|
+
time: '2016-11-04T11:20:00+08:00'
|
238
238
|
city: 桃園市
|
239
239
|
town: 新屋區
|
240
|
-
TEMP: '
|
241
|
-
HUMD: '0.
|
240
|
+
TEMP: '24.2'
|
241
|
+
HUMD: '0.73'
|
242
242
|
古坑:
|
243
|
-
time: '2016-
|
243
|
+
time: '2016-11-04T11:20:00+08:00'
|
244
244
|
city: 雲林縣
|
245
245
|
town: 古坑鄉
|
246
|
-
TEMP:
|
247
|
-
HUMD:
|
246
|
+
TEMP: '27.6'
|
247
|
+
HUMD: '0.57'
|
248
248
|
九宮碼頭:
|
249
|
-
time: '2016-
|
249
|
+
time: '2016-11-04T11:20:00+08:00'
|
250
250
|
city: 金門縣
|
251
251
|
town: 烈嶼鄉
|
252
|
-
TEMP:
|
253
|
-
HUMD:
|
252
|
+
TEMP: "-998.0"
|
253
|
+
HUMD: "-998.00"
|
data/spec/spec_helper.rb
CHANGED
@@ -3,6 +3,9 @@ SimpleCov.start
|
|
3
3
|
|
4
4
|
require_relative '../lib/weatai/cwb.rb'
|
5
5
|
require_relative '../lib/weatai/cwb_api.rb'
|
6
|
+
require_relative '../lib/weatai/cwb_rain.rb'
|
7
|
+
require_relative '../lib/weatai/cwb_psi.rb'
|
8
|
+
require_relative '../lib/weatai/instant.rb'
|
6
9
|
|
7
10
|
require 'minitest/autorun'
|
8
11
|
require 'minitest/rg'
|
@@ -18,13 +21,15 @@ CWB_RESPONSE = YAML.load(File.read('spec/fixtures/data.yml'))
|
|
18
21
|
if File.file?('config/credentials.yml')
|
19
22
|
CREDENTIALS = YAML.load(File.read('config/credentials.yml'))
|
20
23
|
ENV['AUTH_KEY'] = CREDENTIALS[:key]
|
21
|
-
ENV['
|
24
|
+
ENV['DATA_ID1'] = CREDENTIALS[:dataid1]
|
25
|
+
ENV['DATA_ID2'] = CREDENTIALS[:dataid2]
|
26
|
+
ENV['FORMAT'] = CREDENTIALS[:format]
|
27
|
+
ENV['TOKEN'] = CREDENTIALS[:token]
|
22
28
|
end
|
23
29
|
|
24
|
-
WeatherStations = ['基隆','淡水','板橋','竹子湖','鞍部','新竹','臺中','
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
WeatherStationsAmount = 41
|
30
|
+
WeatherStations = ['基隆','淡水','板橋','竹子湖','鞍部','新竹','臺中','梧棲',
|
31
|
+
'澎湖','日月潭','阿里山','玉山','嘉義','臺南','高雄','恆春',
|
32
|
+
'宜蘭','蘇澳','花蓮','成功','臺東','大武','蘭嶼','彭佳嶼',
|
33
|
+
'東吉島','永康','拉拉山','武陵','太魯閣','新店','臺北',
|
34
|
+
'彰師大','吉貝','金門','馬祖','麥寮','新屋','古坑']
|
35
|
+
WeatherStationsAmount = 38
|