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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e3b576a61254285708c3a75ec3723ddf5e5e99dd
4
- data.tar.gz: 34e15ef65f13fbef5457e231fa823c3bcb2a1bd2
3
+ metadata.gz: 3a0663eac6b904175fa19f44ef8e8cab03ace783
4
+ data.tar.gz: 9808033aa822c1130b10c2ad0c08022c60010c7f
5
5
  SHA512:
6
- metadata.gz: 1c57e421a46116fb8c8ad93aec9bd79ee4aca87a51dbdabde900fdbdd21b3c39272e8d9d40c21974c5714c7484706926354951c7f5d17f3bd6c1cc0d14fbdb30
7
- data.tar.gz: 2a65d0ede84bac1c1004161fc5573779d6edb0e3bf80e851fcd7292ba1d3a903de7fd0ef9a51fc3f4494a17f77528617a4e17415a09668da6cec8671ec73af9d
6
+ metadata.gz: 904c17ecd34ca841c3f82b9943f976703225ff05e60bb77e2f189a0fc4c6bc4f8582cd639b48a70fad576057016643c373ffc0174a0815695b8b512320732083
7
+ data.tar.gz: 248aff5771ae6f72fdd94c05b64ab4b209c493ae4fc24e0dc35c469520392f07377daab7fa1bb1edc08104faa031f1fcd0da114e8d00ec878718961de48b00df
@@ -41,50 +41,66 @@ class Feed < ActiveRecord::Base
41
41
  ##################################
42
42
  # attribute reader aliases
43
43
  #
44
- # todo: check if we can use alias_method :name, :title - works for non-existing/on-demand-generated method too??
45
-
46
- def name() title; end # alias for title
47
- def description() summary; end # alias for summary
48
- def desc() summary; end # alias(2) for summary
49
- def subtitle() summary; end # alias(3) for summary
50
- def link() url; end # alias for url
51
- def feed() feed_url; end # alias for feed_url
52
-
53
- def author_name() author; end # alias for author
54
- def owner_name() author; end # alias(2) for author
55
- def owner() author; end # alias(3) for author
56
- def author_email() email; end # alias for email
57
- def author_email() email; end # alias(2) for email
58
-
59
-
60
- def url?() read_attribute(:url).present?; end
61
- def title?() read_attribute(:title).present?; end
62
- def feed_url?() read_attribute(:feed_url).present?; end
63
-
64
- def url() read_attribute_w_fallbacks( :url, :auto_url ); end
65
- def title() read_attribute_w_fallbacks( :title, :auto_title ); end
66
- def feed_url() read_attribute_w_fallbacks( :feed_url, :auto_feed_url ); end
67
-
68
- def summary?() read_attribute(:summary).present?; end
69
-
70
-
71
- def updated?() read_attribute(:updated).present?; end
72
- def published?() read_attribute(:published).present?; end
73
-
74
- def updated
75
- ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing
76
- # db backed attribute
77
- read_attribute_w_fallbacks( :updated, :published )
78
- end
79
-
80
- def published
81
- ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing
82
- # db backed attribute
83
- read_attribute_w_fallbacks( :published, :updated )
84
- end
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.present?
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 # try published
166
- self.items_last_updated = last_item_rec.published
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
  ##
@@ -26,10 +26,10 @@ class Item < ActiveRecord::Base
26
26
 
27
27
  ##################################
28
28
  # attribute reader aliases
29
- def name() title; end # alias for title
30
- def description() summary; end # alias for summary -- also add descr shortcut??
31
- def desc() summary; end # alias (2) for summary -- also add descr shortcut??
32
- def link() url; end # alias for url
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
- def updated?() read_attribute(:updated).present?; end
44
- def published?() read_attribute(:published).present?; end # note: published is basically an alias for created
45
-
46
- def updated
47
- ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing
48
- # db backed attribute
49
- read_attribute_w_fallbacks( :updated, :published )
50
- end
51
-
52
- def published
53
- ## todo/fix: use a new name - do NOT squeeze convenience lookup into existing
54
- # db backed attribute
55
- read_attribute_w_fallbacks( :published, :updated )
56
- end
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
 
@@ -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
- def name() title; end # alias for title
19
+ alias_attr_reader :name, :title # alias for title
19
20
 
20
- def owner_name() author; end # alias for author
21
- def owner() author; end # alias(2) for author
22
- def author_name() author; end # alias(3) for author
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
- def owner_email() email; end # alias for email
25
- def author_email() email; end # alias(2) for email
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
 
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 5
7
- PATCH = 5
7
+ PATCH = 6
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.5.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-06 00:00:00.000000000 Z
11
+ date: 2020-02-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props