weatai 0.1.0
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 +7 -0
- data/.gitignore +5 -0
- data/.travis.yml +12 -0
- data/Gemfile +21 -0
- data/Gemfile.lock +96 -0
- data/LICENSE +21 -0
- data/README.md +34 -0
- data/Rakefile +24 -0
- data/bin/weatai +21 -0
- data/cassettes/all_record.yml +15988 -0
- data/config/credentials.yml.example +3 -0
- data/lib/weatai/cwb.rb +38 -0
- data/lib/weatai/cwb_api.rb +28 -0
- data/lib/weatai/version.rb +3 -0
- data/lib/weatai.rb +2 -0
- data/spec/fixtures/data.yml +253 -0
- data/spec/spec_helper.rb +30 -0
- data/spec/test.rb +92 -0
- data/spec/weatai_spec.rb +100 -0
- data/weatai.gemspec +33 -0
- metadata +222 -0
data/lib/weatai/cwb.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative 'cwb_api'
|
2
|
+
module CWB
|
3
|
+
# Class to organize raw_data, finding the data we need
|
4
|
+
class Weather
|
5
|
+
attr_reader :dataid
|
6
|
+
|
7
|
+
def initialize(data:)
|
8
|
+
@dataid = data['dataid']
|
9
|
+
end
|
10
|
+
|
11
|
+
def instant_weather
|
12
|
+
return @instant_weather if @instant_weather
|
13
|
+
raw_info = CWB::CWBApi.raw_info(@dataid)
|
14
|
+
all_location = {}
|
15
|
+
raw_info['cwbopendata']['location'].each do |item|
|
16
|
+
location = {}
|
17
|
+
place = item['locationName']
|
18
|
+
location['time'] = item['time']['obsTime']
|
19
|
+
location['city'] = item['parameter'][0]['parameterValue']
|
20
|
+
location['town'] = item['parameter'][2]['parameterValue']
|
21
|
+
location['TEMP'] = item['weatherElement'][4]['elementValue']['value']
|
22
|
+
location['HUMD'] = item['weatherElement'][5]['elementValue']['value']
|
23
|
+
all_location.store(place, location)
|
24
|
+
end
|
25
|
+
# File.write('../../spec/fixtures/data.yml', all_location.to_yaml)
|
26
|
+
all_location
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.find(dataid:)
|
30
|
+
raw_data = CWB::CWBApi.raw_info(dataid)
|
31
|
+
new(data: raw_data)
|
32
|
+
end
|
33
|
+
|
34
|
+
def weather_test
|
35
|
+
return 'weather_test_yes'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
require 'yaml'
|
4
|
+
require 'http'
|
5
|
+
module CWB
|
6
|
+
# Service for all weather API calls
|
7
|
+
class CWBApi
|
8
|
+
URL = 'http://opendata.cwb.gov.tw/opendataapi'
|
9
|
+
|
10
|
+
def self.config(credentials)
|
11
|
+
@config ? @config.update(credentials) : @config = credentials
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.config
|
15
|
+
return @config if @config
|
16
|
+
@config = { dataid: ENV['DATA_ID'],
|
17
|
+
key: ENV['AUTH_KEY'] }
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.raw_info(dataid)
|
21
|
+
info_response =
|
22
|
+
HTTP.get(URL,
|
23
|
+
params: { dataid: config[:dataid],
|
24
|
+
authorizationkey: config[:key]})
|
25
|
+
Hash.from_xml(info_response)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/weatai.rb
ADDED
@@ -0,0 +1,253 @@
|
|
1
|
+
---
|
2
|
+
基隆:
|
3
|
+
time: '2016-10-30T21:30:00+08:00'
|
4
|
+
city: 基隆市
|
5
|
+
town: 中山區
|
6
|
+
TEMP: '22.8'
|
7
|
+
HUMD: '0.74'
|
8
|
+
淡水:
|
9
|
+
time: '2016-10-30T21:30:00+08:00'
|
10
|
+
city: 新北市
|
11
|
+
town: 淡水區
|
12
|
+
TEMP: '22.1'
|
13
|
+
HUMD: '0.72'
|
14
|
+
板橋:
|
15
|
+
time: '2016-10-30T21:30:00+08:00'
|
16
|
+
city: 新北市
|
17
|
+
town: 板橋區
|
18
|
+
TEMP: '22.7'
|
19
|
+
HUMD: '0.68'
|
20
|
+
竹子湖:
|
21
|
+
time: '2016-10-30T21:30:00+08:00'
|
22
|
+
city: 臺北市
|
23
|
+
town: 北投區
|
24
|
+
TEMP: '17.2'
|
25
|
+
HUMD: '0.92'
|
26
|
+
鞍部:
|
27
|
+
time: '2016-10-30T21:30:00+08:00'
|
28
|
+
city: 臺北市
|
29
|
+
town: 北投區
|
30
|
+
TEMP: '15.8'
|
31
|
+
HUMD: '0.99'
|
32
|
+
新竹:
|
33
|
+
time: '2016-10-30T21:30:00+08:00'
|
34
|
+
city: 新竹縣
|
35
|
+
town: 竹北市
|
36
|
+
TEMP: '23.0'
|
37
|
+
HUMD: '0.72'
|
38
|
+
臺中:
|
39
|
+
time: '2016-10-30T21:30:00+08:00'
|
40
|
+
city: 臺中市
|
41
|
+
town: 北區
|
42
|
+
TEMP: '24.3'
|
43
|
+
HUMD: '0.70'
|
44
|
+
梧棲:
|
45
|
+
time: '2016-10-30T21:30:00+08:00'
|
46
|
+
city: 臺中市
|
47
|
+
town: 梧棲區
|
48
|
+
TEMP: '22.5'
|
49
|
+
HUMD: '0.72'
|
50
|
+
澎湖:
|
51
|
+
time: '2016-10-30T21:30:00+08:00'
|
52
|
+
city: 澎湖縣
|
53
|
+
town: 馬公市
|
54
|
+
TEMP: '24.6'
|
55
|
+
HUMD: '0.72'
|
56
|
+
日月潭:
|
57
|
+
time: '2016-10-30T21:30:00+08:00'
|
58
|
+
city: 南投縣
|
59
|
+
town: 魚池鄉
|
60
|
+
TEMP: '20.1'
|
61
|
+
HUMD: '0.90'
|
62
|
+
阿里山:
|
63
|
+
time: '2016-10-30T21:30:00+08:00'
|
64
|
+
city: 嘉義縣
|
65
|
+
town: 阿里山鄉
|
66
|
+
TEMP: '12.6'
|
67
|
+
HUMD: '0.90'
|
68
|
+
玉山:
|
69
|
+
time: '2016-10-30T21:30:00+08:00'
|
70
|
+
city: 南投縣
|
71
|
+
town: 信義鄉
|
72
|
+
TEMP: '4.1'
|
73
|
+
HUMD: '0.53'
|
74
|
+
嘉義:
|
75
|
+
time: '2016-10-30T21:30:00+08:00'
|
76
|
+
city: 嘉義市
|
77
|
+
town: 西區
|
78
|
+
TEMP: '23.3'
|
79
|
+
HUMD: '0.80'
|
80
|
+
高雄:
|
81
|
+
time: '2016-10-30T21:30:00+08:00'
|
82
|
+
city: 高雄市
|
83
|
+
town: 前鎮區
|
84
|
+
TEMP: '27.6'
|
85
|
+
HUMD: '0.72'
|
86
|
+
恆春:
|
87
|
+
time: '2016-10-30T21:30:00+08:00'
|
88
|
+
city: 屏東縣
|
89
|
+
town: 恆春鎮
|
90
|
+
TEMP: '26.3'
|
91
|
+
HUMD: '0.70'
|
92
|
+
宜蘭:
|
93
|
+
time: '2016-10-30T21:30:00+08:00'
|
94
|
+
city: 宜蘭縣
|
95
|
+
town: 宜蘭市
|
96
|
+
TEMP: '20.7'
|
97
|
+
HUMD: '0.91'
|
98
|
+
蘇澳:
|
99
|
+
time: '2016-10-30T21:30:00+08:00'
|
100
|
+
city: 宜蘭縣
|
101
|
+
town: 蘇澳鎮
|
102
|
+
TEMP: '20.8'
|
103
|
+
HUMD: '0.92'
|
104
|
+
花蓮:
|
105
|
+
time: '2016-10-30T21:30:00+08:00'
|
106
|
+
city: 花蓮縣
|
107
|
+
town: 花蓮市
|
108
|
+
TEMP: '24.1'
|
109
|
+
HUMD: '0.71'
|
110
|
+
成功:
|
111
|
+
time: '2016-10-30T21:30:00+08:00'
|
112
|
+
city: 臺東縣
|
113
|
+
town: 成功鎮
|
114
|
+
TEMP: '24.0'
|
115
|
+
HUMD: '0.75'
|
116
|
+
臺東:
|
117
|
+
time: '2016-10-30T21:30:00+08:00'
|
118
|
+
city: 臺東縣
|
119
|
+
town: 臺東市
|
120
|
+
TEMP: '23.7'
|
121
|
+
HUMD: '0.77'
|
122
|
+
大武:
|
123
|
+
time: '2016-10-30T21:30:00+08:00'
|
124
|
+
city: 臺東縣
|
125
|
+
town: 大武鄉
|
126
|
+
TEMP: '25.5'
|
127
|
+
HUMD: '0.66'
|
128
|
+
蘭嶼:
|
129
|
+
time: '2016-10-30T21:30:00+08:00'
|
130
|
+
city: 臺東縣
|
131
|
+
town: 蘭嶼鄉
|
132
|
+
TEMP: '23.4'
|
133
|
+
HUMD: '0.79'
|
134
|
+
彭佳嶼:
|
135
|
+
time: '2016-10-30T21:30:00+08:00'
|
136
|
+
city: 基隆市
|
137
|
+
town: 中正區
|
138
|
+
TEMP: '21.8'
|
139
|
+
HUMD: '0.73'
|
140
|
+
東吉島:
|
141
|
+
time: '2016-10-30T21:30:00+08:00'
|
142
|
+
city: 澎湖縣
|
143
|
+
town: 望安鄉
|
144
|
+
TEMP: '25.0'
|
145
|
+
HUMD: '0.75'
|
146
|
+
永康:
|
147
|
+
time: '2016-10-30T21:30:00+08:00'
|
148
|
+
city: 臺南市
|
149
|
+
town: 永康區
|
150
|
+
TEMP: '25.1'
|
151
|
+
HUMD: '0.73'
|
152
|
+
金門(合):
|
153
|
+
time: '2016-10-30T21:30:00+08:00'
|
154
|
+
city: 金門縣
|
155
|
+
town: 金湖鎮
|
156
|
+
TEMP: '22.0'
|
157
|
+
HUMD: '0.67'
|
158
|
+
拉拉山:
|
159
|
+
time: '2016-10-30T21:30:00+08:00'
|
160
|
+
city: 桃園市
|
161
|
+
town: 復興區
|
162
|
+
TEMP: '15.1'
|
163
|
+
HUMD: '0.87'
|
164
|
+
武陵:
|
165
|
+
time: '2016-10-30T21:30:00+08:00'
|
166
|
+
city: 臺中市
|
167
|
+
town: 和平區
|
168
|
+
TEMP: '12.3'
|
169
|
+
HUMD: '0.95'
|
170
|
+
太魯閣:
|
171
|
+
time: '2016-10-30T21:30:00+08:00'
|
172
|
+
city: 花蓮縣
|
173
|
+
town: 秀林鄉
|
174
|
+
TEMP: '22.5'
|
175
|
+
HUMD: '0.89'
|
176
|
+
新店:
|
177
|
+
time: '2016-10-30T21:30:00+08:00'
|
178
|
+
city: 新北市
|
179
|
+
town: 新店區
|
180
|
+
TEMP: "-998.0"
|
181
|
+
HUMD: "-998.00"
|
182
|
+
臺北:
|
183
|
+
time: '2016-10-30T21:30:00+08:00'
|
184
|
+
city: 臺北市
|
185
|
+
town: 中正區
|
186
|
+
TEMP: '22.4'
|
187
|
+
HUMD: '0.75'
|
188
|
+
彰師大:
|
189
|
+
time: '2016-10-30T21:30:00+08:00'
|
190
|
+
city: 彰化縣
|
191
|
+
town: 彰化市
|
192
|
+
TEMP: '23.0'
|
193
|
+
HUMD: '0.67'
|
194
|
+
臺南:
|
195
|
+
time: '2016-10-30T21:30:00+08:00'
|
196
|
+
city: 臺南市
|
197
|
+
town: 中區
|
198
|
+
TEMP: '26.0'
|
199
|
+
HUMD: '0.69'
|
200
|
+
合歡山莊:
|
201
|
+
time: '2016-10-30T21:30:00+08:00'
|
202
|
+
city: 花蓮縣
|
203
|
+
town: 秀林鄉
|
204
|
+
TEMP: '7.7'
|
205
|
+
HUMD: '0.66'
|
206
|
+
吉貝:
|
207
|
+
time: '2016-10-30T21:30:00+08:00'
|
208
|
+
city: 澎湖縣
|
209
|
+
town: 白沙鄉
|
210
|
+
TEMP: '23.9'
|
211
|
+
HUMD: '0.73'
|
212
|
+
東沙:
|
213
|
+
time: '2016-10-30T21:30:00+08:00'
|
214
|
+
city: 高雄市
|
215
|
+
town: 東沙島
|
216
|
+
TEMP: '25.9'
|
217
|
+
HUMD: '1.00'
|
218
|
+
金門:
|
219
|
+
time: '2016-10-30T21:30:00+08:00'
|
220
|
+
city: 金門縣
|
221
|
+
town: 金城鎮
|
222
|
+
TEMP: '22.4'
|
223
|
+
HUMD: '0.67'
|
224
|
+
馬祖:
|
225
|
+
time: '2016-10-30T21:30:00+08:00'
|
226
|
+
city: 連江縣
|
227
|
+
town: 南竿鄉
|
228
|
+
TEMP: '20.6'
|
229
|
+
HUMD: '0.73'
|
230
|
+
麥寮:
|
231
|
+
time: '2016-10-30T21:30:00+08:00'
|
232
|
+
city: 雲林縣
|
233
|
+
town: 麥寮鄉
|
234
|
+
TEMP: '24.9'
|
235
|
+
HUMD: '0.90'
|
236
|
+
新屋:
|
237
|
+
time: '2016-10-30T21:30:00+08:00'
|
238
|
+
city: 桃園市
|
239
|
+
town: 新屋區
|
240
|
+
TEMP: '22.4'
|
241
|
+
HUMD: '0.76'
|
242
|
+
古坑:
|
243
|
+
time: '2016-10-30T21:30:00+08:00'
|
244
|
+
city: 雲林縣
|
245
|
+
town: 古坑鄉
|
246
|
+
TEMP: "-998.0"
|
247
|
+
HUMD: "-998.00"
|
248
|
+
九宮碼頭:
|
249
|
+
time: '2016-10-30T21:30:00+08:00'
|
250
|
+
city: 金門縣
|
251
|
+
town: 烈嶼鄉
|
252
|
+
TEMP: '23.2'
|
253
|
+
HUMD: '0.72'
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require_relative '../lib/weatai/cwb.rb'
|
5
|
+
require_relative '../lib/weatai/cwb_api.rb'
|
6
|
+
|
7
|
+
require 'minitest/autorun'
|
8
|
+
require 'minitest/rg'
|
9
|
+
require 'active_support/all'
|
10
|
+
require 'active_support/core_ext/hash'
|
11
|
+
require 'yaml'
|
12
|
+
require 'http'
|
13
|
+
require 'vcr'
|
14
|
+
require 'webmock'
|
15
|
+
|
16
|
+
|
17
|
+
CWB_RESPONSE = YAML.load(File.read('spec/fixtures/data.yml'))
|
18
|
+
if File.file?('config/credentials.yml')
|
19
|
+
CREDENTIALS = YAML.load(File.read('config/credentials.yml'))
|
20
|
+
ENV['AUTH_KEY'] = CREDENTIALS[:key]
|
21
|
+
ENV['DATA_ID'] = CREDENTIALS[:dataid]
|
22
|
+
end
|
23
|
+
|
24
|
+
WeatherStations = ['基隆','淡水','板橋','竹子湖','鞍部','新竹','臺中','澎湖',
|
25
|
+
'日月潭','阿里山','玉山','嘉義','高雄','恆春','宜蘭','蘇澳',
|
26
|
+
'花蓮','成功','臺東','大武','蘭嶼','彭佳嶼','東吉島','永康',
|
27
|
+
'金門(合)','拉拉山','武陵','太魯閣','新店','臺北','彰師大',
|
28
|
+
'臺南','合歡山莊','吉貝','東沙','金門','馬祖','麥寮','新屋',
|
29
|
+
'古坑','九宮碼頭']
|
30
|
+
WeatherStationsAmount = 41
|
data/spec/test.rb
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'active_support/all'
|
2
|
+
require 'active_support/core_ext/hash'
|
3
|
+
require 'yaml'
|
4
|
+
require 'http'
|
5
|
+
|
6
|
+
|
7
|
+
require_relative '../lib/cwb.rb'
|
8
|
+
require_relative '../lib/cwb_api.rb'
|
9
|
+
|
10
|
+
CWB_RESPONSE = YAML.load(File.read('./fixtures/data.yml'))
|
11
|
+
CREDENTIALS = YAML.load(File.read('../config/credentials.yml'))
|
12
|
+
WeatherStations = ['基隆','淡水','板橋','竹子湖','鞍部','新竹','臺中','澎湖',
|
13
|
+
'日月潭','阿里山','玉山','嘉義','高雄','恆春','宜蘭','蘇澳',
|
14
|
+
'花蓮','成功','臺東','大武','蘭嶼','彭佳嶼','東吉島','永康',
|
15
|
+
'金門(合)','拉拉山','武陵','太魯閣','新店','臺北','彰師大',
|
16
|
+
'臺南','合歡山莊','吉貝','東沙','金門','馬祖','麥寮','新屋',
|
17
|
+
'古坑','九宮碼頭']
|
18
|
+
WeatherStationsAmount = 41
|
19
|
+
|
20
|
+
@cwb_api = CWB::CWBApi.new(
|
21
|
+
data_id: CREDENTIALS[:key],
|
22
|
+
)
|
23
|
+
|
24
|
+
testCWBApi = CWB::Weather.new(
|
25
|
+
@cwb_api
|
26
|
+
)
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
=begin
|
31
|
+
|
32
|
+
#require_relative '../lib/cwb.rb'
|
33
|
+
CWB_RESPONSE = YAML.load(File.read('./fixtures/data.yml'))
|
34
|
+
#CREDENTIALS ssssssssss= YAML.load(File.read('config/credentials.yml'))
|
35
|
+
#CWB_RESPONSE = YAML.load(File.read('./fixtures/data.yml'))
|
36
|
+
#RESULTS = YAML.load(File.read('spec/fixtures/results.yml'))
|
37
|
+
|
38
|
+
WeatherStations = ['基隆','淡水','板橋','竹子湖','鞍部','新竹','臺中','澎湖',
|
39
|
+
'日月潭','阿里山','玉山','嘉義','高雄','恆春','宜蘭','蘇澳',
|
40
|
+
'花蓮','成功','臺東','大武','蘭嶼','彭佳嶼','東吉島','永康',
|
41
|
+
'金門(合)','拉拉山','武陵','太魯閣','新店','臺北','彰師大',
|
42
|
+
'臺南','合歡山莊','吉貝','東沙','金門','馬祖','麥寮','新屋',
|
43
|
+
'古坑','九宮碼頭']
|
44
|
+
|
45
|
+
WeatherStationsAmount = 41
|
46
|
+
|
47
|
+
WeatherStations.each do |name|
|
48
|
+
puts CWB_RESPONSE[name]['TEMP']
|
49
|
+
end
|
50
|
+
|
51
|
+
|
52
|
+
WeatherStations.each do |name|
|
53
|
+
puts name
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
while WeatherStationsAmount > 0
|
60
|
+
puts WeatherStations[WeatherStationsAmount-1]
|
61
|
+
WeatherStationsAmount = WeatherStationsAmount - 1
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
puts CWB_RESPONSE["基隆"]has_key?'TEMP'
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
if CWB_RESPONSE.kind_of?(Hash)
|
72
|
+
puts "hash"
|
73
|
+
else
|
74
|
+
puts "not hash"
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
puts CWB_RESPONSE.has_key?'基隆'
|
79
|
+
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
if CWB_RESPONSE == false
|
85
|
+
puts "空的"
|
86
|
+
else
|
87
|
+
puts "有東西"
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
=end
|
92
|
+
|
data/spec/weatai_spec.rb
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
require_relative 'spec_helper.rb'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
describe 'CWB specifications' do
|
5
|
+
|
6
|
+
VCR.configure do |c|
|
7
|
+
c.cassette_library_dir = 'cassettes'
|
8
|
+
c.hook_into :webmock
|
9
|
+
|
10
|
+
c.filter_sensitive_data('<KEY>') { CREDENTIALS[:key] }
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
VCR.insert_cassette 'all_record', record: :new_episodes
|
15
|
+
# @cwb_api = CWB::CWBApi.config
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
VCR.eject_cassette
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# test 01
|
25
|
+
it 'should be able to get raw info' do
|
26
|
+
# testCWBApi = @cwb_api
|
27
|
+
# testCWBApi.raw_info.wont_be_emptypi
|
28
|
+
testCWB = CWB::Weather.find(dataid: 'O-A0003-001')
|
29
|
+
testCWBA.instant_weather.wont_be_empty
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
#test 02
|
34
|
+
it 'should be able to download the data file in hash format)' do
|
35
|
+
CWB_RESPONSE.kind_of?(Hash).must_equal true
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
# test 03
|
40
|
+
it 'should be able to get instant_weather in hash format' do
|
41
|
+
testWeather = CWB::Weather.new(
|
42
|
+
@cwb_api
|
43
|
+
)
|
44
|
+
testWeather.instant_weather.kind_of?(Hash).must_equal true
|
45
|
+
end
|
46
|
+
=begin
|
47
|
+
#test 04
|
48
|
+
it 'should get name of every Weather Stations' do
|
49
|
+
testWeather = CWB::Weather.new(
|
50
|
+
@cwb_api
|
51
|
+
)
|
52
|
+
instant_weather = testWeather.instant_weather
|
53
|
+
WeatherStations.each do |name|
|
54
|
+
CWB_RESPONSE.has_key?(name).must_equal true
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
# test 05
|
61
|
+
it 'should get temperature of every Weather Stations' do
|
62
|
+
testWeather = CWB::Weather.new(
|
63
|
+
@cwb_api
|
64
|
+
)
|
65
|
+
instant_weather = testWeather.instant_weather
|
66
|
+
puts instant_weather["烏坵"]
|
67
|
+
WeatherStations.each do |name|
|
68
|
+
instant_weather[name].has_key?('TEMP').must_equal true
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
WeatherStations.each do |name|
|
73
|
+
instant_weather[name]['TEMP'].wont_be_empty
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# test 06
|
80
|
+
it 'should get time of every Weather Stations' do
|
81
|
+
testWeather = CWB::Weather.new(
|
82
|
+
@cwb_api
|
83
|
+
)
|
84
|
+
instant_weather = testWeather.instant_weather
|
85
|
+
WeatherStations.each do |name|
|
86
|
+
instant_weather[name].has_key?('time').must_equal true
|
87
|
+
end
|
88
|
+
|
89
|
+
WeatherStations.each do |name|
|
90
|
+
instant_weather[name]['time'].wont_be_empty
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
=end
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
end
|
data/weatai.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'weatai/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'weatai'
|
7
|
+
s.version = CWB::VERSION
|
8
|
+
|
9
|
+
s.summary = 'Get weather content from central weather bureau(Taiwan);'
|
10
|
+
s.description = 'Extracts temperature and humidity for different city'
|
11
|
+
s.authors = ['soainfinite888']
|
12
|
+
s.email = ['wer321011@gmail.com']
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
|
+
s.executables << 'weatai'
|
17
|
+
|
18
|
+
s.add_runtime_dependency 'http', '~> 2.0'
|
19
|
+
s.add_runtime_dependency 'activesupport ', '~> 5.0'
|
20
|
+
|
21
|
+
s.add_development_dependency 'minitest', '~> 5.9'
|
22
|
+
s.add_development_dependency 'minitest-rg', '~> 5.2'
|
23
|
+
s.add_development_dependency 'rake', '~> 11.3'
|
24
|
+
s.add_development_dependency 'vcr', '~> 3.0'
|
25
|
+
s.add_development_dependency 'webmock', '~> 2.1'
|
26
|
+
s.add_development_dependency 'simplecov', '~> 0.12'
|
27
|
+
s.add_development_dependency 'flog', '~> 4.4'
|
28
|
+
s.add_development_dependency 'flay', '~> 2.8'
|
29
|
+
s.add_development_dependency 'rubocop', '~> 0.42'
|
30
|
+
|
31
|
+
s.homepage = 'https://github.com/soainfinite888/weatai'
|
32
|
+
s.license = 'MIT'
|
33
|
+
end
|