pluto 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/Manifest.txt CHANGED
@@ -14,7 +14,11 @@ lib/pluto/installer.rb
14
14
  lib/pluto/lister.rb
15
15
  lib/pluto/manifest_helpers.rb
16
16
  lib/pluto/models.rb
17
+ lib/pluto/refresher.rb
17
18
  lib/pluto/schema.rb
19
+ lib/pluto/subscriber.rb
18
20
  lib/pluto/template_helpers.rb
19
21
  lib/pluto/updater.rb
20
22
  lib/pluto/version.rb
23
+ test/helper.rb
24
+ test/test_helpers.rb
data/README.md CHANGED
@@ -28,6 +28,11 @@ This will
28
28
  Open up `ruby.html` to see your planet web page. Voila!
29
29
 
30
30
 
31
+ Note: If you pass in no planet configuration files, the `pluto` command line tool will look
32
+ for the default planet configuration files,
33
+ that is, `pluto.ini`, `pluto.yml`, `planet.ini`, `planet.yml`.
34
+
35
+
31
36
  ### Command Line Tool
32
37
 
33
38
  ~~~~
@@ -48,10 +53,13 @@ COMMANDS
48
53
  build, b - Build planet
49
54
  install, i - Install template pack
50
55
  list, ls, l - List installed template packs
56
+ fetch, f - Fetch planet feeds
57
+ merge, m - Merge planet template pack
51
58
  about, a - (Debug) Show more version info
52
59
  help - Shows a list of commands or help for one command
53
60
  ~~~~
54
61
 
62
+
55
63
  #### `build` Command
56
64
 
57
65
  ~~~
@@ -68,8 +76,10 @@ COMMAND OPTIONS
68
76
  EXAMPLE
69
77
  pluto build ruby.yml
70
78
  pluto b ruby
79
+ pluto b # will use pluto.ini|pluto.yml|planet.ini|planet.yml if present
71
80
  ~~~
72
81
 
82
+
73
83
  #### `list` Command
74
84
 
75
85
  ~~~
@@ -84,6 +94,7 @@ EXAMPLE
84
94
  pluto ls
85
95
  ~~~
86
96
 
97
+
87
98
  #### `install` Command
88
99
 
89
100
  ~~~
@@ -98,34 +109,85 @@ EXAMPLE
98
109
  ~~~
99
110
 
100
111
 
112
+ #### `fetch` Command
113
+
114
+ ~~~
115
+ NAME
116
+ fetch - Fetch planet feeds
117
+
118
+ SYNOPSIS
119
+ pluto [global options] fetch FILE
120
+
121
+ EXAMPLE
122
+ pluto fetch ruby.yml
123
+ pluto f ruby
124
+ ~~~
125
+
126
+
127
+ #### `merge` Command
128
+
129
+ ~~~
130
+ NAME
131
+ merge - Merge planet template pack
132
+
133
+ SYNOPSIS
134
+ pluto [global options] merge [command options] FILE
135
+
136
+ COMMAND OPTIONS
137
+ -o, --output=PATH - Output Path (default: .)
138
+ -t, --template=MANIFEST - Template Manifest (default: blank)
139
+
140
+ EXAMPLE
141
+ pluto merge ruby.yml
142
+ pluto m ruby
143
+ ~~~
144
+
145
+
146
+
101
147
 
102
148
  ### Planet Configuration Sample
103
149
 
104
- `ruby.yml`:
150
+ `ruby.ini`:
151
+
152
+ ```
153
+ title = Planet Ruby
154
+
155
+ [rubyflow]
156
+ title = Ruby Flow
157
+ feed_url = http://feeds.feedburner.com/Rubyflow?format=xml
158
+ url = http://rubyflow.com
159
+
160
+ [rubyonrails]
161
+ title = Ruby on Rails Blog
162
+ feed_url = http://weblog.rubyonrails.org/feed/atom.xml
163
+ url = http://weblog.rubyonrails.org
164
+
165
+ [viennarb]
166
+ title = vienna.rb Blog
167
+ url = http://vienna-rb.at
168
+ feed_url = http://vienna-rb.at/atom.xml
169
+ ```
170
+
171
+ or `ruby.yml`:
105
172
 
