pluto-models 1.5.3 → 1.5.4

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: 92f609c55f1c97dce198ee7f9a8513d1937efc92
4
- data.tar.gz: b688795ca55c96259a5ef2494fb3fe24fd63fb65
3
+ metadata.gz: 51ec18ad86fd2cc4cafda7e80bc4d9e8d038d650
4
+ data.tar.gz: 27883c52dd7e3d08b2380c0085d162e48112e7ef
5
5
  SHA512:
6
- metadata.gz: e603bb5436e331469dc36edea780f52e831ccce781e43f79bcaf7c83fdb57f1599271a889b6b670b18ddc0542d2e69901c2f7f5526c11ba1b062f525d1096b5f
7
- data.tar.gz: 62499df65996003274e377b6a9c9c5c8e2f398c1dbac7601b9daf4d3201295f89c13d4b8ce9f0641d8123e292444801d2d6a56bce45e25c8d0e7db66200ae997
6
+ metadata.gz: ba8e07e5e685a6d605625e399e210f017af5274724a518f12f9ab71cfb28f08cf9daf5fbd1537aad47f10792a84b4e0825bbb91bf6244683835d9dc275d1002b
7
+ data.tar.gz: 02ce3fde608247434c54114044c5368269b5f941a463d0f5f383041da61a8c49b181a182c6ffaaa74e1b95e38a6d18b505a4124a6144c328a4bd916555632394
@@ -2,6 +2,7 @@ CHANGELOG.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ lib/pluto/config.rb
5
6
  lib/pluto/connecter.rb
6
7
  lib/pluto/models.rb
7
8
  lib/pluto/models/feed.rb
@@ -12,7 +13,6 @@ lib/pluto/models/subscription.rb
12
13
  lib/pluto/models/utils.rb
13
14
  lib/pluto/schema.rb
14
15
  lib/pluto/version.rb
15
- test/data/ruby.ini
16
16
  test/helper.rb
17
17
  test/test_delete_removed.rb
18
18
  test/test_filter.rb
@@ -0,0 +1,32 @@
1
+
2
+
3
+ module Pluto
4
+ class Configuration
5
+
6
+ def debug=(value) @debug = value; end
7
+ def debug?() @debug || false; end
8
+
9
+ def logger
10
+ ## always return root for now; let's you globally configure e.g.
11
+ ## logger.level = :debug etc.
12
+ LogUtils::Logger.root
13
+ end
14
+ end # class Configuration
15
+
16
+
17
+
18
+ ## lets you use
19
+ ## Pluto.configure do |config|
20
+ ## config.debug = true
21
+ ## config.logger.level = :debug
22
+ ## end
23
+
24
+ def self.configure
25
+ yield( config )
26
+ end
27
+
28
+ def self.config
29
+ @config ||= Configuration.new
30
+ end
31
+
32
+ end # module Pluto
@@ -9,14 +9,15 @@ module Pluto
9
9
  class Connecter
10
10
 
11
11
  include LogUtils::Logging
12
+
13
+
12
14
 
13
15
  def initialize
14
16
  # do nothing for now
15
17
  end
16
18
 
19
+ def debug?() Pluto.config.debug?; end
17
20
 
18
- def debug=(value) @debug = value; end
19
- def debug?() @debug || false; end
20
21
 
21
22
 
22
23
  def connect( config={} )
@@ -34,6 +34,7 @@ require 'logutils/activerecord'
34
34
  # our own code
35
35
 
36
36
  require 'pluto/version' # note: let version always get first
37
+ require 'pluto/config'
37
38
  require 'pluto/schema'
38
39
 
39
40
  require 'pluto/models/forward'
@@ -106,9 +107,21 @@ module Pluto
106
107
  end # setup_in_memory_dd
107
108
 
108
109
 
