pluto-models 1.5.5 → 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pluto/models/feed.rb +64 -50
- data/lib/pluto/models/item.rb +25 -20
- data/lib/pluto/models/site.rb +7 -6
- 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: 3a0663eac6b904175fa19f44ef8e8cab03ace783
|
4
|
+
data.tar.gz: 9808033aa822c1130b10c2ad0c08022c60010c7f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 904c17ecd34ca841c3f82b9943f976703225ff05e60bb77e2f189a0fc4c6bc4f8582cd639b48a70fad576057016643c373ffc0174a0815695b8b512320732083
|
7
|
+
data.tar.gz: 248aff5771ae6f72fdd94c05b64ab4b209c493ae4fc24e0dc35c469520392f07377daab7fa1bb1edc08104faa031f1fcd0da114e8d00ec878718961de48b00df
|
data/lib/pluto/models/feed.rb
CHANGED
@@ -41,50 +41,66 @@ class Feed < ActiveRecord::Base
|
|
41
41
|
##################################
|
42
42
|
# attribute reader aliases
|
43
43
|
#
|
44
|
-
#
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
def
|
67
|
-
|
68
|
-
def
|
69
|
-
|
70
|
-
|
71
|
-
def
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
44
|
+
# note: CANNOT use alias_method :name, :title
|
45
|
+
# will NOT work for non-existing/on-demand-generated methods in activerecord
|
46
|
+
#
|
47
|
+
# use rails alias_attribute :new, :old (incl. reader/predicate/writer)
|
48
|
+
# or use alias_attr, alias_attr_reader, alias_attr_writer from activerecord/utils
|
49
|
+
|
50
|
+
alias_attr_reader :name, :title # alias for title
|
51
|
+
alias_attr_reader :description, :summary # alias for summary
|
52
|
+
alias_attr_reader :desc, :summary # alias(2) for summary
|
53
|
+
alias_attr_reader :subtitle, :summary # alias(3) for summary
|
54
|
+
alias_attr_reader :link, :url # alias for url
|
55
|
+
alias_attr_reader :feed, :feed_url # alias for feed_url
|
56
|
+
|
57
|
+
alias_attr_reader :author_name, :author # alias for author
|
58
|
+
alias_attr_reader :owner_name, :author # alias(2) for author
|
59
|
+
alias_attr_reader :owner, :author # alias(3) for author
|
60
|
+
alias_attr_reader :author_email, :email # alias for email
|
61
|
+
alias_attr_reader :author_email, :email # alias(2) for email
|
62
|
+
|
63
|
+
|
64
|
+
#################
|
65
|
+
## attributes with fallbacks or (auto-)backups - use feed.data.<attribute> for "raw" / "original" access
|
66
|
+
def url() read_attribute_w_fallbacks( :url, :auto_url ); end
|
67
|
+
def title() read_attribute_w_fallbacks( :title, :auto_title ); end
|
68
|
+
def feed_url() read_attribute_w_fallbacks( :feed_url, :auto_feed_url ); end
|
69
|
+
|
70
|
+
def url?() url.present?; end
|
71
|
+
def title?() title.present?; end
|
72
|
+
def feed_url?() feed_url.present?; end
|
73
|
+
|
74
|
+
## note:
|
75
|
+
## only use fallback for updated, that is, updated (or published)
|
76
|
+
## do NOT use fallback for published / created -- why? why not?
|
77
|
+
## add items_last_updated to updated as last fall back - why? why not?
|
78
|
+
def updated() read_attribute_w_fallbacks( :updated, :published ); end
|
79
|
+
def updated?() updated.present?; end
|
80
|
+
|
81
|
+
## "raw" access via data "proxy" helper
|
82
|
+
## e.g. use feed.data.updated
|
83
|
+
## feed.data.updated? etc.
|
84
|
+
class Data
|
85
|
+
def initialize( feed ) @feed = feed; end
|
86
|
+
|
87
|
+
def url() @feed.read_attribute( :url ); end # "regular" url incl. auto_url fallback / (auto-)backup
|
88
|
+
def title() @feed.read_attribute( :title ); end
|
89
|
+
def feed_url() @feed.read_attribute( :feed_url ); end
|
90
|
+
def url?() url.present?; end
|
91
|
+
def title?() title.present?; end
|
92
|
+
def feed_url?() feed_url.present?; end
|
93
|
+
|
94
|
+
def updated() @feed.read_attribute(:updated); end # "regular" updated incl. published fallback
|
95
|
+
def published() @feed.read_attribute(:published); end
|
96
|
+
def updated?() updated.present?; end
|
97
|
+
def published?() published.present?; end
|
98
|
+
end # class Data
|
99
|
+
## use a different name for data - why? why not?
|
100
|
+
## e.g. inner, internal, readonly or r, raw, table, direct, or ???
|
101
|
+
def data() @data ||= Data.new( self ); end
|
102
|
+
|
103
|
+
|
88
104
|
def deep_update_from_struct!( data )
|
89
105
|
|
90
106
|
logger = LogUtils::Logger.root
|
@@ -158,13 +174,12 @@ class Feed < ActiveRecord::Base
|
|
158
174
|
# update cached value last published for item
|
159
175
|
## todo/check: force reload of items - why? why not??
|
160
176
|
last_item_rec = items.latest.limit(1).first # note limit(1) will return relation/arrar - use first to get first element or nil from ary
|
161
|
-
if last_item_rec
|
162
|
-
if last_item_rec.updated?
|
177
|
+
if last_item_rec
|
178
|
+
if last_item_rec.updated? ## note: checks for updated & published with attr_reader_w_fallback
|
163
179
|
self.items_last_updated = last_item_rec.updated
|
164
180
|
## save! ## note: will get save w/ update_from_struct! - why? why not??
|
165
|
-
else
|
166
|
-
|
167
|
-
## save! ## note: will get save w/ update_from_struct! - why? why not??
|
181
|
+
else
|
182
|
+
## skip - no updated / published present
|
168
183
|
end
|
169
184
|
end
|
170
185
|
end # check for if data.items.size > 0 (that is, feed has feed items/entries)
|
@@ -174,7 +189,6 @@ class Feed < ActiveRecord::Base
|
|
174
189
|
|
175
190
|
|
176
191
|
def update_from_struct!( data )
|
177
|
-
|
178
192
|
logger = LogUtils::Logger.root
|
179
193
|
|
180
194
|
##
|
data/lib/pluto/models/item.rb
CHANGED
@@ -26,10 +26,10 @@ class Item < ActiveRecord::Base
|
|
26
26
|
|
27
27
|
##################################
|
28
28
|
# attribute reader aliases
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
alias_attr_reader :name, :title # alias for title
|
30
|
+
alias_attr_reader :description, :summary # alias for summary -- also add descr shortcut??
|
31
|
+
alias_attr_reader :desc, :summary # alias (2) for summary -- also add descr shortcut??
|
32
|
+
alias_attr_reader :link, :url # alias for url
|
33
33
|
|
34
34
|
|
35
35
|
def self.latest
|
@@ -40,22 +40,27 @@ class Item < ActiveRecord::Base
|
|
40
40
|
order( Arel.sql( "coalesce(items.updated,items.published,'1970-01-01') desc" ) )
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def updated
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
43
|
+
## note:
|
44
|
+
## only use fallback for updated, that is, updated (or published)
|
45
|
+
## do NOT use fallback for published / created -- why? why not?
|
46
|
+
def updated() read_attribute_w_fallbacks( :updated, :published ); end
|
47
|
+
def updated?() updated.present?; end
|
48
|
+
|
49
|
+
## "raw" access via data "proxy" helper
|
50
|
+
## e.g. use item.data.updated
|
51
|
+
## item.data.updated? etc.
|
52
|
+
class Data
|
53
|
+
def initialize( feed ) @item = item; end
|
54
|
+
|
55
|
+
def updated() @item.read_attribute(:updated); end # "regular" updated incl. published fallback
|
56
|
+
def published() @item.read_attribute(:published); end
|
57
|
+
def updated?() updated.present?; end
|
58
|
+
def published?() published.present?; end
|
59
|
+
end # class Data
|
60
|
+
## use a different name for data - why? why not?
|
61
|
+
## e.g. inner, internal, readonly or r, raw, table, direct, or ???
|
62
|
+
def data() @data ||= Data.new( self ); end
|
63
|
+
|
59
64
|
|
60
65
|
def update_from_struct!( data )
|
61
66
|
|
data/lib/pluto/models/site.rb
CHANGED
@@ -13,16 +13,17 @@ class Site < ActiveRecord::Base
|
|
13
13
|
has_many :feeds, :through => :subscriptions
|
14
14
|
has_many :items, :through => :feeds
|
15
15
|
|
16
|
+
|
16
17
|
##################################
|
17
18
|
# attribute reader aliases
|
18
|
-
|
19
|
+
alias_attr_reader :name, :title # alias for title
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
alias_attr_reader :owner_name, :author # alias for author
|
22
|
+
alias_attr_reader :owner, :author # alias(2) for author
|
23
|
+
alias_attr_reader :author_name, :author # alias(3) for author
|
23
24
|
|
24
|
-
|
25
|
-
|
25
|
+
alias_attr_reader :owner_email, :email # alias for email
|
26
|
+
alias_attr_reader :author_email, :email # alias(2) for email
|
26
27
|
|
27
28
|
|
28
29
|
|
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.5.
|
4
|
+
version: 1.5.6
|
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-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: props
|