pluto-models 1.6.0 → 1.6.1

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: 9ad742c8fd3f916716ace3acb90d1c1a7371b77e
4
- data.tar.gz: fc7a5f6e1b85585b9efb2c34848b04274f80f528
3
+ metadata.gz: '08550943793b98bc0cdbebdc2d767bbbca2ab5d1'
4
+ data.tar.gz: 30d7e476d091976a60f67850087a5280ec58a2f9
5
5
  SHA512:
6
- metadata.gz: 17db570f9d9987f8aa6fdc5addeca4eebad1d4a9aeef59b244a2dd8c7e7c25f3bf13018290b300583ea50c08d069ea591894de8367ad441e3907a0c679cdf233
7
- data.tar.gz: 870555443a637ee053c2eeb164998f35f8007cce25930c948bae3615f9d7948fcd6712a9b0a12459f369b97ba45a8ef2f1e93bc155586aa323586d78a949a8a3
6
+ metadata.gz: 59635030a51054b62fdfe08776d389a0b1e691530e39808b66bfcc594f8fa685a5489a093de2611e25d56dded8cfdaa27987b9f5c3328179423bfb5fc516629f
7
+ data.tar.gz: b0b6f369726828bfa0d42f156cd37f7c2eccb0273b19e379808453521962c64b75a545e5cfaaeebab4e77106f24b03e86d9d181bc01964857aae76a6f2b84552
@@ -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
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 6
7
- PATCH = 0
7
+ PATCH = 1
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
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.0
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-16 00:00:00.000000000 Z
11
+ date: 2020-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props