Class: Pluto::Runner
- Inherits:
-
Object
- Object
- Pluto::Runner
- Includes:
- LogUtils::Logging, Models
- Defined in:
- lib/pluto/cli/runner.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run(args) ⇒ Object
Constructor Details
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
14 15 16 |
# File 'lib/pluto/cli/runner.rb', line 14 def opts @opts end |
Instance Method Details
#run(args) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/pluto/cli/runner.rb', line 16 def run( args ) opt=OptionParser.new do |cmd| cmd. = "Usage: pluto [options] FILE" ## fix/todo: remove .txt from default manifest cmd.on( '-t', '--template MANIFEST', "Template Manifest (default is #{opts.manifest})" ) do |manifest| opts.manifest = manifest end cmd.on( '-c', '--config PATH', "Configuration Path (default is #{opts.config_path})" ) do |path| opts.config_path = path end cmd.on( '-o', '--output PATH', "Output Path (default is #{opts.output_path})" ) { |path| opts.output_path = path } cmd.on( '-v', '--version', "Show version" ) do puts Pluto. exit end cmd.on( "--verbose", "Show debug trace" ) do LogUtils::Logger.root.level = :debug opts.verbose = true end ## todo: add/allow -? too cmd.on_tail( "-h", "--help", "Show this message" ) do puts <<EOS pluto - Lets you build web pages from published web feeds. #{cmd.help} Examples: pluto ruby Further information: https://github.com/geraldb/pluto EOS exit end end opt.parse!( args ) puts Pluto. args.each do |arg| name = File.basename( arg, '.*' ) db_config = { adapter: 'sqlite3', database: "#{opts.output_path}/#{name}.db" } Connecter.new.connect!( db_config ) config_path = arg.dup # add .yml file extension if missing (for convenience) config_path << '.yml' unless config_path.ends_with?( '.yml' ) config = YAML.load_file( config_path ) puts "dump >#{config_path}<:" pp config Fetcher.new( opts, config ).run Formatter.new( opts, config ).run( name ) end puts 'Done.' end |