pluto 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 +7 -0
- data/HISTORY.md +3 -2
- data/Manifest.txt +1 -25
- data/README.md +8 -98
- data/Rakefile +9 -13
- data/lib/pluto.rb +7 -134
- data/lib/pluto/cli/main.rb +16 -6
- data/lib/pluto/cli/opts.rb +4 -1
- data/lib/pluto/cli/version.rb +24 -0
- metadata +79 -103
- data/.gemtest +0 -0
- data/config/pluto.index.yml +0 -23
- data/lib/pluto/activerecord.rb +0 -18
- data/lib/pluto/connecter.rb +0 -96
- 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 -50
- data/lib/pluto/models/activity.rb +0 -8
- data/lib/pluto/models/feed.rb +0 -127
- data/lib/pluto/models/item.rb +0 -73
- data/lib/pluto/models/site.rb +0 -19
- data/lib/pluto/models/subscription.rb +0 -14
- data/lib/pluto/models/utils.rb +0 -47
- data/lib/pluto/refresher.rb +0 -130
- data/lib/pluto/schema.rb +0 -139
- 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
- data/lib/pluto/version.rb +0 -4
- data/test/helper.rb +0 -18
- data/test/test_helpers.rb +0 -15
data/lib/pluto/schema.rb
DELETED
@@ -1,139 +0,0 @@
|
|
1
|
-
|
2
|
-
module Pluto
|
3
|
-
|
4
|
-
class CreateDb < ActiveRecord::Migration
|
5
|
-
|
6
|
-
def up
|
7
|
-
create_table :sites do |t|
|
8
|
-
t.string :title, :null => false # e.g Planet Ruby, Planet JavaScript, etc.
|
9
|
-
t.string :key, :null => false # e.g. ruby, js, etc.
|
10
|
-
|
11
|
-
############
|
12
|
-
# filters (site-wide)
|
13
|
-
t.string :includes # regex
|
14
|
-
t.string :excludes # regex
|
15
|
-
|
16
|
-
######################
|
17
|
-
# for auto-update of feed list/site config
|
18
|
-
|
19
|
-
t.string :url # source url for auto-update (optional)
|
20
|
-
|
21
|
-
## note: make sure to use same fields for update check as feed
|
22
|
-
|
23
|
-
t.datetime :fetched # last fetched/checked date -- make not null ??
|
24
|
-
t.integer :http_code # last http status code e.g. 200,404,etc.
|
25
|
-
t.string :http_etag # last http header etag
|
26
|
-
## note: save last-modified header as text (not datetime) - pass through as is
|
27
|
-
t.string :http_last_modified # last http header last-modified - note: save header as plain text!!! pass along in next request as-is
|
28
|
-
t.string :http_server # last http server header if present
|
29
|
-
|
30
|
-
# note: do NOT store body content (that is, text) and md5 digest
|
31
|
-
# use git! and github! commit will be http_etag!!
|
32
|
-
|
33
|
-
t.datetime :fetched # last fetched/checked date
|
34
|
-
|
35
|
-
#############
|
36
|
-
# more fields
|
37
|
-
|
38
|
-
t.timestamps # created_at, updated_at
|
39
|
-
end
|
40
|
-
|
41
|
-
create_table :subscriptions do |t| # has_many join table (sites/feeds)
|
42
|
-
t.references :site, :null => false
|
43
|
-
t.references :feed, :null => false
|
44
|
-
t.timestamps
|
45
|
-
end
|
46
|
-
|
47
|
-
create_table :feeds do |t|
|
48
|
-
t.string :title # user supplied title
|
49
|
-
t.string :auto_title # "fallback" - auto(fill) title from feed
|
50
|
-
|
51
|
-
t.string :title2 # user supplied title2
|
52
|
-
t.string :auto_title2 # "fallback" - auto(fill) title2 from feed e.g. subtitle (atom)
|
53
|
-
|
54
|
-
t.string :url # user supplied site url
|
55
|
-
t.string :auto_url # "fallback" - auto(fill) url from feed
|
56
|
-
|
57
|
-
t.string :feed_url # user supplied feed url
|
58
|
-
t.string :auto_feed_url # "fallback" - auto discovery feed url from (site) url
|
59
|
-
|
60
|
-
t.text :summary # e.g. description (rss)
|
61
|
-
|
62
|
-
t.string :generator # feed generator (e.g. wordpress, etc.) from feed
|
63
|
-
|
64
|
-
t.datetime :published # from feed published(atom)+ pubDate(rss)
|
65
|
-
t.datetime :built # from feed lastBuiltDate(rss)
|
66
|
-
t.datetime :touched # from feed updated(atom)
|
67
|
-
|
68
|
-
### extras (move to array for custom fields or similar??)
|
69
|
-
t.string :github # github handle (optional)
|
70
|
-
t.string :twitter # twitter handle (optional)
|
71
|
-
t.string :avatar # gravator or hackergotchi handle (optional)
|
72
|
-
|
73
|
-
### add class/kind field e.g.
|
74
|
-
# - personal feed/blog/site, that is, individual author
|
75
|
-
# - team blog/site
|
76
|
-
# - org (anization) or com(pany blog/site)
|
77
|
-
# - newsfeed (composite)
|
78
|
-
# - other (link blog?, podcast?) - why? why not??
|
79
|
-
|
80
|
-
############
|
81
|
-
# filters
|
82
|
-
t.string :includes # regex
|
83
|
-
t.string :excludes # regex
|
84
|
-
# todo: add generic filter list e.g. t.string :filters (comma,pipe or space separated method names?)
|
85
|
-
|
86
|
-
# -- our own (meta) fields
|
87
|
-
t.datetime :last_published # cache last (latest) published for items
|
88
|
-
|
89
|
-
t.string :key, :null => false
|
90
|
-
t.string :format # e.g. atom (1.0), rss 2.0, rss 0.7 etc.
|
91
|
-
|
92
|
-
t.integer :http_code # last http status code e.g. 200,404,etc.
|
93
|
-
t.string :http_etag # last http header etag
|
94
|
-
## note: save last-modified header as text (not datetime) - pass through as is
|
95
|
-
t.string :http_last_modified # last http header last-modified - note: save header as plain text!!! pass along in next request as-is
|
96
|
-
t.string :http_server # last http server header if present
|
97
|
-
|
98
|
-
t.string :md5 # md5 hash of body
|
99
|
-
t.text :body # last http response body (complete feed!)
|
100
|
-
|
101
|
-
t.datetime :fetched # last fetched/checked date
|
102
|
-
|
103
|
-
t.timestamps # created_at, updated_at
|
104
|
-
end
|
105
|
-
|
106
|
-
|
107
|
-
create_table :items do |t|
|
108
|
-
t.string :guid
|
109
|
-
t.string :url
|
110
|
-
|
111
|
-
## note: title may contain more than 255 chars!! use text for sure!
|
112
|
-
## e.g. Rails Girls blog has massive titles in feed
|
113
|
-
|
114
|
-
t.text :title # todo: add some :null => false ??
|
115
|
-
t.text :summary # e.g. description (rss), summary (atom)
|
116
|
-
t.text :content
|
117
|
-
|
118
|
-
t.datetime :published # from feed (published) + pubDate(rss)
|
119
|
-
t.datetime :touched # from feed updated (atom)
|
120
|
-
|
121
|
-
## todo: add :last_updated_at ?? (NOTE: updated_at already take by auto-timestamps)
|
122
|
-
t.references :feed, :null => false
|
123
|
-
|
124
|
-
t.datetime :fetched # last fetched/check date
|
125
|
-
t.timestamps # created_at, updated_at
|
126
|
-
|
127
|
-
## t.string :author
|
128
|
-
## todo: add author/authors, category/categories
|
129
|
-
end
|
130
|
-
|
131
|
-
end
|
132
|
-
|
133
|
-
def down
|
134
|
-
raise ActiveRecord::IrreversibleMigration
|
135
|
-
end
|
136
|
-
|
137
|
-
end # class CreateDb
|
138
|
-
|
139
|
-
end # module Pluto
|
data/lib/pluto/subscriber.rb
DELETED
@@ -1,102 +0,0 @@
|
|
1
|
-
module Pluto
|
2
|
-
|
3
|
-
class Subscriber
|
4
|
-
|
5
|
-
include LogUtils::Logging
|
6
|
-
|
7
|
-
include Models
|
8
|
-
|
9
|
-
def debug=(value) @debug = value; end
|
10
|
-
def debug?() @debug || false; end
|
11
|
-
|
12
|
-
|
13
|
-
def update_subscriptions( config, opts={} )
|
14
|
-
# !!!! -- depreciated API - remove - do NOT use anymore
|
15
|
-
puts "*** warn - [Pluto::Subscriber] depreciated API -- use update_subscriptions_for( site_key )"
|
16
|
-
update_subscriptions_for( 'planet', config, opts ) # default to planet site_key
|
17
|
-
end
|
18
|
-
|
19
|
-
|
20
|
-
def update_subscriptions_for( site_key, config, opts={} )
|
21
|
-
site_attribs = {
|
22
|
-
title: config['title'] || config['name'], # support either title or name
|
23
|
-
url: config['source'] || config['url'] # support source or url for source url for auto-update (optional)
|
24
|
-
}
|
25
|
-
|
26
|
-
logger.debug "site_attribs: #{site_attribs.inspect}"
|
27
|
-
|
28
|
-
site_rec = Site.find_by_key( site_key )
|
29
|
-
if site_rec.nil?
|
30
|
-
site_rec = Site.new
|
31
|
-
site_attribs[ :key ] = site_key
|
32
|
-
|
33
|
-
## use object_id: site.id and object_type: Site
|
34
|
-
## change - model/table/schema!!!
|
35
|
-
Activity.create!( text: "new site >#{site_key}< - #{site_attribs[ :title ]}" )
|
36
|
-
end
|
37
|
-
site_rec.update_attributes!( site_attribs )
|
38
|
-
|
39
|
-
# -- log update activity
|
40
|
-
Activity.create!( text: "update subscriptions >#{site_key}<" )
|
41
|
-
|
42
|
-
# clean out subscriptions and add again
|
43
|
-
logger.debug "before site.subscriptions.delete_all - count: #{site_rec.subscriptions.count}"
|
44
|
-
site_rec.subscriptions.destroy_all # note: use destroy_all NOT delete_all (delete_all tries by default only nullify)
|
45
|
-
logger.debug "after site.subscriptions.delete_all - count: #{site_rec.subscriptions.count}"
|
46
|
-
|
47
|
-
config.each do |key, value|
|
48
|
-
|
49
|
-
## todo: downcase key - why ??? why not???
|
50
|
-
|
51
|
-
# skip "top-level" feed keys e.g. title, etc. or planet planet sections (e.g. planet,defaults)
|
52
|
-
next if ['title','title2','name',
|
53
|
-
'source', 'url',
|
54
|
-
'include','includes','exclude','excludes',
|
55
|
-
'feeds',
|
56
|
-
'planet','defaults'].include?( key )
|
57
|
-
|
58
|
-
### todo/check:
|
59
|
-
## check value - must be hash
|
60
|
-
# check if url or feed_url present
|
61
|
-
# that is, check for required props/key-value pairs
|
62
|
-
|
63
|
-
feed_key = key.to_s.dup
|
64
|
-
feed_hash = value
|
65
|
-
|
66
|
-
# todo/fix: use title from feed?
|
67
|
-
# e.g. fill up auto_title, auto_url, etc.
|
68
|
-
|
69
|
-
feed_attribs = {
|
70
|
-
feed_url: feed_hash[ 'feed' ] || feed_hash[ 'feed_url' ],
|
71
|
-
url: feed_hash[ 'link' ] || feed_hash[ 'url' ],
|
72
|
-
title: feed_hash[ 'title' ] || feed_hash[ 'name' ],
|
73
|
-
title2: feed_hash[ 'title2' ],
|
74
|
-
includes: feed_hash[ 'includes' ] || feed_hash[ 'include' ],
|
75
|
-
excludes: feed_hash[ 'excludes' ] || feed_hash[ 'exclude' ]
|
76
|
-
}
|
77
|
-
|
78
|
-
puts "Updating feed subscription >#{feed_key}< - >#{feed_attribs[:feed_url]}<..."
|
79
|
-
|
80
|
-
feed_rec = Feed.find_by_key( feed_key )
|
81
|
-
if feed_rec.nil?
|
82
|
-
feed_rec = Feed.new
|
83
|
-
feed_attribs[ :key ] = feed_key
|
84
|
-
|
85
|
-
## use object_id: feed.id and object_type: Feed
|
86
|
-
## change - model/table/schema!!!
|
87
|
-
## todo: add parent_action_id - why? why not?
|
88
|
-
Activity.create!( text: "new feed >#{feed_key}< - #{feed_attribs[ :title ]}" )
|
89
|
-
end
|
90
|
-
|
91
|
-
feed_rec.update_attributes!( feed_attribs )
|
92
|
-
|
93
|
-
# add subscription record
|
94
|
-
# note: subscriptions get cleaned out on update first (see above)
|
95
|
-
site_rec.subscriptions.create!( feed_id: feed_rec.id )
|
96
|
-
end
|
97
|
-
|
98
|
-
end # method update_subscriptions
|
99
|
-
|
100
|
-
end # class Subscriber
|
101
|
-
|
102
|
-
end # module Pluto
|
data/lib/pluto/tasks/env.rake
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
task :env do
|
4
|
-
LogUtils::Logger.root.level = :debug
|
5
|
-
|
6
|
-
Pluto.connect!
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
#########
|
11
|
-
# for debugging
|
12
|
-
|
13
|
-
desc 'pluto - debug site setup'
|
14
|
-
task :site => :env do
|
15
|
-
site = Pluto::Models::Site.first # FIX: for now assume one planet per DB (fix later; allow planet key or similar)
|
16
|
-
if site.present?
|
17
|
-
puts "site found:"
|
18
|
-
pp site
|
19
|
-
else
|
20
|
-
puts "no site found"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
### todo: add new task :sites
|
25
|
-
|
data/lib/pluto/tasks/setup.rake
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
desc 'pluto -=- setup/update feed subscriptions'
|
4
|
-
task :setup => :env do
|
5
|
-
|
6
|
-
## check if PLANET key passed in
|
7
|
-
if ENV['PLANET'].present?
|
8
|
-
key = ENV['PLANET']
|
9
|
-
puts "setup planet for key >#{key}<"
|
10
|
-
else
|
11
|
-
puts 'no PLANET=key passed along; try defaults'
|
12
|
-
# try pluto.yml or planet.yml if exist
|
13
|
-
|
14
|
-
if File.exists?( './pluto.ini' ) || File.exists?( './pluto.yml' ) # check if pluto.yml exists, if yes add/use it
|
15
|
-
key ='pluto'
|
16
|
-
elsif File.exists?( './planet.ini' ) || File.exists?( './planet.yml' ) # check if planet.yml exists, if yes add/use it
|
17
|
-
key = 'planet'
|
18
|
-
else
|
19
|
-
puts '*** note: no arg passed in; no pluto.ini|yml or planet.ini|yml found in working folder'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
config_path = "./#{key}.ini"
|
25
|
-
if File.exists?( config_path )
|
26
|
-
config = INI.load_file( config_path )
|
27
|
-
else ## assume .yml
|
28
|
-
config_path = "./#{key}.yml"
|
29
|
-
config = YAML.load_file( config_path )
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
puts "dump planet setup settings >#{config_path}<:"
|
34
|
-
pp config
|
35
|
-
|
36
|
-
# note: allow multiple planets (sites) for a single install
|
37
|
-
Pluto::Subscriber.new.update_subscriptions_for( key, config )
|
38
|
-
|
39
|
-
puts 'Done.'
|
40
|
-
end
|
data/lib/pluto/tasks/stats.rake
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
desc 'pluto - show planet (feed) stats'
|
4
|
-
task :stats => :env do
|
5
|
-
puts "stats:"
|
6
|
-
puts " Feeds: #{Pluto::Models::Feed.count}"
|
7
|
-
puts " Items: #{Pluto::Models::Item.count}"
|
8
|
-
puts " Sites: #{Pluto::Models::Site.count}"
|
9
|
-
puts " Subscriptions: #{Pluto::Models::Subscription.count}"
|
10
|
-
end
|
data/lib/pluto/tasks/update.rake
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
desc 'pluto -=- update planet (site configs)'
|
4
|
-
task :update_sites => :env do
|
5
|
-
|
6
|
-
Pluto.update_sites # update all site configs if source (url) present/specified
|
7
|
-
|
8
|
-
puts 'Done (Update Sites).'
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
desc 'pluto -=- update planet (feeds)'
|
13
|
-
task :update_feeds => :env do
|
14
|
-
|
15
|
-
Pluto.update_feeds
|
16
|
-
|
17
|
-
puts 'Done (Update Feeds).'
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
desc 'pluto -=- update planet (site configs + feeds)'
|
22
|
-
task :update => [:update_sites, :update_feeds] do
|
23
|
-
puts 'Done.'
|
24
|
-
end
|
data/lib/pluto/updater.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
module Pluto
|
2
|
-
|
3
|
-
class Updater
|
4
|
-
|
5
|
-
include LogUtils::Logging
|
6
|
-
|
7
|
-
### fix!!!!!: change config to text - yes/no - why? why not??
|
8
|
-
# or pass along struct
|
9
|
-
# - with hash and text and format(e.g. ini/yml) as fields???
|
10
|
-
#
|
11
|
-
# - why? - we need to get handle on md5 digest/hash plus on plain text, ideally to store in db
|
12
|
-
## - pass along unparsed text!! - not hash struct
|
13
|
-
# - will get saved in db plus we need to generate md5 hash
|
14
|
-
# - add filename e.g. ruby.ini|ruby.conf|ruby.yml as opt ??
|
15
|
-
# or add config format as opt e.g. ini or yml?
|
16
|
-
|
17
|
-
def initialize( opts, config )
|
18
|
-
@opts = opts
|
19
|
-
@config = config
|
20
|
-
end
|
21
|
-
|
22
|
-
attr_reader :opts, :config
|
23
|
-
|
24
|
-
def run( arg )
|
25
|
-
arg = arg.downcase.gsub('.ini','').gsub('.yml','') # remove file extension if present
|
26
|
-
|
27
|
-
update_for( arg )
|
28
|
-
end
|
29
|
-
|
30
|
-
def update_for( site_key )
|
31
|
-
###################
|
32
|
-
# step 1) update subscriptions
|
33
|
-
subscriber = Subscriber.new
|
34
|
-
|
35
|
-
# pass along debug/verbose setting/switch
|
36
|
-
subscriber.debug = true if opts.verbose?
|
37
|
-
subscriber.update_subscriptions_for( site_key, config )
|
38
|
-
|
39
|
-
##############################
|
40
|
-
# step 2) update feeds
|
41
|
-
refresher = Refresher.new
|
42
|
-
|
43
|
-
# pass along debug/verbose setting/switch
|
44
|
-
refresher.debug = true if opts.verbose?
|
45
|
-
refresher.update_feeds_for( site_key )
|
46
|
-
end # method run
|
47
|
-
|
48
|
-
end # class Updater
|
49
|
-
|
50
|
-
end # module Pluto
|
data/lib/pluto/version.rb
DELETED
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
## $:.unshift(File.dirname(__FILE__))
|
2
|
-
|
3
|
-
|
4
|
-
## minitest setup
|
5
|
-
|
6
|
-
# require 'minitest/unit'
|
7
|
-
require 'minitest/autorun'
|
8
|
-
|
9
|
-
# include MiniTest::Unit # lets us use TestCase instead of MiniTest::Unit::TestCase
|
10
|
-
|
11
|
-
|
12
|
-
## our own code
|
13
|
-
|
14
|
-
require 'pluto'
|
15
|
-
|
16
|
-
|
17
|
-
LogUtils::Logger.root.level = :debug
|
18
|
-
|
data/test/test_helpers.rb
DELETED