rss_timeline 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: bef8eacf2a519a1f547819c87b8d1cb3d869231c
4
- data.tar.gz: d2b41eefd9664b2e7840aa9c301ca3d776a2c55e
2
+ SHA256:
3
+ metadata.gz: 75d51049a865b301089684387077084461e29500cf515c51596b20efd0095d46
4
+ data.tar.gz: 9acc314a0929fbc6f0f28d58161d661bb694a8a13b64d617d76100a0c2958eb3
5
5
  SHA512:
6
- metadata.gz: 93bf48714a5fe92c1994045098046b776e232ca60adda260611652c1c10aeee75d42a72a07fddee9d28c2209422f4098b2cd996c269e9fdc029df0f27fa4a763
7
- data.tar.gz: a96d6a140ae9946e3da889ad638e2d8fdd8e25d1bfef485fe0707af5d6e40d99b62c91fe2b23ae5d76709a89635a4c65106267f6ac6ce653f44228c92cd567f3
6
+ metadata.gz: 6761af952c7a0ec6b0aedf116ac7d9ec9875b49180d03bafafe65b3f5a3ff08fa9c2163f98b956eab51e32f525ecc79de987c808636a0626cef47a9c85dfd19c
7
+ data.tar.gz: ce41ce4e99fe7956af62bed1c3094217fff4f190374316117c4c0a08548afcdd64f327f491a661babfc7d8f17702e767a4fb408b37a1998fed2c41fe941ca75c
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rss_timeline.rb CHANGED
@@ -9,12 +9,12 @@ require 'rss_creator'
9
9
 
10
10
 
11
11
  class RSStimeline
12
-
12
+
13
13
  attr_accessor :rssfile
14
14
 
