forecast 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +11 -1
- data/CHANGELOG.md +27 -0
- data/README.md +196 -8
- data/bin/forecast +94 -0
- data/forecast.gemspec +4 -3
- data/lib/forecast/adapter.rb +126 -123
- data/lib/forecast/adapters/forecast_io_adapter.rb +57 -0
- data/lib/forecast/adapters/open_weather_map_adapter.rb +41 -58
- data/lib/forecast/adapters/wunderground_adapter.rb +53 -29
- data/lib/forecast/adapters/yahoo_adapter.rb +21 -29
- data/lib/forecast/collection.rb +4 -4
- data/lib/forecast/conditions.yml +2 -2
- data/lib/forecast/config.rb +4 -5
- data/lib/forecast/config.yml +2 -4
- data/lib/forecast/http.rb +80 -0
- data/lib/forecast/synonyms.yml +32 -0
- data/lib/forecast/themes/weather_icons.yml +10 -8
- data/lib/forecast/utils.rb +101 -6
- data/lib/forecast/version.rb +1 -1
- data/lib/forecast.rb +39 -107
- data/spec/fixtures/locations.yml +21 -0
- data/spec/forecast_spec.rb +58 -27
- data/spec/spec_helper.rb +16 -0
- metadata +28 -22
- data/.README.md.html +0 -480
- data/lib/forecast/adapters/open_weather_map_adapter.yml +0 -18
- data/lib/forecast/cache.rb +0 -7
- data/lib/forecast/model.rb +0 -71
data/.README.md.html
DELETED
@@ -1,480 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
5
|
-
<title>/Users/aphorisme/Documents/Projekte/Kicks App/Workspace/forecast.rb/.README.md.html</title>
|
6
|
-
|
7
|
-
|
8
|
-
<style type="text/css">
|
9
|
-
body {
|
10
|
-
color: #333;
|
11
|
-
font: 13px/1.4 Helvetica,arial,freesans,clean,sans-serif;
|
12
|
-
}
|
13
|
-
|
14
|
-
.markdown-body {
|
15
|
-
border: 1px solid #CACACA;
|
16
|
-
padding: 30px;
|
17
|
-
font-size: 15px;
|
18
|
-
line-height: 1.7;
|
19
|
-
word-wrap: break-word;
|
20
|
-
}
|
21
|
-
.markdown-body > *:first-child {
|
22
|
-
margin-top: 0 !important;
|
23
|
-
}
|
24
|
-
.markdown-body > *:last-child {
|
25
|
-
margin-bottom: 0 !important;
|
26
|
-
}
|
27
|
-
.markdown-body a.absent {
|
28
|
-
color: #C00;
|
29
|
-
}
|
30
|
-
.markdown-body a.anchor {
|
31
|
-
bottom: 0;
|
32
|
-
cursor: pointer;
|
33
|
-
display: block;
|
34
|
-
left: 0;
|
35
|
-
margin-left: -30px;
|
36
|
-
padding-left: 30px;
|
37
|
-
padding-right: 6px;
|
38
|
-
position: absolute;
|
39
|
-
top: 0;
|
40
|
-
}
|
41
|
-
.markdown-body a.anchor:focus {
|
42
|
-
outline: medium none;
|
43
|
-
}
|
44
|
-
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4, .markdown-body h5, .markdown-body h6 {
|
45
|
-
cursor: text;
|
46
|
-
font-weight: bold;
|
47
|
-
line-height: 1.7;
|
48
|
-
margin: 1em 0 15px;
|
49
|
-
padding: 0;
|
50
|
-
position: relative;
|
51
|
-
}
|
52
|
-
|
53
|
-
.markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link {
|
54
|
-
color: #000;
|
55
|
-
display: none;
|
56
|
-
}
|
57
|
-
.markdown-body h1:hover a.anchor, .markdown-body h2:hover a.anchor, .markdown-body h3:hover a.anchor, .markdown-body h4:hover a.anchor, .markdown-body h5:hover a.anchor, .markdown-body h6:hover a.anchor {
|
58
|
-
line-height: 1;
|
59
|
-
margin-left: -22px;
|
60
|
-
padding-left: 0;
|
61
|
-
text-decoration: none;
|
62
|
-
top: 15%;
|
63
|
-
}
|
64
|
-
.markdown-body h1:hover a.anchor .octicon-link, .markdown-body h2:hover a.anchor .octicon-link, .markdown-body h3:hover a.anchor .octicon-link, .markdown-body h4:hover a.anchor .octicon-link, .markdown-body h5:hover a.anchor .octicon-link, .markdown-body h6:hover a.anchor .octicon-link {
|
65
|
-
display: inline-block;
|
66
|
-
}
|
67
|
-
.markdown-body h1 tt, .markdown-body h1 code, .markdown-body h2 tt, .markdown-body h2 code, .markdown-body h3 tt, .markdown-body h3 code, .markdown-body h4 tt, .markdown-body h4 code, .markdown-body h5 tt, .markdown-body h5 code, .markdown-body h6 tt, .markdown-body h6 code {
|
68
|
-
font-size: inherit;
|
69
|
-
}
|
70
|
-
.markdown-body h1 {
|
71
|
-
border-bottom: 1px solid #DDD;
|
72
|
-
font-size: 2.5em;
|
73
|
-
}
|
74
|
-
.markdown-body h2 {
|
75
|
-
border-bottom: 1px solid #EEE;
|
76
|
-
font-size: 2em;
|
77
|
-
}
|
78
|
-
.markdown-body h3 {
|
79
|
-
font-size: 1.5em;
|
80
|
-
}
|
81
|
-
.markdown-body h4 {
|
82
|
-
font-size: 1.2em;
|
83
|
-
}
|
84
|
-
.markdown-body h5 {
|
85
|
-
font-size: 1em;
|
86
|
-
}
|
87
|
-
.markdown-body h6 {
|
88
|
-
color: #777;
|
89
|
-
font-size: 1em;
|
90
|
-
}
|
91
|
-
.markdown-body p, .markdown-body blockquote, .markdown-body ul, .markdown-body ol, .markdown-body dl, .markdown-body table, .markdown-body pre {
|
92
|
-
margin: 15px 0;
|
93
|
-
}
|
94
|
-
.markdown-body ul, .markdown-body ol {
|
95
|
-
padding-left: 30px;
|
96
|
-
}
|
97
|
-
.markdown-body ul.no-list, .markdown-body ol.no-list {
|
98
|
-
list-style-type: none;
|
99
|
-
padding: 0;
|
100
|
-
}
|
101
|
-
.markdown-body ul ul, .markdown-body ul ol, .markdown-body ol ol, .markdown-body ol ul {
|
102
|
-
margin-bottom: 0;
|
103
|
-
margin-top: 0;
|
104
|
-
}
|
105
|
-
.markdown-body dl {
|
106
|
-
padding: 0;
|
107
|
-
}
|
108
|
-
.markdown-body dl dt {
|
109
|
-
font-size: 14px;
|
110
|
-
font-style: italic;
|
111
|
-
font-weight: bold;
|
112
|
-
margin-top: 15px;
|
113
|
-
padding: 0;
|
114
|
-
}
|
115
|
-
.markdown-body dl dd {
|
116
|
-
margin-bottom: 15px;
|
117
|
-
padding: 0 15px;
|
118
|
-
}
|
119
|
-
.markdown-body blockquote {
|
120
|
-
border-left: 4px solid #DDD;
|
121
|
-
color: #777;
|
122
|
-
padding: 0 15px;
|
123
|
-
}
|
124
|
-
.markdown-body blockquote > *:first-child {
|
125
|
-
margin-top: 0;
|
126
|
-
}
|
127
|
-
.markdown-body blockquote > *:last-child {
|
128
|
-
margin-bottom: 0;
|
129
|
-
}
|
130
|
-
.markdown-body table {
|
131
|
-
display: block;
|
132
|
-
overflow: auto;
|
133
|
-
width: 100%;
|
134
|
-
border-collapse: collapse;
|
135
|
-
}
|
136
|
-
.markdown-body table th {
|
137
|
-
font-weight: bold;
|
138
|
-
}
|
139
|
-
.markdown-body table th, .markdown-body table td {
|
140
|
-
border: 1px solid #DDD;
|
141
|
-
padding: 6px 13px;
|
142
|
-
}
|
143
|
-
.markdown-body table tr {
|
144
|
-
background-color: #FFF;
|
145
|
-
border-top: 1px solid #CCC;
|
146
|
-
}
|
147
|
-
.markdown-body table tr:nth-child(2n) {
|
148
|
-
background-color: #F8F8F8;
|
149
|
-
}
|
150
|
-
.markdown-body img {
|
151
|
-
-moz-box-sizing: border-box;
|
152
|
-
-webkit-box-sizing: border-box;
|
153
|
-
-o-box-sizing: border-box;
|
154
|
-
box-sizing: border-box;
|
155
|
-
max-width: 100%;
|
156
|
-
border: 0px;
|
157
|
-
}
|
158
|
-
.markdown-body span.frame {
|
159
|
-
display: block;
|
160
|
-
overflow: hidden;
|
161
|
-
}
|
162
|
-
.markdown-body span.frame > span {
|
163
|
-
border: 1px solid #DDD;
|
164
|
-
display: block;
|
165
|
-
float: left;
|
166
|
-
margin: 13px 0 0;
|
167
|
-
overflow: hidden;
|
168
|
-
padding: 7px;
|
169
|
-
width: auto;
|
170
|
-
}
|
171
|
-
.markdown-body span.frame span img {
|
172
|
-
display: block;
|
173
|
-
float: left;
|
174
|
-
}
|
175
|
-
.markdown-body span.frame span span {
|
176
|
-
clear: both;
|
177
|
-
color: #333;
|
178
|
-
display: block;
|
179
|
-
padding: 5px 0 0;
|
180
|
-
}
|
181
|
-
.markdown-body span.align-center {
|
182
|
-
clear: both;
|
183
|
-
display: block;
|
184
|
-
overflow: hidden;
|
185
|
-
}
|
186
|
-
.markdown-body span.align-center > span {
|
187
|
-
display: block;
|
188
|
-
margin: 13px auto 0;
|
189
|
-
overflow: hidden;
|
190
|
-
text-align: center;
|
191
|
-
}
|
192
|
-
.markdown-body span.align-center span img {
|
193
|
-
margin: 0 auto;
|
194
|
-
text-align: center;
|
195
|
-
}
|
196
|
-
.markdown-body span.align-right {
|
197
|
-
clear: both;
|
198
|
-
display: block;
|
199
|
-
overflow: hidden;
|
200
|
-
}
|
201
|
-
.markdown-body span.align-right > span {
|
202
|
-
display: block;
|
203
|
-
margin: 13px 0 0;
|
204
|
-
overflow: hidden;
|
205
|
-
text-align: right;
|
206
|
-
}
|
207
|
-
.markdown-body span.align-right span img {
|
208
|
-
margin: 0;
|
209
|
-
text-align: right;
|
210
|
-
}
|
211
|
-
.markdown-body span.float-left {
|
212
|
-
display: block;
|
213
|
-
float: left;
|
214
|
-
margin-right: 13px;
|
215
|
-
overflow: hidden;
|
216
|
-
}
|
217
|
-
.markdown-body span.float-left span {
|
218
|
-
margin: 13px 0 0;
|
219
|
-
}
|
220
|
-
.markdown-body span.float-right {
|
221
|
-
display: block;
|
222
|
-
float: right;
|
223
|
-
margin-left: 13px;
|
224
|
-
overflow: hidden;
|
225
|
-
}
|
226
|
-
.markdown-body span.float-right > span {
|
227
|
-
display: block;
|
228
|
-
margin: 13px auto 0;
|
229
|
-
overflow: hidden;
|
230
|
-
text-align: right;
|
231
|
-
}
|
232
|
-
.markdown-body code, .markdown-body tt {
|
233
|
-
background-color: #F8F8F8;
|
234
|
-
border: 1px solid #DDD;
|
235
|
-
border-radius: 3px;
|
236
|
-
margin: 0 2px;
|
237
|
-
padding: 0 5px;
|
238
|
-
}
|
239
|
-
.markdown-body code {
|
240
|
-
white-space: nowrap;
|
241
|
-
}
|
242
|
-
.markdown-body pre > code {
|
243
|
-
border: medium none;
|
244
|
-
margin: 0;
|
245
|
-
padding: 0;
|
246
|
-
white-space: pre;
|
247
|
-
}
|
248
|
-
.markdown-body .highlight pre, .markdown-body pre {
|
249
|
-
background-color: #F8F8F8;
|
250
|
-
border: 1px solid #DDD;
|
251
|
-
border-radius: 3px;
|
252
|
-
font-size: 13px;
|
253
|
-
line-height: 19px;
|
254
|
-
overflow: auto;
|
255
|
-
padding: 6px 10px;
|
256
|
-
}
|
257
|
-
.markdown-body pre code, .markdown-body pre tt {
|
258
|
-
border: medium none;
|
259
|
-
margin: 0;
|
260
|
-
padding: 0;
|
261
|
-
word-wrap: normal;
|
262
|
-
}
|
263
|
-
|
264
|
-
pre, code, tt {
|
265
|
-
font-family: Consolas,"Liberation Mono",Courier,monospace;
|
266
|
-
font-size: 12px;
|
267
|
-
}
|
268
|
-
|
269
|
-
.highlight {
|
270
|
-
background: #FFF;
|
271
|
-
}
|
272
|
-
.highlight .k,
|
273
|
-
.highlight .o,
|
274
|
-
.highlight .cp,
|
275
|
-
.highlight .cs,
|
276
|
-
.highlight .gs,
|
277
|
-
.highlight .gu,
|
278
|
-
.highlight .kc,
|
279
|
-
.highlight .kd,
|
280
|
-
.highlight .kn,
|
281
|
-
.highlight .kp,
|
282
|
-
.highlight .kr,
|
283
|
-
.highlight .kt,
|
284
|
-
.highlight .nc,
|
285
|
-
.highlight .ne,
|
286
|
-
.highlight .nf,
|
287
|
-
.highlight .ow {
|
288
|
-
font-weight: bold;
|
289
|
-
}
|
290
|
-
.highlight .gd,
|
291
|
-
.highlight .gd .x,
|
292
|
-
.highlight .gi,
|
293
|
-
.highlight .gi .x,
|
294
|
-
.type-csharp .highlight .nf,
|
295
|
-
.type-csharp .highlight .nn {
|
296
|
-
color: #000;
|
297
|
-
}
|
298
|
-
.highlight .c,
|
299
|
-
.highlight .cm,
|
300
|
-
.highlight .c1 {
|
301
|
-
color: #998;
|
302
|
-
font-style: italic;
|
303
|
-
}
|
304
|
-
.highlight .err {
|
305
|
-
background-color: #E3D2D2;
|
306
|
-
color: #A61717;
|
307
|
-
}
|
308
|
-
.highlight .cp,
|
309
|
-
.highlight .cs {
|
310
|
-
color: #999;
|
311
|
-
}
|
312
|
-
.highlight .cs,
|
313
|
-
.highlight .ge {
|
314
|
-
font-style: italic;
|
315
|
-
}
|
316
|
-
.highlight .gd {
|
317
|
-
background-color: #FDD;
|
318
|
-
}
|
319
|
-
.highlight .gd .x {
|
320
|
-
background-color: #FAA;
|
321
|
-
}
|
322
|
-
.highlight .gr,
|
323
|
-
.highlight .gt {
|
324
|
-
color: #A00;
|
325
|
-
}
|
326
|
-
.highlight .gh {
|
327
|
-
color: #999;
|
328
|
-
}
|
329
|
-
.highlight .gi {
|
330
|
-
background-color: #DFD;
|
331
|
-
}
|
332
|
-
.highlight .gi .x {
|
333
|
-
background-color: #AFA;
|
334
|
-
}
|
335
|
-
.highlight .go {
|
336
|
-
color: #888;
|
337
|
-
}
|
338
|
-
.highlight .gp,
|
339
|
-
.highlight .nn {
|
340
|
-
color: #555;
|
341
|
-
}
|
342
|
-
.highlight .gu,
|
343
|
-
.highlight .ni {
|
344
|
-
color: #800080;
|
345
|
-
}
|
346
|
-
.highlight .kt {
|
347
|
-
color: #458;
|
348
|
-
}
|
349
|
-
.highlight .m {
|
350
|
-
color: #099;
|
351
|
-
}
|
352
|
-
.highlight .s {
|
353
|
-
color: #D14;
|
354
|
-
}
|
355
|
-
.highlight .n {
|
356
|
-
color: #333;
|
357
|
-
}
|
358
|
-
.highlight .na,
|
359
|
-
.highlight .no,
|
360
|
-
.highlight .nv,
|
361
|
-
.highlight .vc,
|
362
|
-
.highlight .vg,
|
363
|
-
.highlight .vi {
|
364
|
-
color: #008080;
|
365
|
-
}
|
366
|
-
.highlight .nb {
|
367
|
-
color: #0086B3;
|
368
|
-
}
|
369
|
-
.highlight .nc {
|
370
|
-
color: #458;
|
371
|
-
}
|
372
|
-
.highlight .ne,
|
373
|
-
.highlight .nf {
|
374
|
-
color: #900;
|
375
|
-
}
|
376
|
-
.highlight .nt {
|
377
|
-
color: #000080;
|
378
|
-
}
|
379
|
-
.highlight .w {
|
380
|
-
color: #BBB;
|
381
|
-
}
|
382
|
-
.highlight .mf,
|
383
|
-
.highlight .mh,
|
384
|
-
.highlight .mi,
|
385
|
-
.highlight .mo {
|
386
|
-
color: #099;
|
387
|
-
}
|
388
|
-
.highlight .sb,
|
389
|
-
.highlight .sc,
|
390
|
-
.highlight .sd,
|
391
|
-
.highlight .s2,
|
392
|
-
.highlight .se,
|
393
|
-
.highlight .sh,
|
394
|
-
.highlight .si,
|
395
|
-
.highlight .sx,
|
396
|
-
.highlight .s1 {
|
397
|
-
color: #D14;
|
398
|
-
}
|
399
|
-
.highlight .sr {
|
400
|
-
color: #009926;
|
401
|
-
}
|
402
|
-
.highlight .ss {
|
403
|
-
color: #990073;
|
404
|
-
}
|
405
|
-
.highlight .bp {
|
406
|
-
color: #999;
|
407
|
-
}
|
408
|
-
.highlight .il {
|
409
|
-
color: #099;
|
410
|
-
}
|
411
|
-
.highlight .gc {
|
412
|
-
background-color: #EAF2F5;
|
413
|
-
color: #999;
|
414
|
-
}
|
415
|
-
.type-csharp .highlight .k,
|
416
|
-
.type-csharp .highlight .kt {
|
417
|
-
color: #00F;
|
418
|
-
}
|
419
|
-
.type-csharp .highlight .nf {
|
420
|
-
font-weight: normal;
|
421
|
-
}
|
422
|
-
.type-csharp .highlight .nc {
|
423
|
-
color: #2B91AF;
|
424
|
-
}
|
425
|
-
.type-csharp .highlight .s,
|
426
|
-
.type-csharp .highlight .sc {
|
427
|
-
color: #A31515;
|
428
|
-
}
|
429
|
-
|
430
|
-
</style>
|
431
|
-
|
432
|
-
|
433
|
-
<script type="text/javascript">
|
434
|
-
|
435
|
-
function getDocumentScrollTop()
|
436
|
-
{
|
437
|
-
var res = document.body.scrollTop || document.documentElement.scrollTop || window.pageYOffset || 0;
|
438
|
-
// alert(res);
|
439
|
-
return res;
|
440
|
-
}
|
441
|
-
|
442
|
-
function setDocumentScrollTop(ypos)
|
443
|
-
{
|
444
|
-
window.scrollTo(0, ypos);
|
445
|
-
}
|
446
|
-
|
447
|
-
</script>
|
448
|
-
|
449
|
-
|
450
|
-
</head>
|
451
|
-
<body class="markdown-body">
|
452
|
-
<h1> <a name="user-content-forecast" class="anchor" href="..md.html#forecast" aria-hidden="true"><span class="octicon octicon-link"></span></a>forecast</h1>
|
453
|
-
<p>A Forecast-Multi-API-Wrapper with a unified model and integrated caching</p>
|
454
|
-
<h2> <a name="user-content-integrating-with-rails" class="anchor" href="..md.html#integrating-with-rails" aria-hidden="true"><span class="octicon octicon-link"></span></a>Integrating with rails</h2>
|
455
|
-
<h4> <a name="user-content-quick-start" class="anchor" href="..md.html#quick-start" aria-hidden="true"><span class="octicon octicon-link"></span></a>Quick start</h4>
|
456
|
-
<p>Add weather-icons theme to your stylesheets from cdn</p>
|
457
|
-
<div class="highlight highlight-erb">
|
458
|
-
<pre><span class="cp"><%=</span> <span class="n">stylesheet_link_tag</span> <span class="s2">"http://cdnjs.cloudflare.com/ajax/libs/weather-icons/1.2/css/weather-icons.css"</span><span class="p">,</span> <span class="ss">media</span><span class="p">:</span> <span class="s2">"all"</span><span class="p">,</span> <span class="s2">"data-turbolinks-track"</span> <span class="o">=></span> <span class="kp">true</span> <span class="cp">%></span><span class="x"></span>
|
459
|
-
</pre>
|
460
|
-
</div>
|
461
|
-
<p>Create a forecast-helper</p>
|
462
|
-
<div class="highlight highlight-ruby">
|
463
|
-
<pre><span class="k">module</span> <span class="nn">ApplicationHelper</span>
|
464
|
-
<span class="k">def</span> <span class="nf">forecast</span><span class="p">(</span><span class="n">latitude</span><span class="p">,</span> <span class="n">longitude</span><span class="p">,</span> <span class="n">date</span><span class="p">)</span>
|
465
|
-
<span class="n">forecast</span> <span class="o">=</span> <span class="no">Forecast</span><span class="o">.</span><span class="n">daily</span><span class="p">(</span><span class="n">latitude</span><span class="p">,</span> <span class="n">longitude</span><span class="p">)</span><span class="o">.</span><span class="n">select_date</span><span class="p">(</span><span class="n">date</span><span class="p">)</span>
|
466
|
-
<span class="n">content_tag</span><span class="p">(</span><span class="s1">'span'</span><span class="p">,</span> <span class="n">content_tag</span><span class="p">(</span><span class="s1">'i'</span><span class="p">,</span> <span class="s1">' '</span><span class="p">,</span> <span class="ss">class</span><span class="p">:</span> <span class="s2">"forecast-icon "</span> <span class="o">+</span> <span class="n">forecast</span><span class="o">.</span><span class="n">icon</span><span class="p">)</span> <span class="o">+</span> <span class="s2">" "</span><span class="o">.</span><span class="n">html_safe</span> <span class="o">+</span> <span class="n">content_tag</span><span class="p">(</span><span class="s1">'span'</span><span class="p">,</span> <span class="p">(</span><span class="n">forecast</span><span class="o">.</span><span class="n">temp</span><span class="o">.</span><span class="n">to_s</span> <span class="o">+</span> <span class="s2">"&#176;"</span><span class="p">)</span><span class="o">.</span><span class="n">html_safe</span><span class="p">,</span> <span class="ss">class</span><span class="p">:</span> <span class="s1">'forecast-temp'</span><span class="p">),</span> <span class="ss">class</span><span class="p">:</span> <span class="s1">'forecast'</span><span class="p">)</span>
|
467
|
-
<span class="k">end</span>
|
468
|
-
<span class="k">end</span>
|
469
|
-
</pre>
|
470
|
-
</div>
|
471
|
-
<p>Create a view</p>
|
472
|
-
<div class="highlight highlight-erb">
|
473
|
-
<pre><span class="x"><h1>Forecast Test</h1></span>
|
474
|
-
<span class="x"><p></span>
|
475
|
-
<span class="x"> The weather of tomorrow in New York: </span><span class="cp"><%=</span> <span class="n">forecast</span><span class="p">(</span><span class="mi">41</span><span class="o">.</span><span class="mi">145495</span><span class="p">,</span> <span class="o">-</span><span class="mi">73</span><span class="o">.</span><span class="mi">994901</span><span class="p">,</span> <span class="no">Time</span><span class="o">.</span><span class="n">now</span> <span class="o">+</span> <span class="mi">60</span><span class="o">*</span><span class="mi">60</span><span class="o">*</span><span class="mi">24</span><span class="p">)</span> <span class="cp">%></span><span class="x"></span>
|
476
|
-
<span class="x"></p></span>
|
477
|
-
</pre>
|
478
|
-
</div>
|
479
|
-
</body>
|
480
|
-
</html>
|
@@ -1,18 +0,0 @@
|
|
1
|
-
forecast:
|
2
|
-
adapters:
|
3
|
-
open_weather_map:
|
4
|
-
conditions:
|
5
|
-
200..210: Windy
|
6
|
-
211: Storm
|
7
|
-
212..299: 'Heavy Storm'
|
8
|
-
300..399: 'Light Rain'
|
9
|
-
500: 'Light Rain'
|
10
|
-
501: 'Rain'
|
11
|
-
502..599: 'Heavy Rain'
|
12
|
-
600: 'Light Snow'
|
13
|
-
601: 'Snow'
|
14
|
-
602..699: 'Heavy Snow'
|
15
|
-
800: 'Clear'
|
16
|
-
801: 'Partly Cloudy'
|
17
|
-
802..803: 210
|
18
|
-
804..899: 'Mostly Cloudy'
|
data/lib/forecast/cache.rb
DELETED
data/lib/forecast/model.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
class Forecast
|
2
|
-
module Model
|
3
|
-
|
4
|
-
def initialize(object_attribute_hash = {})
|
5
|
-
object_attribute_hash.map do |(k, v)|
|
6
|
-
send("#{k}=", v) if respond_to?("#{k}=")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def icon
|
11
|
-
if Forecast.config.theme.is_a? Hash
|
12
|
-
icon = Forecast.config.theme[self.condition]
|
13
|
-
return icon unless icon == nil
|
14
|
-
end
|
15
|
-
return slugify(self.condition)
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.included(base)
|
19
|
-
base.extend(ClassMethods)
|
20
|
-
end
|
21
|
-
|
22
|
-
def as_json options = {}
|
23
|
-
serialized = Hash.new
|
24
|
-
if self.class.attributes != nil
|
25
|
-
self.class.attributes.each do |attribute|
|
26
|
-
serialized[attribute] = self.public_send attribute
|
27
|
-
end
|
28
|
-
end
|
29
|
-
serialized
|
30
|
-
end
|
31
|
-
|
32
|
-
def to_json *a
|
33
|
-
as_json.to_json a
|
34
|
-
end
|
35
|
-
|
36
|
-
def from_json(json)
|
37
|
-
self.class.attributes.each do |attribute|
|
38
|
-
writer_m = "#{attribute}="
|
39
|
-
value = json[attribute.to_s]
|
40
|
-
if attribute == :date
|
41
|
-
value = DateTime.parse(value)
|
42
|
-
end
|
43
|
-
send(writer_m, value) if respond_to?(writer_m)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def slugify(string)
|
52
|
-
string.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
53
|
-
end
|
54
|
-
|
55
|
-
module ClassMethods
|
56
|
-
|
57
|
-
@attributes = []
|
58
|
-
|
59
|
-
def attributes
|
60
|
-
@attributes
|
61
|
-
end
|
62
|
-
|
63
|
-
def attr_accessor *attrs
|
64
|
-
@attributes = Array attrs
|
65
|
-
super
|
66
|
-
end
|
67
|
-
|
68
|
-
end
|
69
|
-
|
70
|
-
end
|
71
|
-
end
|