pluto-news 1.0.1 → 1.1.0

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: 3ea3e56d2fafd5f9632ec43d764a67dbd79c3f31
4
- data.tar.gz: f3d699d67b12b51f997c96b62656698cc0372d7b
3
+ metadata.gz: 7908922c343e9a80b979528c5561f2b946b77a74
4
+ data.tar.gz: 1c6753f57ad5d2f47ac9b1f9d2dc774619a5fe0d
5
5
  SHA512:
6
- metadata.gz: 1efd5f84d0b143b52b5009b7309ab83a594d5f43bf035fec5ab3a530c2f86c6853f6a19cc84048be060fb1ee7ac4653309ad9268ed188b64eceb0b8a552584f7
7
- data.tar.gz: 9c673852ef696eb8eaee63a366797d28c6e2b0e976a9d2dcd723c45cc996d97a13d3cb10ba7f34c12d39189a28484f83e5ee6a44881c81d6ab6b98316e78c697
6
+ metadata.gz: 2278051b4c6b0729a83d2697012b61fe214f8cfecbcaffc24ca365ad6e8dba4db3a4c8cae9b22feadf23cd4b9a80115893b2d0e2f10f72b42628f39d5c927e1e
7
+ data.tar.gz: 232c79b23e21ce139bfc107495e65f2bcb960c1f926c98f8d40197ddf1885f5d8add3bea79d9afcb4939817a8de7383bb13d08e7dc9f771d1f981a0f00ffa9e3
@@ -54,13 +54,18 @@ require 'pluto/news/version'
54
54
 
55
55
  module News
56
56
 
57
+ def self.site=(value) @site = value; end
58
+ def self.site() @site ||= 'news'; end ## note: defaults to news
59
+
60
+
61
+
57
62
  def self.subscribe( *feeds )
58
63
  site_hash = { ## note: keys are strings (NOT symbols) for now
59
- 'title' => 'News, News, News'
64
+ 'title' => 'Untitled'
60
65
  }
61
66
 
62
67
  feeds.each_with_index do |feed|
63
- ## note:
68
+ ## note:
64
69
  ## use a "fingerprint" hash digest as key
65
70
  ## do NOT include scheme (e.g. https or http)
66
71
  ## do NOT include port
@@ -74,14 +79,14 @@ module News
74
79
  ## note: cut-off www. if leading e.g. www.ruby-lang.org => ruby-lang.org
75
80
  host = uri.host.downcase.sub( /^www\./, '' )
76
81
  # use a differt separator e.g _ or ~ and NOT $ - why? why not?
77
- key = "#{host}$#{Digest::MD5.hexdigest( uri.request_uri )}"
82
+ key = "#{host}$#{Digest::MD5.hexdigest( uri.request_uri )}"
78
83
 
79
84
  site_hash[ key ] = { 'feed' => feed }
80
85
  end
81
86
 
82
87
  connection ## make sure we have a database connection (and setup) up-and-running
83
- site_key = 'news' ## note: use always news (and single-site setup) for now
84
- Pluto::Model::Site.deep_create_or_update_from_hash!( site_key, site_hash )
88
+ ## note: always use "multi-site" setup; defaults to 'news' site key
89
+ Pluto::Model::Site.deep_create_or_update_from_hash!( site, site_hash )
85
90
  end
86
91
 
87
92
  def self.update
@@ -94,20 +99,32 @@ module News
94
99
 
95
100
  def self.feeds
96
101
  connection
102
+ ## note: always use "multi-site" setup; defaults to 'news' site key
97
103
  ## note: add "default" scope - orders (sorts) by latest / time
98
- Pluto::Model::Feed.order(
104
+ rec = Pluto::Model::Site.where(key: site).first
105
+ if rec.nil?
106
+ Pluto::Model::Feed.none ## use null (relation) pattern to avoid crash on nil - why? why not?
107
+ else
108
+ rec.feeds.order(
99
109
  Arel.sql( "coalesce(feeds.updated,feeds.published,'1970-01-01') desc" )
100
110
  )
111
+ end
101
112
  end
102
113
  def self.channels() feeds; end ## convenience alias for feeds
103
114
 
104
115
 
105
116
  def self.items
106
117
  connection ## make sure we have a database connection (and setup) up-and-running
118
+ ## note: always use "multi-site" setup; defaults to 'news' site key
107
119
  ## note: add "default" scope - orders (sorts) by latest / time
108
- Pluto::Model::Item.order(
120
+ rec = Pluto::Model::Site.where(key: site).first
121
+ if rec.nil?
122
+ Pluto::Model::Item.none ## use null (relation) pattern to avoid crash on nil - why? why not?
123
+ else
124
+ rec.items.order(
109
125
  Arel.sql( "coalesce(items.updated,items.published,'1970-01-01') desc" )
110
126
  )
127
+ end
111
128
  end
112
129
  def self.latest() items; end ## note: "default" scope orders (sorts) by latest / time
113
130
 
@@ -174,7 +191,7 @@ module News
174
191
  def self.q3( year=Date.today.year ) quarter3( year ); end
175
192
  def self.q4( year=Date.today.year ) quarter4( year ); end
176
193
 
177
-
194
+
178
195
  def self.year( year=Date.today.year )
179
196
  q = year
180
197
  items.
@@ -183,9 +200,9 @@ module News
183
200
  )
184
201
  end
185
202
 
186
-
187
-
188
-
203
+
204
+
205
+
189
206
  def self.this_week() week; end ## convenience alias - keep - why? why not?
190
207
  def self.this_month() month; end
191
208
  def self.this_quarter() quarter; end
@@ -2,8 +2,8 @@
2
2
  module PlutoNews
3
3
 
4
4
  MAJOR = 1
5
- MINOR = 0
6
- PATCH = 1
5
+ MINOR = 1
6
+ PATCH = 0
7
7
  VERSION = [MAJOR,MINOR,PATCH].join('.')
8
8
 
9
9
  def self.version
@@ -20,4 +20,3 @@ module PlutoNews
20
20
  end
21
21
 
22
22
  end # module PlutoNews
23
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto-news
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
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-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pluto-models