pluto 1.2.3 → 1.3.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: 2a1333bbf4d46791b54f5b77b96d86dbaffcf3a4
4
- data.tar.gz: 09d431c970583c027818e707f0f9a24791276fc5
3
+ metadata.gz: 12c68dae2b3404d2b6bfb5e90d65988a817e05f0
4
+ data.tar.gz: 63865f5cb4df9d9fa5a6757bc68cdcb895efc732
5
5
  SHA512:
6
- metadata.gz: c08d13ddf9fe2255d639353319687e3d8cc50df12b8d74dee0a162811775acc744929025bbb861f3606234c532e08baa333650cbd2ffd681a429bc3ae73420b9
7
- data.tar.gz: 4ea0263e98596344b7a66d5c7c9d47e659f79b656c4a474d021c0af826ef8360239a4c56091f67c9c09a487ca1e559ade1115ecb9534d630f34fdf9f8d53701f
6
+ metadata.gz: a2c924baf3e216458ccf3ce8f4234a91a791d3c58f6759fff098681671da13ad07fa93011f7c3fa9c50c6688ce33e5054770f09075ad53df654d5767c023a366
7
+ data.tar.gz: 9bbb372a6a0804b804d4eebe3e12e71915d5a9d6d3d244c1fa4674b3c7bffcb05dd05c5ef5cb382b977c1c2f67a816b0c49fca72f4363e75435a8c281f45e6e0
@@ -1,11 +1,11 @@
1
- HISTORY.md
2
- Manifest.txt
3
- README.md
4
- Rakefile
5
- bin/pluto
6
- lib/pluto.rb
7
- lib/pluto/cli/main.rb
8
- lib/pluto/cli/opts.rb
9
- lib/pluto/cli/sysinfo.rb
10
- lib/pluto/cli/updater.rb
11
- lib/pluto/cli/version.rb
1
+ HISTORY.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ bin/pluto
6
+ lib/pluto.rb
7
+ lib/pluto/cli/main.rb
8
+ lib/pluto/cli/opts.rb
9
+ lib/pluto/cli/sysinfo.rb
10
+ lib/pluto/cli/updater.rb
11
+ lib/pluto/cli/version.rb
data/README.md CHANGED
@@ -8,12 +8,12 @@ from published web feeds.
8
8
  * gem :: [rubygems.org/gems/pluto](https://rubygems.org/gems/pluto)
9
9
  * rdoc :: [rubydoc.info/gems/pluto](http://rubydoc.info/gems/pluto)
10
10
  * templates :: [github.com/planet-templates](https://github.com/planet-templates)
11
- * forum :: [groups.google.com/group/feedreader](http://groups.google.com/group/feedreader)
11
+ * forum :: [groups.google.com/group/wwwmake](http://groups.google.com/group/wwwmake)
12
12
 
13
13
 
14
14
  ## Usage
15
15
 
16
- ~~~~
16
+ ```
17
17
  NAME
18
18
  pluto - another planet generator - lets you build web pages from published web feeds
19
19
 
@@ -35,12 +35,12 @@ COMMANDS
35
35
  merge, m - Merge planet template pack
36
36
  about, a - (Debug) Show more version info
37
37
  help - Shows a list of commands or help for one command
38
- ~~~~
38
+ ```
39
39
 
40
40
 
41
41
  #### `build` Command
42
42
 
43
- ~~~
43
+ ```
44
44
  NAME
45
45
  build - Build planet
46
46
 
@@ -51,20 +51,20 @@ COMMAND OPTIONS
51
51
  -o, --output=PATH - Output Path (default: .)
52
52
  -t, --template=MANIFEST - Template Manifest (default: blank)
53
53
  -d, --dbpath=PATH - Database path (default: .)
54
- -n, --dbname=NAME - Database name (default: <PLANET>.db e.g. ruby.db)
54
+ -n, --dbname=NAME - Database name (default: planet.db)
55
55
 
56
56
  EXAMPLE
57
57
  pluto build ruby.ini
58
58
  pluto build ruby.ini --template news
59
- pluto b ruby
60
- pluto b ruby -t news
61
- pluto b # will use pluto.ini|pluto.yml|planet.ini|planet.yml if present
62
- ~~~
59
+ pluto b ruby.ini
60
+ pluto b ruby.ini -t news
61
+ pluto b # will use planet.ini if present
62
+ ```
63
63
 
64
64
 
65
65
  #### `list` Command
66
66
 
67
- ~~~
67
+ ```
68
68
  NAME
69
69
  list - List installed template packs
70
70
 
@@ -74,12 +74,12 @@ SYNOPSIS
74
74
  EXAMPLE
75
75
  pluto list
76
76
  pluto ls
77
- ~~~
77
+ ```
78
78
 
79
79
 
80
80
  #### `install` Command
81
81
 
82
- ~~~
82
+ ```
83
83
  NAME
84
84
  install - Install template pack
85
85
 
@@ -88,31 +88,31 @@ SYNOPSIS
88
88
 
89
89
  EXAMPLE
90
90
  pluto install news # install "river of news" template pack
91
- ~~~
91
+ ```
92
92
 
93
93
 
94
94
  #### `update` Command
95
95
 
96
- ~~~
96
+ ```
97
97
  NAME
98
98
  update - Update planet feeds
99
99
 
100
100
  COMMAND OPTIONS
101
101
  -d, --dbpath=PATH - Database path (default: .)
102
- -n, --dbname=NAME - Database name (default: <PLANET>.db e.g. ruby.db)
102
+ -n, --dbname=NAME - Database name (default: planet.db)
103
103
 
104
104
  SYNOPSIS
105
105
  pluto [global options] update FILE
106
106
 
107
107
  EXAMPLE
108
108
  pluto update ruby.ini
109
- pluto u ruby
110
- ~~~
109
+ pluto u ruby.ini
110
+ ```
111
111
 
112
112
 
113
113
  #### `merge` Command
114
114
 
115
- ~~~
115
+ ```
116
116
  NAME
117
117
  merge - Merge planet template pack
118
118
 
@@ -123,14 +123,14 @@ COMMAND OPTIONS
123
123
  -o, --output=PATH - Output Path (default: .)
124
124
  -t, --template=MANIFEST - Template Manifest (default: blank)
125
125
  -d, --dbpath=PATH - Database path (default: .)
126
- -n, --dbname=NAME - Database name (default: <PLANET>.db e.g. ruby.db)
126
+ -n, --dbname=NAME - Database name (default: planet.db)
127
127
 
128
128
  EXAMPLE
129
129
  pluto merge ruby.ini
130
130
  pluto merge ruby.ini --template news
131
- pluto m ruby
132
- pluto m ruby -t news
133
- ~~~
131
+ pluto m ruby.ini
132
+ pluto m ruby.ini -t news
133
+ ```
134
134
 
135
135
 
136
136
  ## Install
@@ -142,10 +142,12 @@ Just install the gem:
142
142
 
143
143
  ## License
144
144
 
145
+ ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
146
+
145
147
  The `pluto` scripts are dedicated to the public domain.
146
148
  Use it as you please with no restrictions whatsoever.
147
149
 
148
150
  ## Questions? Comments?
149
151
 
150
- Send them along to the [Planet Pluto and Friends Forum/Mailing List](http://groups.google.com/group/feedreader).
152
+ Send them along to the [wwwmake Forum/Mailing List](http://groups.google.com/group/wwwmake).
151
153
  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 = 'feedreader@googlegroups.com'
14
+ self.email = 'wwwmake@googlegroups.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
data/bin/pluto CHANGED
File without changes
@@ -1,411 +1,381 @@
1
- # encoding: utf-8
2
-
3
- require 'gli'
4
-
5
-
6
- include GLI::App
7
-
8
- program_desc 'another planet generator (lets you build web pages from published web feeds)'
9
- version PlutoCli::VERSION
10
-
11
-
12
- ## some setup code
13
-
14
- LogUtils::Logger.root.level = :info # set logging level to info
15
-
16
- logger = LogUtils::Logger.root
17
-
18
-
19
- opts = Pluto::Opts.new
20
-
21
-
22
-
23
- ######
24
- # begin
25
- # move to pluto for reuse (e.g. in rakefile)
26
-
27
- def load_config( name )
28
- config = INI.load_file( name )
29
-
30
- puts "dump >#{name}<:"
31
- pp config
32
-
33
- config
34
- end
35
-
36
-
37
- def find_default_config_path
38
- candidates = [ 'pluto.ini',
39
- 'planet.ini'
40
- ]
41
-
42
- candidates.each do |candidate|
43
- return candidate if File.exists?( candidate ) ## todo: use ./candidate -- why? why not??
44
- end
45
-
46
- puts "*** note: no default planet configuration found, that is, no #{candidates.join('|')} found in working folder"
47
- nil # return nil; no conifg existing candidate found/present; sorry
48
- end
49
-
50
-
51
- def find_config_path( name )
52
- extname = File.extname( name ) # return '' or '.ini' or '.conf' or '.cfg' or '.txt -???' etc.
53
-
54
- return name if extname.present? # nothing to do; extension already present
55
-
56
- candidates = [ '.ini' ]
57
-
58
- candidates.each do |candidate|
59
- return "#{name}#{candidate}" if File.exists?( "#{name}#{candidate}" )
60
- end
61
-
62
- # no extensions matching; sorry
63
- puts "*** note: no configuration found w/ extensions #{candidates.join('|')} for '#{name}'"
64
- # todo/check/fix - ?? -skip; remove from arg - or just pass through ???
65
- nil # return nil; no config found/present; sorry
66
- end
67
-
68
- # end
69
- # move to pluto for reuse (e.g. in rakefile)
70
- ###########################
71
-
72
-
73
-
74
- def expand_config_args( args )
75
-
76
- # 1) no args - try to find default config e.g. pluto.ini etc.
77
- if args.length == 0
78
- new_arg = find_default_config_path
79
-
80
- return [] if new_arg.nil?
81
- return [new_arg] # create a new args w/ one item e.g. ['pluto.yml']
82
- end
83
-
84
- # 2) expand extname if no extname and config present
85
-
86
- new_args = []
87
- args.each do |arg|
88
- new_arg = find_config_path( arg )
89
- if new_arg.nil?
90
- # skip for now
91
- else
92
- new_args << new_arg
93
- end
94
- end
95
- new_args
96
-
97
- end # method expand_config_args
98
-
99
-
100
-
101
- ## "global" options (switches/flags)
102
-
103
- desc '(Debug) Show debug messages'
104
- switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
105
-
106
- desc 'Only show warnings, errors and fatal messages'
107
- switch [:q, :quiet], negatable: false
108
-
109
-
110
- desc 'Configuration Path'
111
- arg_name 'PATH'
112
- default_value opts.config_path
113
- flag [:c, :config]
114
-
115
-
116
- ### note: mostly for debugging lets you fetch individual feeds
117
- desc 'Fetch feeds'
118
- arg_name 'FEED', multiple: true ## todo/fix: check multiple will not print typeo???
119
- command [:fetch, :f] do |c|
120
-
121
- c.desc 'Database path'
122
- c.arg_name 'PATH'
123
- c.default_value opts.db_path
124
- c.flag [:d, :dbpath]
125
-
126
- c.desc 'Database name'
127
- c.arg_name 'NAME'
128
- c.default_value opts.db_name
129
- c.flag [:n, :dbname]
130
-
131
- c.action do |g,o,args|
132
- logger.debug 'hello from fetch command'
133
-
134
- ## turn on debug flag by default; no need to passing --verbose
135
- LogUtils::Logger.root.level = :debug
136
- opts.verbose = true
137
-
138
- # add dbname as opts property
139
-
140
- #####
141
- # todo: add into method for reuse for build/merge/fetch
142
- # all use the same code
143
-
144
- db_config = {
145
- adapter: 'sqlite3',
146
- database: "#{opts.db_path}/#{opts.db_name}"
147
- }
148
-
149
- Pluto.connect( db_config )
150
-
151
- args.each do |arg|
152
- feed_rec = Pluto::Model::Feed.find_by_key!( arg )
153
-
154
- puts "feed_rec:"
155
- pp feed_rec
156
-
157
- fetcher = Pluto::FeedFetcherBasic.new
158
- fetcher.debug = true # by default debug is true (only used for debuggin! - save feed to file, etc.)
159
-
160
- feed = fetcher.fetch( feed_rec )
161
- ## pp feed
162
- end
163
-
164
- puts 'Done.'
165
- end
166
- end # command fetch
167
-
168
-
169
-
170
- ## note: same as build (but without step 1) fetch)
171
- desc 'Merge planet template pack'
172
- arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
173
- command [:merge, :m] do |c|
174
-
175
- c.desc 'Output Path'
176
- c.arg_name 'PATH'
177
- c.default_value opts.output_path
178
- c.flag [:o,:output]
179
-
180
- c.desc 'Template Manifest'
181
- c.arg_name 'MANIFEST'
182
- c.default_value opts.manifest
183
- c.flag [:t, :template]
184
-
185
- c.desc 'Database path'
186
- c.arg_name 'PATH'
187
- c.default_value opts.db_path
188
- c.flag [:d, :dbpath]
189
-
190
- c.desc 'Database name'
191
- c.arg_name 'NAME'
192
- c.flag [:n, :dbname]
193
-
194
-
195
- c.action do |g,o,args|
196
- logger.debug 'hello from merge command'
197
-
198
- args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
199
-
200
- args.each do |arg|
201
- name = File.basename( arg, '.*' )
202
-
203
- #####
204
- # todo: add into method for reuse for build/merge/fetch
205
- # all use the same code
206
-
207
- db_name = opts.db_name? ? opts.db_name : "#{name}.db"
208
-
209
- db_config = {
210
- adapter: 'sqlite3',
211
- database: "#{opts.db_path}/#{db_name}"
212
- }
213
-
214
- Pluto.connect( db_config )
215
-
216
- config = load_config( arg )
217
-
218
- Pluto::Formatter.new( opts, config ).run( name )
219
- end
220
-
221
- puts 'Done.'
222
- end
223
- end # command merge
224
-
225
-
226
- ## note: same as build (but without step 2) merge)
227
- desc 'Update planet feeds'
228
- arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
229
- command [:update, :up, :u] do |c|
230
-
231
- c.desc 'Database path'
232
- c.arg_name 'PATH'
233
- c.default_value opts.db_path
234
- c.flag [:d, :dbpath]
235
-
236
- c.desc 'Database name'
237
- c.arg_name 'NAME'
238
- c.flag [:n, :dbname]
239
-
240
-
241
- c.action do |g,o,args|
242
- logger.debug 'hello from update command'
243
-
244
- args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
245
-
246
- args.each do |arg|
247
- name = File.basename( arg, '.*' )
248
-
249
- #####
250
- # todo: add into method for reuse for build/merge/fetch
251
- # all use the same code
252
-
253
- db_name = opts.db_name? ? opts.db_name : "#{name}.db"
254
-
255
- db_config = {
256
- adapter: 'sqlite3',
257
- database: "#{opts.db_path}/#{db_name}"
258
- }
259
-
260
- # Note: use ! version w/ auto-migrate! - why? why not??
261
- ## just use regular connect??
262
- Pluto.connect!( db_config )
263
-
264
- config = load_config( arg )
265
-
266
- Pluto::Updater.new( opts, config ).run( name )
267
- end
268
-
269
- puts 'Done.'
270
- end
271
- end # command fetch
272
-
273
-
274
-
275
- desc 'Build planet'
276
- arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
277
- command [:build, :b] do |c|
278
-
279
- c.desc 'Output Path'
280
- c.arg_name 'PATH'
281
- c.default_value opts.output_path
282
- c.flag [:o,:output]
283
-
284
- c.desc 'Template Manifest'
285
- c.arg_name 'MANIFEST'
286
- c.default_value opts.manifest
287
- c.flag [:t, :template]
288
-
289
- c.desc 'Database path'
290
- c.arg_name 'PATH'
291
- c.default_value opts.db_path
292
- c.flag [:d, :dbpath]
293
-
294
- c.desc 'Database name'
295
- c.arg_name 'NAME'
296
- c.flag [:n, :dbname]
297
-
298
-
299
- c.action do |g,o,args|
300
- logger.debug 'hello from build command'
301
-
302
- args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
303
-
304
- args.each do |arg|
305
- name = File.basename( arg, '.*' )
306
-
307
- db_name = opts.db_name? ? opts.db_name : "#{name}.db"
308
-
309
- db_config = {
310
- adapter: 'sqlite3',
311
- database: "#{opts.db_path}/#{db_name}"
312
- }
313
-
314
- # Note: use ! version w/ auto-migrate!
315
- Pluto.connect!( db_config )
316
-
317
- config = load_config( arg )
318
-
319
- Pluto::Updater.new( opts, config ).run( name )
320
- Pluto::Formatter.new( opts, config ).run( name )
321
- end
322
-
323
- puts 'Done.'
324
- end
325
- end # command build
326
-
327
-
328
- desc 'List installed template packs'
329
- command [:list,:ls,:l] do |c|
330
-
331
- c.action do |g,o,args|
332
- logger.debug 'hello from list command'
333
-
334
- Pluto::Lister.new( opts ).list
335
- end
336
- end
337
-
338
-
339
- desc 'Install template pack'
340
- arg_name 'MANIFEST', multiple: true
341
- command [:install,:i] do |c|
342
-
343
- c.action do |g,o,args|
344
- logger.debug 'hello from install command'
345
-
346
- args.each do |arg|
347
- Pluto::Installer.new( opts ).install( arg ) ## todo: remove opts merge into config
348
- end
349
- end
350
- end
351
-
352
-
353
- desc '(Debug) Show more version info'
354
- skips_pre
355
- command [:about,:a] do |c|
356
- c.action do
357
- logger.debug 'hello from about command'
358
-
359
- Pluto::SysInfo.new( opts ).dump
360
- end
361
- end
362
-
363
-
364
- desc '(Debug) Show global options, options, arguments for test command'
365
- command :test do |c|
366
- c.action do |g,o,args|
367
- puts 'hello from test command'
368
- puts 'g/global_options:'
369
- pp g
370
- puts 'o/options:'
371
- pp o
372
- puts 'args:'
373
- pp args
374
- end
375
- end
376
-
377
-
378
-
379
- pre do |g,c,o,args|
380
- opts.merge_gli_options!( g )
381
- opts.merge_gli_options!( o )
382
-
383
- puts PlutoCli.banner
384
-
385
- LogUtils::Logger.root.level = :debug if opts.verbose?
386
-
387
- logger.debug " executing command #{c.name}"
388
- true
389
- end
390
-
391
-
392
- post do |global,c,o,args|
393
- logger.debug " executed command #{c.name}"
394
- true
395
- end
396
-
397
-
398
- on_error do |e|
399
- puts
400
- puts "*** error: #{e.message}"
401
- puts
402
-
403
- ## todo/fix: find a better way to print; just raise exception e.g. raise e - why? why not??
404
- ## puts e.backtrace.inspect if opts.verbose?
405
- raise e if opts.verbose?
406
-
407
- false # skip default error handling
408
- end
409
-
410
-
411
- exit run(ARGV)
1
+ # encoding: utf-8
2
+
3
+ require 'gli'
4
+
5
+
6
+ include GLI::App
7
+
8
+ program_desc 'another planet generator (lets you build web pages from published web feeds)'
9
+ version PlutoCli::VERSION
10
+
11
+
12
+ ## some setup code
13
+
14
+ LogUtils::Logger.root.level = :info # set logging level to info
15
+
16
+ logger = LogUtils::Logger.root
17
+
18
+
19
+ opts = Pluto::Opts.new
20
+
21
+
22
+
23
+ ######
24
+ # begin
25
+ # move to pluto for reuse (e.g. in rakefile)
26
+
27
+ def load_config( name )
28
+ config = INI.load_file( name )
29
+ config
30
+ end
31
+
32
+ # end
33
+ # move to pluto for reuse (e.g. in rakefile)
34
+ ###########################
35
+
36
+
37
+
38
+
39
+ ## "global" options (switches/flags)
40
+
41
+ desc '(Debug) Show debug messages'
42
+ switch [:verbose, :debug], negatable: false
43
+
44
+
45
+ ## todo/check:
46
+ ## use quiet (warn) and quieter (error) - why? why not?
47
+ ## use quiet for warn level (not error) as default - why? why not?
48
+
49
+ desc 'Only show errors and fatal messages'
50
+ switch [:q, :quiet, :err, :error], negatable: false
51
+
52
+ desc 'Only show warnings, errors and fatal messages'
53
+ switch [:w, :warn], negatable: false
54
+
55
+
56
+
57
+ desc 'Configuration Path'
58
+ arg_name 'PATH'
59
+ default_value opts.config_path
60
+ flag [:c, :config]
61
+
62
+
63
+ ### note: mostly for debugging lets you fetch individual feeds
64
+ desc 'Fetch feeds'
65
+ arg_name 'FEED', multiple: true ## todo/fix: check multiple will not print typeo???
66
+ command [:fetch, :f] do |c|
67
+
68
+ c.desc 'Database path'
69
+ c.arg_name 'PATH'
70
+ c.default_value opts.db_path
71
+ c.flag [:d, :dbpath]
72
+
73
+ c.desc 'Database name'
74
+ c.arg_name 'NAME'
75
+ c.default_value opts.db_name
76
+ c.flag [:n, :dbname]
77
+
78
+ c.action do |g,o,args|
79
+ logger.debug 'hello from fetch command'
80
+
81
+ ## turn on debug flag by default; no need to passing --verbose
82
+ LogUtils::Logger.root.level = :debug
83
+ opts.verbose = true
84
+
85
+ # add dbname as opts property
86
+
87
+ #####
88
+ # todo: add into method for reuse for build/merge/fetch
89
+ # all use the same code
90
+
91
+ db_config = {
92
+ adapter: 'sqlite3',
93
+ database: "#{opts.db_path}/#{opts.db_name}"
94
+ }
95
+
96
+ Pluto.connect( db_config )
97
+
98
+ args.each do |arg|
99
+ feed_rec = Pluto::Model::Feed.find_by_key!( arg )
100
+
101
+ puts "feed_rec:"
102
+ pp feed_rec
103
+
104
+ fetcher = Pluto::FeedFetcherBasic.new
105
+ fetcher.debug = true # by default debug is true (only used for debuggin! - save feed to file, etc.)
106
+
107
+ feed = fetcher.fetch( feed_rec )
108
+ ## pp feed
109
+ end
110
+
111
+ puts 'Done.'
112
+ end
113
+ end # command fetch
114
+
115
+
116
+
117
+ ## note: same as build (but without step 1) fetch)
118
+ desc 'Merge planet template pack'
119
+ arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
120
+ command [:merge, :m] do |c|
121
+
122
+ c.desc 'Output Path'
123
+ c.arg_name 'PATH'
124
+ c.default_value opts.output_path
125
+ c.flag [:o,:output]
126
+
127
+ c.desc 'Template Manifest'
128
+ c.arg_name 'MANIFEST'
129
+ c.default_value opts.manifest
130
+ c.flag [:t, :template]
131
+
132
+ c.desc 'Database path'
133
+ c.arg_name 'PATH'
134
+ c.default_value opts.db_path
135
+ c.flag [:d, :dbpath]
136
+
137
+ c.desc 'Database name'
138
+ c.arg_name 'NAME'
139
+ c.flag [:n, :dbname]
140
+
141
+
142
+ c.action do |g,o,args|
143
+ logger.debug 'hello from merge command'
144
+
145
+ ## note: no more "magic" - remove expand_config_args!! - always pass in planet.ini or similar
146
+ ## args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
147
+
148
+ args.each do |arg|
149
+ name = File.basename( arg, '.*' )
150
+
151
+ #####
152
+ # todo: add into method for reuse for build/merge/fetch
153
+ # all use the same code
154
+
155
+ db_name = opts.db_name? ? opts.db_name : "#{name}.db"
156
+
157
+ db_config = {
158
+ adapter: 'sqlite3',
159
+ database: "#{opts.db_path}/#{db_name}"
160
+ }
161
+
162
+ Pluto.connect( db_config )
163
+
164
+ config = load_config( arg )
165
+ if opts.verbose?
166
+ puts "dump >#{name}<:"
167
+ pp config
168
+ end
169
+
170
+ Pluto::Formatter.new( opts, config ).run( name )
171
+ end
172
+
173
+ puts 'Done.'
174
+ end
175
+ end # command merge
176
+
177
+
178
+ ## note: same as build (but without step 2) merge)
179
+ desc 'Update planet feeds'
180
+ arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
181
+ command [:update, :up, :u] do |c|
182
+
183
+ c.desc 'Database path'
184
+ c.arg_name 'PATH'
185
+ c.default_value opts.db_path
186
+ c.flag [:d, :dbpath]
187
+
188
+ c.desc 'Database name'
189
+ c.arg_name 'NAME'
190
+ c.flag [:n, :dbname]
191
+
192
+
193
+ c.action do |g,o,args|
194
+ logger.debug 'hello from update command'
195
+
196
+ ## note: no more "magic" - remove expand_config_args!! - always pass in planet.ini or similar
197
+ ## args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
198
+
199
+ args.each do |arg|
200
+ name = File.basename( arg, '.*' )
201
+
202
+ #####
203
+ # todo: add into method for reuse for build/merge/fetch
204
+ # all use the same code
205
+
206
+ db_name = opts.db_name? ? opts.db_name : "#{name}.db"
207
+
208
+ db_config = {
209
+ adapter: 'sqlite3',
210
+ database: "#{opts.db_path}/#{db_name}"
211
+ }
212
+
213
+ # Note: use ! version w/ auto-migrate! - why? why not??
214
+ ## just use regular connect??
215
+ Pluto.connect!( db_config )
216
+
217
+ config = load_config( arg )
218
+ if opts.verbose?
219
+ puts "dump >#{name}<:"
220
+ pp config
221
+ end
222
+
223
+ Pluto::Updater.new( opts, config ).run( name )
224
+ end
225
+
226
+ puts 'Done.'
227
+ end
228
+ end # command fetch
229
+
230
+
231
+
232
+ desc 'Build planet'
233
+ arg_name 'FILE', multiple: true ## todo/fix: check multiple will not print typeo???
234
+ command [:build, :b] do |c|
235
+
236
+ c.desc 'Output Path'
237
+ c.arg_name 'PATH'
238
+ c.default_value opts.output_path
239
+ c.flag [:o,:output]
240
+
241
+ c.desc 'Template Manifest'
242
+ c.arg_name 'MANIFEST'
243
+ c.default_value opts.manifest
244
+ c.flag [:t, :template]
245
+
246
+ c.desc 'Database path'
247
+ c.arg_name 'PATH'
248
+ c.default_value opts.db_path
249
+ c.flag [:d, :dbpath]
250
+
251
+ c.desc 'Database name'
252
+ c.arg_name 'NAME'
253
+ c.flag [:n, :dbname]
254
+
255
+
256
+ c.action do |g,o,args|
257
+ logger.debug 'hello from build command'
258
+
259
+ ## note: no more "magic" - remove expand_config_args!! - always pass in planet.ini or similar
260
+ ## args = expand_config_args( args ) # add missing .ini|.yml extension if missing or add default config (e.g. pluto.ini)
261
+
262
+ args.each do |arg|
263
+ name = File.basename( arg, '.*' )
264
+
265
+ db_name = opts.db_name? ? opts.db_name : "#{name}.db"
266
+
267
+ db_config = {
268
+ adapter: 'sqlite3',
269
+ database: "#{opts.db_path}/#{db_name}"
270
+ }
271
+
272
+ # Note: use ! version w/ auto-migrate!
273
+ Pluto.connect!( db_config )
274
+
275
+ config = load_config( arg )
276
+ if opts.verbose?
277
+ puts "dump >#{name}<:"
278
+ pp config
279
+ end
280
+
281
+ Pluto::Updater.new( opts, config ).run( name )
282
+ Pluto::Formatter.new( opts, config ).run( name )
283
+ end
284
+
285
+ puts 'Done.'
286
+ end
287
+ end # command build
288
+
289
+
290
+ desc 'List installed template packs'
291
+ command [:list,:ls,:l] do |c|
292
+
293
+ c.action do |g,o,args|
294
+ logger.debug 'hello from list command'
295
+
296
+ Pluto::Lister.new( opts ).list
297
+ end
298
+ end
299
+
300
+
301
+ desc 'Install template pack'
302
+ arg_name 'MANIFEST', multiple: true
303
+ command [:install,:i] do |c|
304
+
305
+ c.action do |g,o,args|
306
+ logger.debug 'hello from install command'
307
+
308
+ args.each do |arg|
309
+ Pluto::Installer.new( opts ).install( arg ) ## todo: remove opts merge into config
310
+ end
311
+ end
312
+ end
313
+
314
+
315
+ desc '(Debug) Show more version info'
316
+ skips_pre
317
+ command [:about,:a] do |c|
318
+ c.action do
319
+ logger.debug 'hello from about command'
320
+
321
+ Pluto::SysInfo.new( opts ).dump
322
+ end
323
+ end
324
+
325
+
326
+ desc '(Debug) Show global options, options, arguments for test command'
327
+ command :test do |c|
328
+ c.action do |g,o,args|
329
+ puts 'hello from test command'
330
+ puts 'g/global_options:'
331
+ pp g
332
+ puts 'o/options:'
333
+ pp o
334
+ puts 'args:'
335
+ pp args
336
+ end
337
+ end
338
+
339
+
340
+
341
+ pre do |g,c,o,args|
342
+ opts.merge_gli_options!( g )
343
+ opts.merge_gli_options!( o )
344
+
345
+ puts PlutoCli.banner
346
+
347
+ if opts.verbose?
348
+ LogUtils::Logger.root.level = :debug
349
+ elsif opts.warn?
350
+ LogUtils::Logger.root.level = :warn
351
+ elsif opts.quiet?
352
+ LogUtils::Logger.root.level = :error
353
+ else
354
+ ## do nothing; keep :info level (default)
355
+ end
356
+
357
+ logger.debug " executing command #{c.name}"
358
+ true
359
+ end
360
+
361
+
362
+ post do |global,c,o,args|
363
+ logger.debug " executed command #{c.name}"
364
+ true
365
+ end
366
+
367
+
368
+ on_error do |e|
369
+ puts
370
+ puts "*** error: #{e.message}"
371
+ puts
372
+
373
+ ## todo/fix: find a better way to print; just raise exception e.g. raise e - why? why not??
374
+ ## puts e.backtrace.inspect if opts.verbose?
375
+ raise e if opts.verbose?
376
+
377
+ false # skip default error handling
378
+ end
379
+
380
+
381
+ exit run(ARGV)
@@ -10,10 +10,27 @@ class Opts
10
10
 
11
11
 
12
12
  def merge_gli_options!( options={} )
13
- @verbose = true if options[:verbose] == true
13
+ ###
14
+ # todo/check: renamve verbose to debug and quiet to error - why? why not?
15
+ # use a single (internal) variable for log level - why? why not?
16
+
17
+ if options[:verbose] == true ## debug level
18
+ @verbose = @warn = @quiet = true
19
+ end
20
+
21
+ if options[:warn] == true ## warn level
22
+ @warn = @quiet = true
23
+ @verbose = false
24
+ end
25
+
26
+ if options[:quiet] == true ## error level (for now) - why? why not?
27
+ @quiet = true
28
+ @verbose = @warn = false
29
+ end
30
+
14
31
 
15
32
  @db_path = options[:dbpath] if options[:dbpath].present?
16
-
33
+
17
34
  if options[:dbname].present?
18
35
  ##########
19
36
  # note: c.default_value '<PLANET>.db e.g. ruby.db'
@@ -41,20 +58,28 @@ class Opts
41
58
  def manifest=(value) @manifest = value; end
42
59
  def manifest() @manifest || 'blank' ; end
43
60
 
44
- def verbose=(value)
45
- @verbose = true # note: always assumes true for now; default is false
46
- end
47
61
 
48
- def verbose?
49
- @verbose || false
50
- end
62
+ ## # note: always assumes true for now for verbose/quiet/warn; default is false
63
+ def verbose=(value) @verbose = true; end
64
+ def verbose?() @verbose || false; end
65
+ def debug?() @verbose || false; end ## add debug? alias for verbose
66
+
67
+ def warn=(value) @warn = true; end
68
+ def warn?() @warn || false; end
69
+
70
+ def quiet=(value) @quiet = true; end ## use error/error? - why? why not?
71
+ def quiet?() @quiet || false; end
72
+ def error?() @quiet || false; end ## add error? alias for quiet
73
+
74
+
75
+
51
76
 
52
77
  def config_path=(value)
53
78
  @config_path = value
54
79
  end
55
-
80
+
56
81
  def config_path
57
- ## @config_path || '~/.pluto' --- old code
82
+ ## note: defaults to ~/.pluto
58
83
  @config_path || File.join( Env.home, '.pluto' )
59
84
  end
60
85
 
@@ -62,7 +87,7 @@ class Opts
62
87
  def output_path=(value)
63
88
  @output_path = value
64
89
  end
65
-
90
+
66
91
  def output_path
67
92
  @output_path || '.'
68
93
  end
@@ -75,10 +100,10 @@ class Opts
75
100
  def map_fetch_shortcut( key )
76
101
  # NB: always returns an array!!! 0,1 or more entries
77
102
  # - no value - return empty ary
78
-
103
+
79
104
  ## todo: normalize key???
80
105
  value = @shortcuts.fetch( key, nil )
81
-
106
+
82
107
  if value.nil?
83
108
  []
84
109
  elsif value.kind_of?( String )
@@ -10,7 +10,7 @@ class SysInfo
10
10
  def initialize( opts )
11
11
  @opts = opts
12
12
  end
13
-
13
+
14
14
  attr_reader :opts
15
15
 
16
16
 
@@ -44,7 +44,7 @@ EOS
44
44
  # dump Pluto settings
45
45
  # config.dump
46
46
  # puts
47
-
47
+
48
48
 
49
49
  ## todo: add more gem version info
50
50
  # todo: add logutils version
@@ -3,8 +3,8 @@
3
3
  module PlutoCli
4
4
 
5
5
  MAJOR = 1
6
- MINOR = 2
7
- PATCH = 3
6
+ MINOR = 3
7
+ PATCH = 0
8
8
  VERSION = [MAJOR,MINOR,PATCH].join('.')
9
9
 
10
10
  def self.version
@@ -21,4 +21,3 @@ module PlutoCli
21
21
  end
22
22
 
23
23
  end # module PlutoCli
24
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.3.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: 2015-01-18 00:00:00.000000000 Z
11
+ date: 2017-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pluto-models
@@ -114,17 +114,17 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '3.13'
117
+ version: '3.16'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '3.13'
124
+ version: '3.16'
125
125
  description: pluto - Another Planet Generator (Lets You Build Web Pages from Published
126
126
  Web Feeds)
127
- email: feedreader@googlegroups.com
127
+ email: wwwmake@googlegroups.com
128
128
  executables:
129
129
  - pluto
130
130
  extensions: []
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project:
169
- rubygems_version: 2.4.2
169
+ rubygems_version: 2.5.2
170
170
  signing_key:
171
171
  specification_version: 4
172
172
  summary: pluto - Another Planet Generator