15
- def initialize(feeds=[], rssfile: 'timeline.rss', xslt: nil,
15
+ def initialize(feeds=[], rssfile: 'timeline.rss', xslt: nil,
16
16
  filepath: '.', debug: false, target_filepath: nil)
17
-
17
+
18
18
  @source_feeds, @debug, @rssfile, @newupdate = feeds, debug, rssfile, false
19
19
  @target_filepath = target_filepath
20
20
 
@@ -27,15 +27,15 @@ class RSStimeline
27
27
  FileUtils.mkdir_p @cache_filepath
28
28
 
29
29
  if File.exists? rssfile then
30
- @timeline =RSScreator.new rssfile
31
- else
30
+ @timeline = RSScreator.new rssfile
31
+ else
32
32
 
33
- @timeline =RSScreator.new
33
+ @timeline = RSScreator.new
34
34
  self.title = 'My RSStimeline feed'
35
- self.description = 'Generated using the RSStimeline gem'
36
-
35
+ self.description = 'Generated using the RSStimeline gem'
36
+
37
37
  end
38
-
38
+
39
39
  @timeline.xslt = xslt if xslt
40
40
  puts '@timeline.xslt : ' + @timeline.xslt.inspect if @debug
41
41
 
@@ -44,19 +44,19 @@ class RSStimeline
44
44
  def update()
45
45
 
46
46
  # fetch the feeds from the web
47
- feeds = @source_feeds.map {|feed| [feed, SimpleRSS.parse(open(feed))] }
47
+ feeds = @source_feeds.map {|feed| [feed, SimpleRSS.parse(URI.open(feed))] }
48
48
 
49
49
  # check for each feed from the cache.
50
50
  # if the feed is in the cache, compare the 2 to find any new items.
51
51
  # New items should be added to the main timeline RSS feed
52
-
52
+
53
53
  updated = false
54
54
 
55
55
  feeds.each do |feed, rss|
56
56
 
57
57
  rssfile = File.join(@cache_filepath, feed[6..-1].gsub(/\W+/,'').\
58
58
  reverse.slice(0,40).reverse)
59
-
59
+
60
60
  if File.exists? rssfile then
61
61
 
62
62
  rss_cache = SimpleRSS.parse File.read(rssfile)
@@ -64,105 +64,112 @@ class RSStimeline
64
64
  fresh, old = [rss.items, rss_cache.items].map do |feed|
65
65
  feed.clone.each {|x| x.delete :guid }
66
66
  end
67
-
67
+
68
+
68
69
  new_items = fresh - old
69
-
70
+
71
+ if @debug then
72
+ puts 'fresh: ' + fresh.inspect
73
+ puts 'old: ' + old.inspect
74
+ puts 'new_items: ' + new_items.inspect
75
+ end
76
+
70
77
  new_rss_items = new_items.map do |x|
71
78
  rss.items.find {|y| y[:title] == x[:title]}
72
79
  end
73
-
80
+
74
81
  new_rss_items.reverse.each {|item| add_new item}
75
-
82
+
76
83
  if new_rss_items.any? then
77
84
  puts 'new_rss_items: ' + new_rss_items.inspect if @debug
78
85
  updated = true
79
- File.write rssfile, rss.source
86
+ File.write rssfile, rss.source
80
87
  end
81
-
88
+
82
89
  else
83
90
 
84
91
  updated = true
85
92
  add_new rss.items.first
86
93
  File.write rssfile, rss.source
87
-
94
+
88
95
  end
89
96
  end
90
-
97
+
91
98
  save() if updated
92
-
99
+
93
100
  end
94
-
101
+
95
102
  def description()
96
103
  @timeline.description
97
104
  end
98
-
105
+
99
106
  def description=(val)
100
107
  @timeline.description = val
101
108
  end
102
-
109
+
103
110
  def link(val)
104
111
  @timeline.link
105
112
  end
106
-
113
+
107
114
  def link=(val)
108
115
  @timeline = val
109
116
  end
110
-
117
+
111
118
  def title()
112
119
  @timeline.title
113
120
  end
114
-
121
+
115
122
  def title=(val)
116
123
  @timeline.title = val
117
124
  end
118
-
125
+
119
126
  protected
120
-
127
+
121
128
  def on_new_item(item)
122
- # you can override this method to create your
129
+ # you can override this method to create your
123
130
  # own notifier, callback, or webhook
124
131
  end
125
-
132
+
126
133
  def on_update()
127
- # you can override this method to create your
134
+ # you can override this method to create your
128
135
  # own notifier, callback, or webhook
129
- end
130
-
136
+ end
137
+
131
138
  private
132
-
139
+
133
140
  def add_new(item)
134
-
141
+
135
142
  puts 'inside add_new: ' + item.inspect if @debug
136
-
143
+
137
144
  @timeline.add item: new_item(item), id: nil
138
145
  @newupdate = true
139
146
  on_new_item(item)
140
-
147
+
141
148
  end
142
-
149
+
143
150
  def new_item(x)
144
-
151
+
145
152
  h = {
146
- title: x[:title],
147
- link: x[:link],
148
- description: x[:description],
153
+ title: x[:title],
154
+ link: x[:link],
155
+ description: x[:description],
149
156
  date: x[:date] || Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
150
157
  }
151
-
158
+
152
159
  puts 'inside new_item: ' + h.inspect if @debug
153
-
160
+
154
161
  h
155
-
162
+
156
163
  end
157
-
164
+
158
165
  def save()
159
-
166
+
160
167
  @newupdate = false
161
-
168
+
162
169
  @timeline.save File.join(@filepath, @rssfile)
163
170
  @timeline.save File.join(@target_filepath, @rssfile) if @target_filepath
164
- on_update()
165
-
171
+ on_update()
172
+
166
173
  end
167
-
174
+
168
175
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rss_timeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,28 +10,32 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
- YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
- 8ixkARkWAmV1MB4XDTE3MDMxNDEzNTEyN1oXDTE4MDMxNDEzNTEyN1owSDESMBAG
16
- A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
- EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBANw+TZR6TmXbOqWm3wd4+9vHKqr5u9Fc34kQMk4XPhlvWL6cOgKPMKB/8e0g
19
- 5VLqFe1Z6Baih0SK7KMiQTfOgJHBWuvf3sEm1O6dSrhZk0MXGOG37XEcmezgvGEf
20
- xD82LMrJU35O8pX8Cwz4Y4Ar2iWtD+PldtyZt9MZhPVj74pxZh6zIPxBOk/NJOK4
21
- geZaawUOoFszKYpmjxSYMQk42/goI80LxyrHViIVaBqU2w//YVc+roM2/Qdq46mC
22
- X3FEaI6xIkdTMR9tpWPHRi0m6QxyUYKiFPzOIfdj7RAEZrzUjnJvcG8S7kh395XC
23
- 91znHhbDa0isqSpP89mj34KiR4cCAw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2mzNoDK6P7AL4m7kfnLfQUIc2aF5x9/zIcBi5tEMDcnujsKH
36
+ l5hjs/75OfrhM2lNdizSwpSW
33
37
  -----END CERTIFICATE-----
34
- date: 2018-02-03 00:00:00.000000000 Z
38
+ date: 2021-11-18 00:00:00.000000000 Z
35
39
  dependencies:
36
40
  - !ruby/object:Gem::Dependency
37
41
  name: simple-rss
@@ -42,7 +46,7 @@ dependencies:
42
46
  version: '1.3'
43
47
  - - ">="
44
48
  - !ruby/object:Gem::Version
45
- version: 1.3.1
49
+ version: 1.3.3
46
50
  type: :runtime
47
51
  prerelease: false
48
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -52,29 +56,29 @@ dependencies:
52
56
  version: '1.3'
53
57
  - - ">="
54
58
  - !ruby/object:Gem::Version
55
- version: 1.3.1
59
+ version: 1.3.3
56
60
  - !ruby/object:Gem::Dependency
57
61
  name: rss_creator
58
62
  requirement: !ruby/object:Gem::Requirement
59
63
  requirements:
60
64
  - - "~>"
61
65
  - !ruby/object:Gem::Version
62
- version: '0.3'
66
+ version: '0.4'
63
67
  - - ">="
64
68
  - !ruby/object:Gem::Version
65
- version: 0.3.11
69
+ version: 0.4.2
66
70
  type: :runtime
67
71
  prerelease: false
68
72
  version_requirements: !ruby/object:Gem::Requirement
69
73
  requirements:
70
74
  - - "~>"
71
75
  - !ruby/object:Gem::Version
72
- version: '0.3'
76
+ version: '0.4'
73
77
  - - ">="
74
78
  - !ruby/object:Gem::Version
75
- version: 0.3.11
79
+ version: 0.4.2
76
80
  description:
77
- email: james@jamesrobertson.eu
81
+ email: digital.robertson@gmail.com
78
82
  executables: []
79
83
  extensions: []
80
84
  extra_rdoc_files: []
@@ -100,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
100
104
  version: '0'
101
105
  requirements: []
102
106
  rubyforge_project:
103
- rubygems_version: 2.6.13
107
+ rubygems_version: 2.7.10
104
108
  signing_key:
105
109
  specification_version: 4
106
110
  summary: An RSS aggregator which generates an RSS file
metadata.gz.sig CHANGED
Binary file