rss_creator 0.2.2 → 0.2.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/rss_creator.rb +26 -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: 03c7921871f1a37a2fa2d6cd544baa844f4f1a18
|
4
|
+
data.tar.gz: 7f04bda066cf647da72731324b3e4a8890f04642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc9af4c46ba46a2aa04716d062686acc0ef3218c66746fb5133d8c953841ebf2546bffd7d91977a04a92f96bb0261bbe06d4175c0b55885aad4852bf35b44045
|
7
|
+
data.tar.gz: b6932abd33c7dc3c07b39b83c5e5679604f6dfc9e8c93d4b91fb00131e72988bf827ea79e1cbaab203fa59788dee78a6c708535521232d9eed75e61be7d170dc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/rss_creator.rb
CHANGED
@@ -14,7 +14,7 @@ class RSScreator
|
|
14
14
|
|
15
15
|
@filepath = filepath
|
16
16
|
|
17
|
-
if filepath then
|
17
|
+
if filepath and File.exists? filepath then
|
18
18
|
|
19
19
|
rtd = RSStoDynarex.new filepath
|
20
20
|
@dx = rtd.to_dynarex
|
@@ -33,17 +33,21 @@ class RSScreator
|
|
33
33
|
'link:link,pubDate:date)'
|
34
34
|
# maxium number of items saved in the RSS feed
|
35
35
|
@limit = 11
|
36
|
+
@dirty = true
|
36
37
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def add(item={title: '', link: '', description: ''})
|
40
|
-
|
41
|
+
|
41
42
|
unless item[:title] and item[:link] then
|
42
43
|
raise 'RSScreator: title or link can\'t be blank'
|
43
44
|
end
|
44
45
|
|
45
46
|
record = {date: Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")}.merge(item)
|
46
47
|
@dx.create record
|
48
|
+
|
49
|
+
@dirty = true
|
50
|
+
|
47
51
|
end
|
48
52
|
|
49
53
|
def save(new_filepath=nil)
|
@@ -51,11 +55,26 @@ class RSScreator
|
|
51
55
|
filepath = new_filepath ? new_filepath : @filepath
|
52
56
|
File.write filepath, print_rss
|
53
57
|
end
|
58
|
+
|
59
|
+
def description=(val)
|
60
|
+
@description = val
|
61
|
+
@dirty = true
|
62
|
+
end
|
54
63
|
|
55
64
|
def dynarex()
|
56
65
|
@dx
|
57
66
|
end
|
58
67
|
|
68
|
+
def link=(val)
|
69
|
+
@link = val
|
70
|
+
@dirty = true
|
71
|
+
end
|
72
|
+
|
73
|
+
def title=(val)
|
74
|
+
@title = val
|
75
|
+
@dirty = true
|
76
|
+
end
|
77
|
+
|
59
78
|
def to_s()
|
60
79
|
print_rss
|
61
80
|
end
|
@@ -63,13 +82,17 @@ class RSScreator
|
|
63
82
|
private
|
64
83
|
|
65
84
|
def print_rss()
|
85
|
+
|
86
|
+
return @rss unless @dirty
|
66
87
|
|
67
88
|
if @title.nil? or @description.nil? then
|
68
89
|
raise 'RSScreator: title or description can\'t be blank'
|
69
90
|
end
|
70
91
|
|
71
92
|
@dx.title, @dx.description, @dx.link = @title, @description, @link || ''
|
72
|
-
@dx.to_rss({limit: @limit})
|
93
|
+
@rss = @dx.to_rss({limit: @limit})
|
94
|
+
@dirty = false
|
95
|
+
@rss
|
73
96
|
|
74
97
|
end
|
75
98
|
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|