pluto-models 1.6.1 → 1.6.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
2
  SHA1:
3
- metadata.gz: '08550943793b98bc0cdbebdc2d767bbbca2ab5d1'
4
- data.tar.gz: 30d7e476d091976a60f67850087a5280ec58a2f9
3
+ metadata.gz: 929cce8604ed70070a58181f54d4dd42c0e028eb
4
+ data.tar.gz: 53e6ddd2905e2790ee0d1727d0a64566baec84f3
5
5
  SHA512:
6
- metadata.gz: 59635030a51054b62fdfe08776d389a0b1e691530e39808b66bfcc594f8fa685a5489a093de2611e25d56dded8cfdaa27987b9f5c3328179423bfb5fc516629f
7
- data.tar.gz: b0b6f369726828bfa0d42f156cd37f7c2eccb0273b19e379808453521962c64b75a545e5cfaaeebab4e77106f24b03e86d9d181bc01964857aae76a6f2b84552
6
+ metadata.gz: b42db115a5b8fb0ce87e2a42d192abb121b7c260ac5e894bb2e55d9352c7aac25707e9f2cde5e5f3e3735461d8c32b49fd4be13d6e6763742bad096ec178e72c
7
+ data.tar.gz: 61604bbc1d4c213bfda49fda83d6514bb4eee66c5b156e49206e2bd6cce5c8e0dadc3a81a4330da404366c2226e75913e3ace28527903af39b8282e935ef4c14
@@ -17,4 +17,5 @@ test/helper.rb
17
17
  test/test_delete_removed.rb
18
18
  test/test_filter.rb
19
19
  test/test_helpers.rb
20
+ test/test_regex.rb
20
21
  test/test_site.rb
@@ -214,10 +214,41 @@ class Feed < ActiveRecord::Base
214
214
  update_from_struct!( data )
215
215
  end # method deep_update_from_struct!
216
216
 
217
+
218
+ # try to get date from slug in url
219
+ # e.g. /news/2019-10-17-growing-ruby-together
220
+ FIX_DATE_SLUG_RE = %r{\b
221
+ (?<year>[0-9]{4})
222
+ -
223
+ (?<month>[0-9]{2})
224
+ -
225
+ (?<day>[0-9]{2})
226
+ \b}x
227
+
217
228
  ###################################################
218
229
  # helpers to fix-up some "broken" feed data
219
230
  def fix_dates( data )
220
231
 
232
+ ## check for missing / no dates
233
+ ## examples
234
+ ## - rubytogether feed @ https://rubytogether.org/news.xml
235
+ data.items.each do |item|
236
+ if item.updated.nil? &&
237
+ item.published.nil?
238
+ ## try to get date from slug in url
239
+ ## e.g. /news/2019-10-17-growing-ruby-together
240
+ if (m=FIX_DATE_SLUG_RE.match( item.url ))
241
+ ## todo/fix: make sure DateTime gets utc (no timezone/offset +000)
242
+ published = DateTime.new( m[:year].to_i(10),
243
+ m[:month].to_i(10),
244
+ m[:day].to_i(10) )
245
+ item.published_local = published
246
+ item.published = published
247
+ end
248
+ end
249
+ end
250
+
251
+
221
252
  ## check if all updated dates are the same (uniq count is 1)
222
253
  ## AND if all published dates are present
223
254
  ## than assume "fake" updated dates and nullify updated dates
@@ -71,7 +71,7 @@ class Item < ActiveRecord::Base
71
71
  ## e.g. use item.data.updated
72
72
  ## item.data.updated? etc.
73
73
  class Data
74
- def initialize( feed ) @item = item; end
74
+ def initialize( item ) @item = item; end
75
75
 
76
76
  def updated() @item.read_attribute(:updated); end # "regular" updated incl. published fallback
77
77
  def published() @item.read_attribute(:published); end
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 6
7
- PATCH = 1
7
+ PATCH = 2
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -0,0 +1,28 @@
1
+ ###
2
+ # to run use
3
+ # ruby -I ./lib -I ./test test/test_regex.rb
4
+
5
+
6
+ require 'helper'
7
+
8
+ class TestRegex < MiniTest::Test
9
+
10
+ FIX_DATE_SLUG_RE = Pluto::Model::Feed::FIX_DATE_SLUG_RE
11
+
12
+ def test_fix_dates
13
+ m = FIX_DATE_SLUG_RE.match( ' /news/2019-10-17-growing-ruby-together' )
14
+ assert_equal false, m.nil?
15
+ assert_equal '2019', m[:year]
16
+ assert_equal '10', m[:month]
17
+ assert_equal '17', m[:day]
18
+
19
+ ## check \b (boundray)
20
+ m = FIX_DATE_SLUG_RE.match( ' /news/002019-10-1700-growing-ruby-together' )
21
+ assert_equal true, m.nil?
22
+ m = FIX_DATE_SLUG_RE.match( ' /news/2019-10-1700-growing-ruby-together' )
23
+ assert_equal true, m.nil?
24
+ m = FIX_DATE_SLUG_RE.match( ' /news/xxx2019-10-1700-growing-ruby-together' )
25
+ assert_equal true, m.nil?
26
+ end
27
+
28
+ end # class TestRegex
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.1
4
+ version: 1.6.2
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-21 00:00:00.000000000 Z
11
+ date: 2020-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -220,6 +220,7 @@ files:
220
220
  - test/test_delete_removed.rb
221
221
  - test/test_filter.rb
222
222
  - test/test_helpers.rb
223
+ - test/test_regex.rb
223
224
  - test/test_site.rb
224
225
  homepage: https://github.com/feedreader/pluto
225
226
  licenses: