pluto-models 1.1.0 → 1.2.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 +4 -4
- data/Manifest.txt +1 -14
- data/README.md +3 -55
- data/lib/pluto/connecter.rb +5 -14
- data/lib/pluto/models.rb +54 -31
- data/lib/pluto/models/feed.rb +5 -2
- data/lib/pluto/models/forward.rb +20 -0
- data/lib/pluto/models/item.rb +4 -2
- data/lib/pluto/models/site.rb +4 -2
- data/lib/pluto/models/subscription.rb +4 -2
- data/lib/pluto/models/utils.rb +4 -2
- data/lib/pluto/schema.rb +1 -0
- data/lib/pluto/version.rb +1 -1
- data/test/helper.rb +13 -0
- data/test/test_helpers.rb +18 -3
- metadata +3 -16
- data/config/pluto.index.yml +0 -23
- data/lib/pluto/fetcher.rb +0 -292
- data/lib/pluto/formatter.rb +0 -81
- data/lib/pluto/installer.rb +0 -58
- data/lib/pluto/lister.rb +0 -42
- data/lib/pluto/manifest_helpers.rb +0 -51
- data/lib/pluto/models/activity.rb +0 -8
- data/lib/pluto/refresher.rb +0 -130
- data/lib/pluto/subscriber.rb +0 -102
- data/lib/pluto/tasks/env.rake +0 -25
- data/lib/pluto/tasks/setup.rake +0 -40
- data/lib/pluto/tasks/stats.rake +0 -10
- data/lib/pluto/tasks/update.rake +0 -24
- data/lib/pluto/updater.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9b3813114643297e875af83b6de083bb21105e9
|
4
|
+
data.tar.gz: 91c8b11ba6a9355c094a4925c58746fac6767e9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a4c186d390099072cf075e5ebce91f54b85b366888bc34418d392cdc7bb73aa9cb2cbbb5b5b6cf6b9efdfee17f628f19c41514e1973a22997e7cf008ebbc1c5
|
7
|
+
data.tar.gz: 37f8499fcd0e15309de9e590726d8db86c01ade4b805719c02be4199f48172dcb19a25ecc3140262d647490c2b655a6c0480b5ec101695822951d55b2642f7ed
|
data/Manifest.txt
CHANGED
@@ -2,29 +2,16 @@ HISTORY.md
|
|
2
2
|
Manifest.txt
|
3
3
|
README.md
|
4
4
|
Rakefile
|
5
|
-
config/pluto.index.yml
|
6
5
|
lib/pluto/activerecord.rb
|
7
6
|
lib/pluto/connecter.rb
|
8
|
-
lib/pluto/fetcher.rb
|
9
|
-
lib/pluto/formatter.rb
|
10
|
-
lib/pluto/installer.rb
|
11
|
-
lib/pluto/lister.rb
|
12
|
-
lib/pluto/manifest_helpers.rb
|
13
7
|
lib/pluto/models.rb
|
14
|
-
lib/pluto/models/activity.rb
|
15
8
|
lib/pluto/models/feed.rb
|
9
|
+
lib/pluto/models/forward.rb
|
16
10
|
lib/pluto/models/item.rb
|
17
11
|
lib/pluto/models/site.rb
|
18
12
|
lib/pluto/models/subscription.rb
|
19
13
|
lib/pluto/models/utils.rb
|
20
|
-
lib/pluto/refresher.rb
|
21
14
|
lib/pluto/schema.rb
|
22
|
-
lib/pluto/subscriber.rb
|
23
|
-
lib/pluto/tasks/env.rake
|
24
|
-
lib/pluto/tasks/setup.rake
|
25
|
-
lib/pluto/tasks/stats.rake
|
26
|
-
lib/pluto/tasks/update.rake
|
27
|
-
lib/pluto/updater.rb
|
28
15
|
lib/pluto/version.rb
|
29
16
|
test/helper.rb
|
30
17
|
test/test_helpers.rb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# pluto-models gem - planet
|
1
|
+
# pluto-models gem - planet schema 'n' models for easy (re)use
|
2
2
|
|
3
3
|
* home :: [github.com/feedreader/pluto-models](https://github.com/feedreader/pluto-models)
|
4
4
|
* bugs :: [github.com/feedreader/pluto-models/issues](https://github.com/feedreader/pluto-models/issues)
|
@@ -10,64 +10,12 @@
|
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
13
|
-
### Planet Configuration Sample
|
14
|
-
|
15
|
-
`ruby.ini`:
|
16
|
-
|
17
|
-
```
|
18
|
-
title = Planet Ruby
|
19
|
-
|
20
|
-
[rubyflow]
|
21
|
-
title = Ruby Flow
|
22
|
-
link = http://rubyflow.com
|
23
|
-
feed = http://feeds.feedburner.com/Rubyflow?format=xml
|
24
|
-
|
25
|
-
[rubyonrails]
|
26
|
-
title = Ruby on Rails Blog
|
27
|
-
link = http://weblog.rubyonrails.org
|
28
|
-
feed = http://weblog.rubyonrails.org/feed/atom.xml
|
29
|
-
|
30
|
-
[viennarb]
|
31
|
-
title = vienna.rb Blog
|
32
|
-
link = http://vienna-rb.at
|
33
|
-
feed = http://vienna-rb.at/atom.xml
|
34
|
-
```
|
35
|
-
|
36
|
-
or `ruby.yml`:
|
37
|
-
|
38
|
-
```
|
39
|
-
title: Planet Ruby
|
40
|
-
|
41
|
-
|
42
|
-
rubyflow:
|
43
|
-
title: Ruby Flow
|
44
|
-
link: http://rubyflow.com
|
45
|
-
feed: http://feeds.feedburner.com/Rubyflow?format=xml
|
46
|
-
|
47
|
-
rubyonrails:
|
48
|
-
title: Ruby on Rails Blog
|
49
|
-
link: http://weblog.rubyonrails.org
|
50
|
-
feed: http://weblog.rubyonrails.org/feed/atom.xml
|
51
|
-
|
52
|
-
viennarb:
|
53
|
-
title: vienna.rb Blog
|
54
|
-
link: http://vienna-rb.at
|
55
|
-
feed: http://vienna-rb.at/atom.xml
|
56
|
-
```
|
57
|
-
|
58
|
-
For more samples, see [`nytimes.ini`](https://github.com/feedreader/pluto.samples/blob/master/nytimes.ini),
|
59
|
-
[`js.ini`](https://github.com/feedreader/pluto.samples/blob/master/js.ini),
|
60
|
-
[`dart.ini`](https://github.com/feedreader/pluto.samples/blob/master/dart.ini),
|
61
|
-
[`haskell.ini`](https://github.com/feedreader/pluto.samples/blob/master/haskell.ini),
|
62
|
-
[`viennarb.ini`](https://github.com/feedreader/pluto.samples/blob/master/viennarb.ini),
|
63
|
-
[`beer.ini`](https://github.com/feedreader/pluto.samples/blob/master/beer.ini),
|
64
|
-
[`football.ini`](https://github.com/feedreader/pluto.samples/blob/master/football.ini).
|
65
13
|
|
66
14
|
|
67
15
|
## Real World Usage
|
68
16
|
|
69
|
-
[`pluto`](https://github.com/feedreader/pluto) - planet generator command line tool using the pluto-models gem
|
70
|
-
[`pluto.live`](https://github.com/feedreader/pluto.live) - sample planet site; sinatra web app/starter template in ruby using the pluto-models gem
|
17
|
+
- [`pluto`](https://github.com/feedreader/pluto) - planet generator command line tool using the pluto-models gem
|
18
|
+
- [`pluto.live`](https://github.com/feedreader/pluto.live) - sample planet site; sinatra web app/starter template in ruby using the pluto-models gem
|
71
19
|
|
72
20
|
|
73
21
|
|
data/lib/pluto/connecter.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pluto
|
2
4
|
|
3
5
|
|
@@ -21,10 +23,9 @@ class Connecter
|
|
21
23
|
@debug || false
|
22
24
|
end
|
23
25
|
|
26
|
+
def connect( config={} )
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
if config.nil? # use/try DATABASE_URL from environment
|
28
|
+
if config.empty? # use/try DATABASE_URL from environment
|
28
29
|
|
29
30
|
logger.debug "ENV['DATBASE_URL'] - >#{ENV['DATABASE_URL']}<"
|
30
31
|
|
@@ -77,18 +78,8 @@ class Connecter
|
|
77
78
|
ActiveRecord::Base.logger = Logger.new( STDOUT )
|
78
79
|
end
|
79
80
|
|
80
|
-
|
81
81
|
ActiveRecord::Base.establish_connection( config )
|
82
|
-
|
83
|
-
# first time? - auto-run db migratation, that is, create db tables
|
84
|
-
unless ActivityDb::Models::Activity.table_exists?
|
85
|
-
ActivityDb::CreateDb.new.up
|
86
|
-
end
|
87
|
-
|
88
|
-
unless Models::Feed.table_exists?
|
89
|
-
CreateDb.new.up
|
90
|
-
end
|
91
|
-
end # method connect!
|
82
|
+
end # method connect
|
92
83
|
|
93
84
|
|
94
85
|
end # class Connecter
|
data/lib/pluto/models.rb
CHANGED
@@ -7,24 +7,24 @@ require 'json'
|
|
7
7
|
require 'uri'
|
8
8
|
require 'pp'
|
9
9
|
require 'fileutils'
|
10
|
-
require 'logger'
|
11
10
|
require 'date'
|
12
11
|
require 'digest/md5'
|
13
12
|
|
13
|
+
require 'logger' # Note: use for ActiveRecord::Base.logger = Logger.new( STDOUT ) for now
|
14
|
+
|
14
15
|
|
15
16
|
# 3rd party ruby gems/libs
|
16
17
|
|
17
|
-
require 'active_record'
|
18
|
+
require 'active_record'
|
18
19
|
|
19
20
|
require 'logutils'
|
20
21
|
require 'props' # manage settings/env
|
21
22
|
require 'fetcher' # fetch (download) files
|
22
|
-
require 'pakman' # template pack manager
|
23
23
|
require 'feedutils'
|
24
24
|
require 'textutils'
|
25
25
|
|
26
|
+
## add more activerecords addons/utils
|
26
27
|
require 'activityutils'
|
27
|
-
|
28
28
|
require 'props/activerecord'
|
29
29
|
require 'logutils/activerecord'
|
30
30
|
|
@@ -35,53 +35,76 @@ require 'pluto/version' # note: let version always get first
|
|
35
35
|
require 'pluto/schema'
|
36
36
|
require 'pluto/activerecord'
|
37
37
|
|
38
|
-
require 'pluto/models/
|
38
|
+
require 'pluto/models/forward'
|
39
39
|
require 'pluto/models/feed'
|
40
40
|
require 'pluto/models/item'
|
41
41
|
require 'pluto/models/site'
|
42
42
|
require 'pluto/models/subscription'
|
43
43
|
require 'pluto/models/utils'
|
44
44
|
|
45
|
-
require 'pluto/manifest_helpers'
|
46
45
|
require 'pluto/connecter'
|
47
46
|
|
48
|
-
require 'pluto/installer'
|
49
|
-
require 'pluto/fetcher'
|
50
|
-
require 'pluto/refresher'
|
51
|
-
require 'pluto/subscriber'
|
52
|
-
require 'pluto/updater'
|
53
|
-
require 'pluto/lister'
|
54
|
-
require 'pluto/formatter'
|
55
|
-
|
56
47
|
|
57
48
|
module Pluto
|
58
49
|
|
59
|
-
def self.
|
60
|
-
|
50
|
+
def self.create
|
51
|
+
CreateDb.new.up
|
52
|
+
ConfDb::Model::Prop.create!( key: 'db.schema.planet.version', value: VERSION )
|
61
53
|
end
|
62
54
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
55
|
+
def self.create_all
|
56
|
+
LogDb.create # add logs table
|
57
|
+
ConfDb.create # add props table
|
58
|
+
ActivityDb::CreateDb.new.up # todo/check - use ActivityDb.create if exists???
|
59
|
+
Pluto.create
|
67
60
|
end
|
68
61
|
|
69
|
-
def self.update_feeds
|
70
|
-
Refresher.new.update_feeds
|
71
|
-
end
|
72
62
|
|
73
|
-
def self.
|
74
|
-
|
63
|
+
def self.auto_migrate!
|
64
|
+
# first time? - auto-run db migratation, that is, create db tables
|
65
|
+
unless LogDb::Model::Log.table_exists?
|
66
|
+
LogDb.create # add logs table
|
67
|
+
end
|
68
|
+
|
69
|
+
unless ConfDb::Model::Prop.table_exists?
|
70
|
+
ConfDb.create # add props table
|
71
|
+
end
|
72
|
+
|
73
|
+
## fix: change to Model from Models
|
74
|
+
unless ActivityDb::Models::Activity.table_exists?
|
75
|
+
ActivityDb::CreateDb.new.up # todo/check - use ActivityDb.create if exists???
|
76
|
+
end
|
77
|
+
|
78
|
+
unless Model::Feed.table_exists?
|
79
|
+
Pluto.create
|
80
|
+
end
|
81
|
+
end # method auto_migrate!
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
def self.connect( config={} ) # convenience shortcut without (w/o) automigrate
|
86
|
+
Connecter.new.connect( config )
|
75
87
|
end
|
76
88
|
|
77
|
-
def self.
|
78
|
-
|
79
|
-
|
80
|
-
load 'pluto/tasks/setup.rake'
|
81
|
-
load 'pluto/tasks/stats.rake'
|
82
|
-
load 'pluto/tasks/update.rake'
|
89
|
+
def self.connect!( config={} ) # convenience shortcut w/ automigrate
|
90
|
+
Pluto.connect( config )
|
91
|
+
Pluto.auto_migrate!
|
83
92
|
end
|
84
93
|
|
94
|
+
|
95
|
+
def self.setup_in_memory_db
|
96
|
+
# Database Setup & Config
|
97
|
+
ActiveRecord::Base.logger = Logger.new( STDOUT )
|
98
|
+
## ActiveRecord::Base.colorize_logging = false - no longer exists - check new api/config setting?
|
99
|
+
|
100
|
+
Pluto.connect( adapter: 'sqlite3',
|
101
|
+
database: ':memory:' )
|
102
|
+
|
103
|
+
## build schema
|
104
|
+
Pluto.create_all
|
105
|
+
end # setup_in_memory_dd
|
106
|
+
|
107
|
+
|
85
108
|
end # module Pluto
|
86
109
|
|
87
110
|
|
data/lib/pluto/models/feed.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
|
1
4
|
module Pluto
|
2
|
-
module
|
5
|
+
module Model
|
3
6
|
|
4
7
|
class Feed < ActiveRecord::Base
|
5
8
|
self.table_name = 'feeds'
|
@@ -123,5 +126,5 @@ class Feed < ActiveRecord::Base
|
|
123
126
|
end # class Feed
|
124
127
|
|
125
128
|
|
126
|
-
end # module
|
129
|
+
end # module Model
|
127
130
|
end # module Pluto
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Pluto
|
4
|
+
module Model
|
5
|
+
|
6
|
+
#######
|
7
|
+
# ActivityDB
|
8
|
+
|
9
|
+
# add shortcut/alias
|
10
|
+
## fix: use Model instead of Models
|
11
|
+
Activity = ActivityDb::Models::Activity
|
12
|
+
|
13
|
+
end # module Model
|
14
|
+
|
15
|
+
# note: convenience alias for Model
|
16
|
+
# lets you use include Pluto::Models
|
17
|
+
Models = Model
|
18
|
+
|
19
|
+
end # module Pluto
|
20
|
+
|
data/lib/pluto/models/item.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pluto
|
2
|
-
module
|
4
|
+
module Model
|
3
5
|
|
4
6
|
class Item < ActiveRecord::Base
|
5
7
|
self.table_name = 'items'
|
@@ -69,5 +71,5 @@ class Item < ActiveRecord::Base
|
|
69
71
|
end # class Item
|
70
72
|
|
71
73
|
|
72
|
-
end # module
|
74
|
+
end # module Model
|
73
75
|
end # module Pluto
|
data/lib/pluto/models/site.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
1
3
|
module Pluto
|
2
|
-
module
|
4
|
+
module Model
|
3
5
|
|
4
6
|
class Site < ActiveRecord::Base
|
5
7
|
self.table_name = 'sites'
|
@@ -15,5 +17,5 @@ class Site < ActiveRecord::Base
|
|
15
17
|
|
16
18
|
end
|
17
19
|
|
18
|
-
end # module
|
20
|
+
end # module Model
|
19
21
|
end # module Pluto
|
data/lib/pluto/models/utils.rb
CHANGED
data/lib/pluto/schema.rb
CHANGED
data/lib/pluto/version.rb
CHANGED
data/test/helper.rb
CHANGED
@@ -11,3 +11,16 @@ require 'pluto/models'
|
|
11
11
|
|
12
12
|
LogUtils::Logger.root.level = :debug
|
13
13
|
|
14
|
+
|
15
|
+
## some shortcuts
|
16
|
+
Log = LogDb::Model::Log
|
17
|
+
Prop = ConfDb::Model::Prop
|
18
|
+
|
19
|
+
Site = Pluto::Model::Site
|
20
|
+
Feed = Pluto::Model::Feed
|
21
|
+
Item = Pluto::Model::Item
|
22
|
+
Subscription = Pluto::Model::Subscription
|
23
|
+
|
24
|
+
|
25
|
+
Pluto.setup_in_memory_db
|
26
|
+
|
data/test/test_helpers.rb
CHANGED
@@ -12,11 +12,26 @@ class TestHelper < MiniTest::Test
|
|
12
12
|
|
13
13
|
## add some tests; to be done
|
14
14
|
|
15
|
-
def test_banner
|
15
|
+
def test_banner
|
16
16
|
puts Pluto.banner
|
17
|
-
|
18
|
-
assert true
|
17
|
+
|
18
|
+
assert true ## if we get here it should workd
|
19
19
|
end
|
20
20
|
|
21
|
+
def test_models
|
22
|
+
assert_equal 1, Prop.count
|
23
|
+
assert_equal 0, Log.count
|
24
|
+
|
25
|
+
assert_equal 0, Site.count
|
26
|
+
assert_equal 0, Feed.count
|
27
|
+
assert_equal 0, Item.count
|
28
|
+
assert_equal 0, Subscription.count
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_auto_migrate
|
32
|
+
Pluto.auto_migrate!
|
33
|
+
|
34
|
+
assert true ## if we get here it should workd
|
35
|
+
end
|
21
36
|
|
22
37
|
end # class TestHelper
|