rss_creator 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c55bbb375aff51662e10d1254184218dede57bf
4
- data.tar.gz: d646cecb9d7ce17567b596f27a22ebb653ab982c
3
+ metadata.gz: 03c7921871f1a37a2fa2d6cd544baa844f4f1a18
4
+ data.tar.gz: 7f04bda066cf647da72731324b3e4a8890f04642
5
5
  SHA512:
6
- metadata.gz: 51df9b21a6631b9743afa2cba300eac7099061980d1806ee98488043169197fa94fddb1d033f1b801fd85d37248131f28649c986d36a13a1f482b62f38d07a6a
7
- data.tar.gz: 3b021bdecd968143e95ea573c730b79d7a4baf254c1da54037ce0d635c51b55d92f54b427ee2b6ce73a3616667e69bf9d136621e05d336530380d845321429cf
6
+ metadata.gz: fc9af4c46ba46a2aa04716d062686acc0ef3218c66746fb5133d8c953841ebf2546bffd7d91977a04a92f96bb0261bbe06d4175c0b55885aad4852bf35b44045
7
+ data.tar.gz: b6932abd33c7dc3c07b39b83c5e5679604f6dfc9e8c93d4b91fb00131e72988bf827ea79e1cbaab203fa59788dee78a6c708535521232d9eed75e61be7d170dc
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -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
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rss_creator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
Binary file