110
+ #########################################
111
+ ## let's put test configuration in its own namespace / module
112
+ class Test ## todo/check: works with module too? use a module - why? why not?
113
+
114
+ ####
115
+ # todo/fix: find a better way to configure shared test datasets - why? why not?
116
+ # note: use one-up (..) directory for now as default - why? why not?
117
+ def self.data_dir() @data_dir ||= '../test'; end
118
+ def self.data_dir=( path ) @data_dir = path; end
119
+ end # class Test
120
+
109
121
  end # module Pluto
110
122
 
111
123
 
112
124
 
125
+
113
126
  # say hello
114
127
  puts Pluto.banner if $DEBUG || (defined?($RUBYLIBS_DEBUG) && $RUBYLIBS_DEBUG)
@@ -12,8 +12,8 @@ class Feed < ActiveRecord::Base
12
12
  ## only class method present?
13
13
  ## what's the best way to add logging to activerecord (use "builtin" machinery??)
14
14
 
15
- def debug=(value) @debug = value; end
16
- def debug?() @debug || false; end
15
+
16
+ def debug?() Pluto.config.debug?; end
17
17
 
18
18
 
19
19
 
@@ -33,9 +33,9 @@ class Feed < ActiveRecord::Base
33
33
  # note: order by first non-null datetime field
34
34
  # coalesce - supported by sqlite (yes), postgres (yes)
35
35
 
36
- # note: if not updated or published use hardcoded 1971-01-01 for now
37
- ## order( "coalesce(updated,published,'1971-01-01') desc" )
38
- order( Arel.sql( "coalesce(feeds.items_last_updated,'1971-01-01') desc" ) )
36
+ # note: if not updated or published use hardcoded 1970-01-01 for now
37
+ ## was: order( "coalesce(updated,published,'1970-01-01') desc" )
38
+ order( Arel.sql( "coalesce(feeds.items_last_updated,'1970-01-01') desc" ) )
39
39
  end
40
40
 
41
41
  ##################################
@@ -119,8 +119,6 @@ class Feed < ActiveRecord::Base
119
119
  logger.info "UPDATE | #{item.title}"
120
120
  end
121
121
 
122
- item_rec.debug = debug? ? true : false # pass along debug flag
123
-
124
122
  item_rec.feed_id = id # feed_rec.id - add feed_id fk_ref
125
123
  item_rec.fetched = fetched # feed_rec.fetched
126
124
 
@@ -10,8 +10,8 @@ class Item < ActiveRecord::Base
10
10
  ## only class method present?
11
11
  ## what's the best way to add logging to activerecord (use "builtin" machinery??)
12
12
 
13
- def debug=(value) @debug = value; end
14
- def debug?() @debug || false; end
13
+
14
+ def debug?() Pluto.config.debug?; end
15
15
 
16
16
 
17
17
  self.table_name = 'items'
@@ -36,8 +36,8 @@ class Item < ActiveRecord::Base
36
36
  # note: order by first non-null datetime field
37
37
  # coalesce - supported by sqlite (yes), postgres (yes)
38
38
 
39
- # note: if not updated,published use hardcoded 1971-01-01 for now
40
- order( Arel.sql( "coalesce(items.updated,items.published,'1971-01-01') desc" ) )
39
+ # note: if not updated,published use hardcoded 1970-01-01 for now
40
+ order( Arel.sql( "coalesce(items.updated,items.published,'1970-01-01') desc" ) )
41
41
  end
42
42
 
43
43
  def updated?() read_attribute(:updated).present?; end
@@ -10,7 +10,7 @@ class ItemCursor
10
10
  end
11
11
 
12
12
  def each
13
- last_updated = Time.local( 1971, 1, 1 )
13
+ last_updated = Time.local( 1970, 1, 1 )
14
14
  last_feed_id = -1 ## todo: use feed_key instead of id?? why? why not??
15
15
 
16
16
  @items.each do |item|
@@ -4,7 +4,7 @@ module Pluto
4
4
 
5
5
  MAJOR = 1
6
6
  MINOR = 5
