pluto-models 1.6.0 → 1.6.1
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
- data/lib/pluto/models/feed.rb +42 -0
- data/lib/pluto/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08550943793b98bc0cdbebdc2d767bbbca2ab5d1'
|
4
|
+
data.tar.gz: 30d7e476d091976a60f67850087a5280ec58a2f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59635030a51054b62fdfe08776d389a0b1e691530e39808b66bfcc594f8fa685a5489a093de2611e25d56dded8cfdaa27987b9f5c3328179423bfb5fc516629f
|
7
|
+
data.tar.gz: b0b6f369726828bfa0d42f156cd37f7c2eccb0273b19e379808453521962c64b75a545e5cfaaeebab4e77106f24b03e86d9d181bc01964857aae76a6f2b84552
|
data/lib/pluto/models/feed.rb
CHANGED
@@ -52,6 +52,7 @@ class Feed < ActiveRecord::Base
|
|
52
52
|
alias_attr_reader :desc, :summary # alias(2) for summary
|
53
53
|
alias_attr_reader :subtitle, :summary # alias(3) for summary
|
54
54
|
alias_attr_reader :link, :url # alias for url
|
55
|
+
alias_attr_reader :html_url, :url # alias(2) for url
|
55
56
|
alias_attr_reader :feed, :feed_url # alias for feed_url
|
56
57
|
|
57
58
|
alias_attr_reader :author_name, :author # alias for author
|
@@ -130,6 +131,11 @@ class Feed < ActiveRecord::Base
|
|
130
131
|
## (e.g. data.items.size == 0).
|
131
132
|
if data.items.size > 0
|
132
133
|
|
134
|
+
#####
|
135
|
+
## apply some fix-up for "broken" feed data
|
136
|
+
fix_dates( data )
|
137
|
+
|
138
|
+
|
133
139
|
######
|
134
140
|
## check for filters (includes/excludes) if present
|
135
141
|
## for now just check for includes
|
@@ -208,6 +214,42 @@ class Feed < ActiveRecord::Base
|
|
208
214
|
update_from_struct!( data )
|
209
215
|
end # method deep_update_from_struct!
|
210
216
|
|
217
|
+
###################################################
|
218
|
+
# helpers to fix-up some "broken" feed data
|
219
|
+
def fix_dates( data )
|
220
|
+
|
221
|
+
## check if all updated dates are the same (uniq count is 1)
|
222
|
+
## AND if all published dates are present
|
223
|
+
## than assume "fake" updated dates and nullify updated dates
|
224
|
+
## example real-world "messed-up" feeds include:
|
225
|
+
## - https://bundler.io/blog/feed.xml
|
226
|
+
## - https://dry-rb.org/feed.xml
|
227
|
+
##
|
228
|
+
## todo/check - limit to atom feed format only - why? why not?
|
229
|
+
|
230
|
+
count = data.items.size
|
231
|
+
count_published = data.items.reduce( 0 ) {|count,item| count += 1 if item.published; count }
|
232
|
+
|
233
|
+
if count == count_published
|
234
|
+
uniq_count_updated = 0
|
235
|
+
last_updated = nil
|
236
|
+
|
237
|
+
data.items.each do |item|
|
238
|
+
uniq_count_updated += 1 if item.updated != last_updated
|
239
|
+
last_updated = item.updated
|
240
|
+
end
|
241
|
+
|
242
|
+
if uniq_count_updated == 1
|
243
|
+
puts "bingo!! nullify all updated dates"
|
244
|
+
## todo/fix: log report updated date fix!!!!
|
245
|
+
data.items.each do |item|
|
246
|
+
item.updated = nil
|
247
|
+
item.updated_local = nil
|
248
|
+
end
|
249
|
+
end
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
211
253
|
|
212
254
|
def update_from_struct!( data )
|
213
255
|
logger = LogUtils::Logger.root
|
data/lib/pluto/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluto-models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|