rss_timeline 0.2.0 → 0.3.0

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
- SHA1:
3
- metadata.gz: 639253db51c59a5e10d6a2303e5f02ec4cac55db
4
- data.tar.gz: 24151e07742f8b43931bf2ef735d11dcc492b3ab
2
+ SHA256:
3
+ metadata.gz: e7d0917dcf6a4513e264221316f73df4adac9a0837f253e5ed74b04bbbfb8069
4
+ data.tar.gz: 05ab3115b5903debd742932fe16fd764194224cd2398992e542c0049a5614aad
5
5
  SHA512:
6
- metadata.gz: e3ada7acf96385bd7d4d693bce9d40bfa07b26107119649c4f9c36bda8149ec8b18427adfb4d07d359f080de05c23f53cfdcb53fa54a43737071ceaad799a8c9
7
- data.tar.gz: 2b58f0f1387eaa709fc4ec345916e82818055053a0e436f70c4649d33ab0a2ca197e0946c391424dba05777d41647211850ecef6708985b5444629c670340e4c
6
+ metadata.gz: bcc1eb504d8e6619ab4749230d9094f5e4610ed08e1da76ab2f2db8124c0885e7f36287585a08a6c42123be084cb489db97d82775834ebbd9dae54c3fc452a68
7
+ data.tar.gz: f36f5f339757d11a464b7632f9da9bb31aeb784c456889c96cb90c815792c26159834eca245410daa9d5dc3ab152664e2db3ee1d06315992636e5ac78ddf29d6
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/rss_timeline.rb CHANGED
@@ -4,17 +4,18 @@
4
4
 
5
5
  require 'simple-rss'
6
6
  require 'open-uri'
7
- require 'fileutils'
8
7
  require 'rss_creator'
8
+ require 'rxfreadwrite'
9
9
 
10
10
 
11
11
  class RSStimeline
12
-
12
+ include RXFReadWriteModule
13
+
13
14
  attr_accessor :rssfile
14
15
 