106
173
  ```
107
174
  title: Planet Ruby
108
175
 
109
176
 
110
177
  rubyflow:
111
- title: Ruby Flow
178
+ title: Ruby Flow
112
179
  feed_url: http://feeds.feedburner.com/Rubyflow?format=xml
113
- url: http://rubyflow.com
114
-
115
- edgerails:
116
- title: What's new in Edge Rails?
117
- feed_url: http://www.edgerails.info/blog.atom
118
- url: http://www.edgerails.info
180
+ url: http://rubyflow.com
119
181
 
120
182
  rubyonrails:
121
- title: Ruby on Rails Blog
183
+ title: Ruby on Rails Blog
122
184
  feed_url: http://weblog.rubyonrails.org/feed/atom.xml
123
- url: http://weblog.rubyonrails.org
185
+ url: http://weblog.rubyonrails.org
124
186
 
125
- railstutorial:
126
- title: Rails Tutorial News
127
- feed_url: http://feeds.feedburner.com/railstutorial?format=xml
128
- url: http://news.railstutorial.org
187
+ viennarb:
188
+ title: vienna.rb Blog
189
+ url: http://vienna-rb.at
190
+ feed_url: http://vienna-rb.at/atom.xml
129
191
  ```
130
192
 
131
193
  For more samples, see [`nytimes.yml`](https://github.com/feedreader/pluto.samples/blob/master/nytimes.yml),
@@ -152,16 +214,24 @@ Just install the gem:
152
214
 
153
215
  `planet.rb` by Akira Yamada [(Site)](http://planet.rubyforge.org)
154
216
 
155
- `Planet.rb` by Pablo Astigarraga [(Site)](https://github.com/pote/planet.rb) - used with jekyll/octopress site generator
217
+ `planet.rb` by Pablo Astigarraga [(Site)](https://github.com/pote/planet.rb) - used with jekyll/octopress site generator
218
+
219
+ Planet Mars by Sam Ruby [(Site)](https://github.com/rubys/mars) - first draft of cleaned up Planet Planet code; last change in 2008
156
220
 
157
221
  ### Python
158
222
 
159
- Planet Planet by Scott James Remnant n Jeff Waugh [(Site)](http://www.planetplanet.org) - uses Mark Pilgrim's universal feed parser (RDF, RSS and Atom) and Tomas Styblo's templating engine
223
+ Planet Planet by Scott James Remnant n Jeff Waugh [(Site)](http://www.planetplanet.org) - uses Mark Pilgrim's universal feed parser (RDF, RSS and Atom) and Tomas Styblo's templating engine; last release version 2.0 in 2006
160
224
 
161
- Planet Venus by Sam Ruby [(Site)](https://github.com/rubys/venus) - cleaned up Planet Planet code
225
+ Planet Venus by Sam Ruby [(Site)](https://github.com/rubys/venus) - cleaned up Planet Planet code; last change in 2010
162
226
 
163
227
 
164
228
  ## License
165
229
 
166
230
  The `pluto` scripts are dedicated to the public domain.
167
231
  Use it as you please with no restrictions whatsoever.
232
+
233
+ ## Questions? Comments?
234
+
235
+ Questions? Comments?
236
+ Send them along to the [Planet Pluto and Friends Forum/Mailing List](http://groups.google.com/group/feedreader).
237
+ Thanks!
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.spec 'pluto' do
11
11
  self.urls = ['https://github.com/feedreader/pluto']
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'webslideshow@googlegroups.com'
14
+ self.email = 'feedreader@googlegroups.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -21,8 +21,8 @@ Hoe.spec 'pluto' do
21
21
  ['pakman', '>= 0.5'],
22
22
  ['fetcher', '>= 0.3'],
23
23
  ['logutils', '>= 0.6'],
24
- ['feedutils', '>= 0.3'],
25
- ['props', '>= 1.0.0'],
24
+ ['feedutils', '>= 0.3.2'], # use min. 0.3.2 - added fix for rss.item.guid missing; no more auto-summary in atom
25
+ ['props', '>= 1.0.2'], # use min. 1.0.2 - added ini support
26
26
  ['textutils', '>= 0.6.8'], # future: add some filters (for include/exclude)
27
27
  ['gli', '>= 2.5.6']
28
28
  ## ['activerecord', '~> 3.2'], # NB: soft dependency, will include activesupport,etc.
data/lib/pluto.rb CHANGED
@@ -36,8 +36,10 @@ require 'pluto/manifest_helpers'
36
36
  require 'pluto/connecter'
37
37
 
38
38
  require 'pluto/installer'
39
- require 'pluto/updater'
40
39
  require 'pluto/fetcher'
40
+ require 'pluto/refresher'
41
+ require 'pluto/subscriber'
42
+ require 'pluto/updater'
41
43
  require 'pluto/lister'
42
44
  require 'pluto/template_helpers'
43
45
  require 'pluto/formatter'
@@ -59,11 +61,11 @@ module Pluto
59
61
  end
60
62
 
61
63
  def self.update_subscriptions( config )
62
- Updater.new.update_subscriptions( config )
64
+ Subscriber.new.update_subscriptions( config )
63
65
  end
64
66
 
65
67
  def self.update_feeds
66
- Updater.new.update_feeds
68
+ Refresher.new.update_feeds
67
69
  end
68
70
 
69
71
  def self.main
@@ -64,6 +64,86 @@ end # class SysInfo
64
64
 
65
65
 
66
66
 
67
+ ######
68
+ # begin
69
+ # move to pluto for reuse (e.g. in rakefile)
70
+
71
+ def load_config( name )
72
+ extname = File.extname( name ) # return '' or '.ini' or '.yml' etc.
73
+
74
+ config = extname == '.ini' ? INI.load_file( name ) :
75
+ YAML.load_file( name )
76
+
77
+ puts "dump >#{name}<:"
78
+ pp config
79
+
80
+ config
81
+ end
82
+
83
+
84
+ def find_default_config_path
85
+ candidates = [ 'pluto.ini',
86
+ 'pluto.yml',
87
+ 'planet.ini',
88
+ 'planet.yml' ]
89
+
90
+ candidates.each do |candidate|
91
+ return candidate if File.exists?( candidate ) ## todo: use ./candidate -- why? why not??
92
+ end
93
+
94
+ puts "*** note: no default planet configuration found, that is, no #{candidates.join('|')} found in working folder"
95
+ nil # return nil; no conifg existing candidate found/present; sorry
96
+ end
97
+
98
+
99
+ def find_config_path( name )
100
+ extname = File.extname( name ) # return '' or '.ini' or '.yml' etc.
101
+
102
+ return name if extname.present? # nothing to do; extension already present
103
+
104
+ candidates = [ '.ini', '.yml' ]
105
+
106
+ candidates.each do |candidate|
107
+ return "#{name}#{candidate}" if File.exists?( "#{name}#{candidate}" )
108
+ end
109
+
110
+ # no extensions matching; sorry
111
+ puts "*** note: no configuration found w/ extensions #{candidates.join('|')} for '#{name}'"
112
+ # todo/check/fix - ?? -skip; remove from arg - or just pass through ???
113
+ nil # return nil; no config found/present; sorry
114
+ end
115
+
116
+ # end
117
+ # move to pluto for reuse (e.g. in rakefile)
118
+ ###########################
119
+
120
+
121
+ def expand_config_args( args )
122
+
123
+ # 1) no args - try to find default config e.g. pluto.ini etc.
124
+ if args.length == 0
125
+ new_arg = find_default_config_path
126
+
127
+ return [] if new_arg.nil?
128
+ return [new_arg] # create a new args w/ one item e.g. ['pluto.yml']
129
+ end
130
+
131
+ # 2) expand extname if no extname and config present
132
+
133
+ new_args = []
134
+ args.each do |arg|
135
+ new_arg = find_config_path( arg )
136
+ if new_arg.nil?
137
+ # skip for now
138
+ else
139
+ new_args << new_arg
140
+ end
141
+ end
142
+ new_args
143
+
144
+ end # method expand_config_args
145
+
146
+
67
147
 
68
148
  ## "global" options (switches/flags)
69
149
 
@@ -99,18 +179,10 @@ command [:merge, :m] do |c|
99
179
  c.action do |g,o,args|
100
180
  logger.debug 'hello from merge command'
101
181
 
102
- if args.length == 0
103
- if File.exists?( 'pluto.yml' ) # check if pluto.yml exists, if yes add/use it
104
- args = ['pluto.yml'] # create a new args w/ one item
105
- elsif File.exists?( 'planet.yml' ) # check if planet.yml exists, if yes add/use it
106
- args = ['planet.yml'] # create a new args w/ one item
107
- else
108
- puts '*** note: no arg passed in; no pluto.yml or planet.yml found in working folder'
109
- end
110
- end
182
+ args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
111
183
 
112
184
  args.each do |arg|
113
- name = File.basename( arg, '.*' )
185
+ name = File.basename( arg, '.*' )
114
186
 
115
187
  #####
116
188
  # todo: add into method for reuse for build/merge/fetch
@@ -120,16 +192,10 @@ command [:merge, :m] do |c|
120
192
  adapter: 'sqlite3',
121
193
  database: "#{opts.output_path}/#{name}.db"
122
194
  }
123
-
124
- Pluto::Connecter.new.connect!( db_config )
125
195
 
126
- config_path = arg.dup # add .yml file extension if missing (for convenience)
127
- config_path << '.yml' unless config_path.ends_with?( '.yml' )
196
+ Pluto::Connecter.new.connect!( db_config )
128
197
 
129
- config = YAML.load_file( config_path )
130
-
131
- puts "dump >#{config_path}<:"
132
- pp config
198
+ config = load_config( arg )
133
199
 
134
200
  Pluto::Formatter.new( opts, config ).run( name )
135
201
  end
@@ -147,18 +213,10 @@ command [:fetch, :f] do |c|
147
213
  c.action do |g,o,args|
148
214
  logger.debug 'hello from fetch command'
149
215
 
150
- if args.length == 0
151
- if File.exists?( 'pluto.yml' ) # check if pluto.yml exists, if yes add/use it
152
- args = ['pluto.yml'] # create a new args w/ one item
153
- elsif File.exists?( 'planet.yml' ) # check if planet.yml exists, if yes add/use it
154
- args = ['planet.yml'] # create a new args w/ one item
155
- else
156
- puts '*** note: no arg passed in; no pluto.yml or planet.yml found in working folder'
157
- end
158
- end
216
+ args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
159
217
 
160
218
  args.each do |arg|
161
- name = File.basename( arg, '.*' )
219
+ name = File.basename( arg, '.*' )
162
220
 
163
221
  #####
164
222
  # todo: add into method for reuse for build/merge/fetch
@@ -168,18 +226,12 @@ command [:fetch, :f] do |c|
168
226
  adapter: 'sqlite3',
169
227
  database: "#{opts.output_path}/#{name}.db"
170
228
  }
171
-
229
+
172
230
  Pluto::Connecter.new.connect!( db_config )
173
231
 
174
- config_path = arg.dup # add .yml file extension if missing (for convenience)
175
- config_path << '.yml' unless config_path.ends_with?( '.yml' )
232
+ config = load_config( arg )
176
233
 
177
- config = YAML.load_file( config_path )
178
-
179
- puts "dump >#{config_path}<:"
180
- pp config
181
-
182
- Pluto::Fetcher.new( opts, config ).run
234
+ Pluto::Updater.new( opts, config ).run
183
235
  end
184
236
 
185
237
  puts 'Done.'
@@ -206,38 +258,22 @@ command [:build, :b] do |c|
206
258
  c.action do |g,o,args|
207
259
  logger.debug 'hello from build command'
208
260
 
209
- if args.length == 0
210
- if File.exists?( 'pluto.yml' ) # check if pluto.yml exists, if yes add/use it
211
- args = ['pluto.yml'] # create a new args w/ one item
212
- elsif File.exists?( 'planet.yml' ) # check if planet.yml exists, if yes add/use it
213
- args = ['planet.yml'] # create a new args w/ one item
214
- else
215
- puts '*** note: no arg passed in; no pluto.yml or planet.yml found in working folder'
216
- end
217
- end
261
+ args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
218
262
 
219
263
  args.each do |arg|
264
+ name = File.basename( arg, '.*' )
220
265
 
221
- name = File.basename( arg, '.*' )
222
-
223
266
  db_config = {
224
267
  adapter: 'sqlite3',
225
268
  database: "#{opts.output_path}/#{name}.db"
226
269
  }
227
-
270
+
228
271
  Pluto::Connecter.new.connect!( db_config )
229
272
 
230
- config_path = arg.dup # add .yml file extension if missing (for convenience)
231
- config_path << '.yml' unless config_path.ends_with?( '.yml' )
273
+ config = load_config( arg )
232
274
 
233
- config = YAML.load_file( config_path )
234
-
235
- puts "dump >#{config_path}<:"
236
- pp config
237
-
238
- Pluto::Fetcher.new( opts, config ).run
275
+ Pluto::Updater.new( opts, config ).run
239
276
  Pluto::Formatter.new( opts, config ).run( name )
240
-
241
277
  end
242
278
 
243
279
  puts 'Done.'
data/lib/pluto/fetcher.rb CHANGED
@@ -3,26 +3,8 @@ module Pluto
3
3
 
4
4
  class Fetcher
5
5
 
6
- include LogUtils::Logging
7
-
8
- def initialize( opts, config )
9
- @opts = opts
10
- @config = config
11
- end
12
-
13
- attr_reader :opts, :config
14
-
15
-
16
- def run
17
- updater = Updater.new
18
-
19
- # pass along debug/verbose setting/switch
20
- updater.debug = true if opts.verbose?
21
-
22
- updater.update_subscriptions( config )
23
- updater.update_feeds
24
- end # method run
25
-
6
+ ## todo: add fetch_feed machinery here
7
+ # now in refresher
26
8
 
27
9
  end # class Fetcher
28
10