forecast 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.README.md.html +480 -0
- data/.gitignore +19 -0
- data/.project +11 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +32 -0
- data/Rakefile +1 -0
- data/dump.rdb +1 -0
- data/forecast.gemspec +27 -0
- data/lib/forecast/adapter.rb +204 -0
- data/lib/forecast/adapters/open_weather_map_adapter.rb +95 -0
- data/lib/forecast/adapters/open_weather_map_adapter.yml +18 -0
- data/lib/forecast/adapters/wunderground_adapter.rb +70 -0
- data/lib/forecast/adapters/yahoo_adapter.rb +90 -0
- data/lib/forecast/cache.rb +7 -0
- data/lib/forecast/collection.rb +28 -0
- data/lib/forecast/conditions.yml +12 -0
- data/lib/forecast/config.rb +74 -0
- data/lib/forecast/config.yml +6 -0
- data/lib/forecast/model.rb +71 -0
- data/lib/forecast/themes/weather_icons.yml +10 -0
- data/lib/forecast/utils.rb +32 -0
- data/lib/forecast/version.rb +3 -0
- data/lib/forecast.rb +134 -0
- data/spec/forecast_spec.rb +41 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MjEzYjY5MzJiZWUyMGIxNjIxOTAyZTBmY2NkYmE1NDFiMDA4MDI4ZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjE4MDM0ZDVjODYzZDg5MmYyZGU2MThjMzI2ZDc2NDkwZWMzYzgzNg==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MWEyMzRmNTNiMGEyOGM4OTZmYzdlNDk2ZDI4NmFkMTliODMwZjkwNTRmMGY1
|
10
|
+
MjFlNmVhNDRhNjY5NWM3ZWE2MzNlNWNmZTA5NjE1MWUzZWMwMTEyNTQ5MDJh
|
11
|
+
OTk1NGMyMDI5NWM0MmFiNzdkZDFjMjJhMTZkM2RkYTgzYjc2ODU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MDA3MWY5NmM4MGY4YjYyNjdkM2RjN2NmNzg2OTczMmJmYjdhN2VkYjZlOWJk
|
14
|
+
N2YzMzMyZTVjMzY4MDViZjg5YmVkMzNhNmI1Y2YzNDFhNDQ5YWE0Y2I1YmVi
|
15
|
+
YTEzMDUwNTcxOTM2YmMwNmFiOGI0MWMwZDNmNDU2NzlhZDQwYjc=
|
data/.README.md.html
ADDED
@@ -0,0 +1,480 @@
|
|
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>
|
data/.gitignore
ADDED
data/.project
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 rexblack
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
forecast
|
2
|
+
========
|
3
|
+
|
4
|
+
A Forecast-Multi-API-Wrapper with a unified model and integrated caching
|
5
|
+
|
6
|
+
|
7
|
+
Integrating with rails
|
8
|
+
----------------------
|
9
|
+
|
10
|
+
#### Quick start
|
11
|
+
|
12
|
+
Add weather-icons theme to your stylesheets from cdn
|
13
|
+
```erb
|
14
|
+
<%= stylesheet_link_tag "http://cdnjs.cloudflare.com/ajax/libs/weather-icons/1.2/css/weather-icons.css", media: "all", "data-turbolinks-track" => true %>
|
15
|
+
```
|
16
|
+
Create a forecast-helper
|
17
|
+
```ruby
|
18
|
+
module ApplicationHelper
|
19
|
+
def forecast(latitude, longitude, date)
|
20
|
+
forecast = Forecast.daily(latitude, longitude).select_date(date)
|
21
|
+
content_tag('span', content_tag('i', ' ', class: "forecast-icon " + forecast.icon) + " ".html_safe + content_tag('span', (forecast.temp.to_s + "°").html_safe, class: 'forecast-temp'), class: 'forecast')
|
22
|
+
end
|
23
|
+
end
|
24
|
+
```
|
25
|
+
|
26
|
+
Create a view
|
27
|
+
```erb
|
28
|
+
<h1>Forecast Test</h1>
|
29
|
+
<p>
|
30
|
+
The weather of tomorrow in New York: <%= forecast(41.145495, -73.994901, Time.now + 60*60*24) %>
|
31
|
+
</p>
|
32
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/dump.rdb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
REDIS0006�ܳC�Z��V
|
data/forecast.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'forecast/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "forecast"
|
8
|
+
spec.version = Forecast::VERSION
|
9
|
+
spec.authors = ["Rafael Nowrotek"]
|
10
|
+
spec.email = ["mail@benignware.com"]
|
11
|
+
spec.summary = %q{A Forecast-Multi-API-Wrapper with a unified model and integrated caching}
|
12
|
+
spec.description = %q{A Forecast-Multi-API-Wrapper with a unified model and integrated caching}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "redis"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
spec.add_development_dependency "rspec", "~> 2.6"
|
26
|
+
|
27
|
+
end
|