15
- def initialize(feeds=[], rssfile: 'timeline.rss', xslt: nil,
16
+ def initialize(feeds=[], rssfile: 'timeline.rss', xslt: nil,
16
17
  filepath: '.', debug: false, target_filepath: nil)
17
-
18
+
18
19
  @source_feeds, @debug, @rssfile, @newupdate = feeds, debug, rssfile, false
19
20
  @target_filepath = target_filepath
20
21
 
@@ -24,18 +25,18 @@ class RSStimeline
24
25
  @cache_filepath = File.join(@filepath, 'cache')
25
26
 
26
27
  # create a cache directory if it doesn't already exist
27
- FileUtils.mkdir_p @cache_filepath
28
+ FileX.mkdir_p @cache_filepath
28
29
 
29
- if File.exists? rssfile then
30
- @timeline =RSScreator.new rssfile
31
- else
30
+ if FileX.exists? rssfile then
31
+ @timeline = RSScreator.new rssfile
32
+ else
32
33
 
33
- @timeline =RSScreator.new
34
+ @timeline = RSScreator.new
34
35
  self.title = 'My RSStimeline feed'
35
- self.description = 'Generated using the RSStimeline gem'
36
-
36
+ self.description = 'Generated using the RSStimeline gem'
37
+
37
38
  end
38
-
39
+
39
40
  @timeline.xslt = xslt if xslt
40
41
  puts '@timeline.xslt : ' + @timeline.xslt.inspect if @debug
41
42
 
@@ -44,127 +45,135 @@ class RSStimeline
44
45
  def update()
45
46
 
46
47
  # fetch the feeds from the web
47
- feeds = @source_feeds.map {|feed| [feed, SimpleRSS.parse(open(feed))] }
48
+ feeds = @source_feeds.map do |feed|
49
+ #force_encoding('UTF-8')
50
+ [feed, SimpleRSS.parse(URI.open(feed).read.force_encoding('UTF-8'))]
51
+ end
48
52
 
49
53
  # check for each feed from the cache.
50
54
  # if the feed is in the cache, compare the 2 to find any new items.
51
55
  # New items should be added to the main timeline RSS feed
52
-
56
+
53
57
  updated = false
54
58
 
55
59
  feeds.each do |feed, rss|
56
60
 
57
61
  rssfile = File.join(@cache_filepath, feed[6..-1].gsub(/\W+/,'').\
58
62
  reverse.slice(0,40).reverse)
59
-
63
+
60
64
  if File.exists? rssfile then
61
65
 
62
- rss_cache = SimpleRSS.parse File.read(rssfile)
66
+ rss_cache = SimpleRSS.parse FileX.read(rssfile).force_encoding('UTF-8')
63
67
 
64
68
  fresh, old = [rss.items, rss_cache.items].map do |feed|
65
69
  feed.clone.each {|x| x.delete :guid }
66
70
  end
67
-
71
+
72
+
68
73
  new_items = fresh - old
69
-
74
+
75
+ if @debug then
76
+ puts 'fresh: ' + fresh.inspect
77
+ puts 'old: ' + old.inspect
78
+ puts 'new_items: ' + new_items.inspect
79
+ end
80
+
70
81
  new_rss_items = new_items.map do |x|
71
82
  rss.items.find {|y| y[:title] == x[:title]}
72
83
  end
73
-
84
+
74
85
  new_rss_items.reverse.each {|item| add_new item}
75
-
86
+
76
87
  if new_rss_items.any? then
77
88
  puts 'new_rss_items: ' + new_rss_items.inspect if @debug
78
89
  updated = true
79
- File.write rssfile, rss.source
90
+ FileX.write rssfile, rss.source
80
91
  end
81
-
92
+
82
93
  else
83
94
 
84
95
  updated = true
85
96
  add_new rss.items.first
86
- File.write rssfile, rss.source
87
-
97
+ FileX.write rssfile, rss.source
98
+
88
99
  end
89
100
  end
90
-
101
+
91
102
  save() if updated
92
-
103
+
93
104
  end
94
-
105
+
95
106
  def description()
96
107
  @timeline.description
97
108
  end
98
-
109
+
99
110
  def description=(val)
100
111
  @timeline.description = val
101
112
  end
102
-
113
+
103
114
  def link(val)
104
115
  @timeline.link
105
116
  end
106
-
117
+
107
118
  def link=(val)
108
119
  @timeline = val
109
120
  end
110
-
121
+
111
122
  def title()
112
123
  @timeline.title
113
124
  end
114
-
125
+
115
126
  def title=(val)
116
127
  @timeline.title = val
117
128
  end
118
-
129
+
119
130
  protected
120
-
131
+
121
132
  def on_new_item(item)
122
- # you can override this method to create your
133
+ # you can override this method to create your
123
134
  # own notifier, callback, or webhook
124
135
  end
125
-
136
+
126
137
  def on_update()
127
- # you can override this method to create your
138
+ # you can override this method to create your
128
139
  # own notifier, callback, or webhook
129
- end
130
-
140
+ end
141
+
131
142
  private
132
-
143
+
133
144
  def add_new(item)
134
-
145
+
135
146
  puts 'inside add_new: ' + item.inspect if @debug
136
-
147
+
137
148
  @timeline.add item: new_item(item), id: nil
138
149
  @newupdate = true
139
150
  on_new_item(item)
140
-
151
+
141
152
  end
142
-
153
+
143
154
  def new_item(x)
144
-
155
+
145
156
  h = {
146
- title: x[:title],
147
- link: x[:link],
148
- description: x[:description],
157
+ title: x[:title],
158
+ link: x[:link],
159
+ description: x[:description],
149
160
  date: x[:date] || Time.now.strftime("%a, %d %b %Y %H:%M:%S %z")
150
161
  }
151
-
162
+
152
163
  puts 'inside new_item: ' + h.inspect if @debug
153
-
164
+
154
165
  h
155
-
166
+
156
167
  end
157
-
168
+
158
169
  def save()
159
-
160
- #return unless @newupdate
161
-
162
- on_update()
170
+
163
171
  @newupdate = false
164
-
172
+
165
173
  @timeline.save File.join(@filepath, @rssfile)
166
174
  @timeline.save File.join(@target_filepath, @rssfile) if @target_filepath
167
-
175
+ on_update()
176
+
168
177
  end
169
-
178
+
170
179
  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.0
4
+ version: 0.3.0
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
- 5VLqFe1Z6Baih0SK7KMiQTfOgJHBWuvf3sEm1O6dSrhZk0MXGOG37XEcmezgvGE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aQ12NgqsCq
32
+ dYahrHrep87Kr4mFPl1nfvqM3OArdV720fwePgciO7suRIXPfI8qVnABIlFpWHoo
33
+ uT7Xa9HSWeV7zMgohnPRGVbF+r2yPsVUXPZmb+coXUV4WHsCLypaDojqCanNouyo
34
+ uV5AKfB2wO57X83nRdJ8OzrUzCZVxYX3WpTbUIn/n0k4h7CoCRinO/wUM9aCEuyL
35
+ 9TjZeJfzvcT9qoVK2mzNoDK6P7AL4m7kfnLfQUIc2aF5x9/zIcBi5tEMDcnujsKH
36
+ l5hjs/75OfrhM2lNdizSwpSW
33
37
  -----END CERTIFICATE-----
34
- date: 2018-02-03 00:00:00.000000000 Z
38
+ date: 2022-03-11 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: []
@@ -99,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
103
  - !ruby/object:Gem::Version
100
104
  version: '0'
101
105
  requirements: []
102
- rubyforge_project:
103
- rubygems_version: 2.6.13
106
+ rubygems_version: 3.2.22
104
107
  signing_key:
105
108
  specification_version: 4
106
109
  summary: An RSS aggregator which generates an RSS file
metadata.gz.sig CHANGED
Binary file