myweatherfeed 0.1.0 → 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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/myweatherfeed.rb +27 -3
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d65b79a78287a229370386cfdbc4e3c18bd2040
|
4
|
+
data.tar.gz: 43be9c93572222369f6ecd402631c910eeca3601
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49f5466ec26222061747551e0011923feead76a063d6e862f7668f1063d4eefad3b5f4d545328a7ce54c38c1a1ca2a2d994fd8e6e37a994ef31625715573ce94
|
7
|
+
data.tar.gz: 57513f099185b4f2e7aad354cc8cf220685789b855a1592fc6eb1c4186807d75c83098068c8c57196d5907285ccd954615fbedb0c68d5f0eaa5ad7d8b942c7d0
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/myweatherfeed.rb
CHANGED
@@ -9,7 +9,7 @@ require 'myweatherforecast'
|
|
9
9
|
class MyWeatherFeed < DailyNotices
|
10
10
|
|
11
11
|
def initialize(filepath='', location: nil, api_key: nil, \
|
12
|
-
|
12
|
+
url_base: '', dx_xslt: '', rss_xslt: '', refreshrate: nil)
|
13
13
|
|
14
14
|
super(filepath, url_base: url_base, dx_xslt: dx_xslt, rss_xslt: rss_xslt)
|
15
15
|
|
@@ -17,13 +17,37 @@ class MyWeatherFeed < DailyNotices
|
|
17
17
|
self.title = 'My weather feed for ' + \
|
18
18
|
(location || @w.coordinates.join(', '))
|
19
19
|
self.description = 'Weather data fetched from forecast.io'
|
20
|
+
|
21
|
+
# set the time last updated in the hidden scratch file if refreshrate set
|
22
|
+
|
23
|
+
@datafile = File.join(@filepath, '.myweatherfeed')
|
24
|
+
@refreshrate = refreshrate
|
25
|
+
|
26
|
+
if refreshrate then
|
27
|
+
|
28
|
+
@h = File.exists?(@datafile) ? Kvx.new(File.read(@datafile)).to_h : {nextrefresh: Time.now.to_s, notice: ''}
|
20
29
|
|
30
|
+
end
|
31
|
+
|
21
32
|
end
|
22
33
|
|
23
34
|
def update()
|
35
|
+
|
36
|
+
return if @refreshrate and Time.parse(@h[:nextrefresh]) > Time.now
|
37
|
+
|
38
|
+
notice = @w.now.to_s
|
39
|
+
|
40
|
+
return if notice == @h[:notice]
|
41
|
+
|
42
|
+
self.add notice
|
24
43
|
|
25
|
-
|
44
|
+
if @refreshrate then
|
45
|
+
|
46
|
+
@h = {nextrefresh: (Time.now + @refreshrate * 60).to_s, notice: notice}
|
47
|
+
File.write @datafile, Kvx.new(@h)
|
48
|
+
|
49
|
+
end
|
26
50
|
|
27
51
|
end
|
28
52
|
|
29
|
-
end
|
53
|
+
end
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|