7
- PATCH = 3
7
+ PATCH = 4
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -1,18 +1,15 @@
1
- ## $:.unshift(File.dirname(__FILE__))
2
-
3
-
4
1
  ## minitest setup
5
-
6
2
  require 'minitest/autorun'
7
3
 
8
4
  ## our own code
9
5
  require 'pluto/models'
10
6
 
11
7
 
12
- LogUtils::Logger.root.level = :debug
8
+ Pluto.config.debug = true
9
+ Pluto.config.logger.level = :debug
13
10
 
14
11
 
15
- ## some shortcuts
12
+ ## add some (ActiveRecord model class) shortcuts
16
13
  Log = LogDb::Model::Log
17
14
  Prop = ConfDb::Model::Prop
18
15
 
@@ -1,10 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  ###
4
2
  # to run use
5
3
  # ruby -I ./lib -I ./test test/test_delete_removed.rb
6
- # or better
7
- # rake test
4
+
8
5
 
9
6
  require 'helper'
10
7
 
@@ -1,10 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  ###
4
2
  # to run use
5
3
  # ruby -I ./lib -I ./test test/test_filter.rb
6
- # or better
7
- # rake test
4
+
8
5
 
9
6
  require 'helper'
10
7
 
@@ -1,10 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  ###
4
2
  # to run use
5
3
  # ruby -I ./lib -I ./test test/test_helpers.rb
6
- # or better
7
- # rake test
4
+
8
5
 
9
6
  require 'helper'
10
7
 
@@ -1,10 +1,7 @@
1
- # encoding: utf-8
2
-
3
1
  ###
4
2
  # to run use
5
3
  # ruby -I ./lib -I ./test test/test_site.rb
6
- # or better
7
- # rake test
4
+
8
5
 
9
6
  require 'helper'
10
7
 
@@ -20,7 +17,7 @@ class TestSite < MiniTest::Test
20
17
 
21
18
 
22
19
  def test_site_create
23
- site_text = File.read( "#{Pluto.root}/test/data/ruby.ini")
20
+ site_text = File.read( "#{Pluto::Test.data_dir}/ruby.ini")
24
21
  site_config = INI.load( site_text )
25
22
  ## pp site_config
26
23
 
@@ -45,7 +42,7 @@ class TestSite < MiniTest::Test
45
42
 
46
43
 
47
44
  def test_site_update
48
- site_text = File.read( "#{Pluto.root}/test/data/ruby.ini")
45
+ site_text = File.read( "#{Pluto::Test.data_dir}/ruby.ini")
49
46
  site_config = INI.load( site_text )
50
47
  ## pp site_config
51
48
 
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.3
4
+ version: 1.5.4
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-01-30 00:00:00.000000000 Z
11
+ date: 2020-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: props
@@ -191,6 +191,7 @@ files:
191
191
  - Manifest.txt
192
192
  - README.md
193
193
  - Rakefile
194
+ - lib/pluto/config.rb
194
195
  - lib/pluto/connecter.rb
195
196
  - lib/pluto/models.rb
196
197
  - lib/pluto/models/feed.rb
@@ -201,7 +202,6 @@ files:
201
202
  - lib/pluto/models/utils.rb
202
203
  - lib/pluto/schema.rb
203
204
  - lib/pluto/version.rb
204
- - test/data/ruby.ini
205
205
  - test/helper.rb
206
206
  - test/test_delete_removed.rb
207
207
  - test/test_filter.rb
@@ -1,13 +0,0 @@
1
- title = Planet Ruby
2
- source = https://github.com/feedreader/pluto/raw/master/pluto-models/test/data/ruby.ini
3
-
4
- [rubylang]
5
- title = Ruby Lang News
6
- link = http://www.ruby-lang.org/en/news
7
- feed = http://www.ruby-lang.org/en/feeds/news.rss
8
-
9
- [rubyonrails]
10
- title = Ruby on Rails News
11
- link = http://weblog.rubyonrails.org
12
- feed = http://weblog.rubyonrails.org/feed/atom.xml
13
-