Class: SchemaDoc::Runner
- Inherits:
-
Object
- Object
- SchemaDoc::Runner
- Includes:
- LogUtils::Logging
- Defined in:
- lib/schemadoc/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.
19 20 21 |
# File 'lib/schemadoc/cli/runner.rb', line 19 def opts @opts end |
Instance Method Details
#run(args) ⇒ Object
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 93 94 95 |
# File 'lib/schemadoc/cli/runner.rb', line 25 def run( args ) opt=OptionParser.new do |cmd| cmd. = "Usage: schemadoc [options]" cmd.on( '-o', '--output PATH', "Output path (default is '#{opts.output_path}')" ) do |s| opts.output_path = s end # todo: find different letter for debug trace switch (use v for version?) cmd.on( '-v', '--verbose', 'Show debug trace' ) do logger = LogUtils::Logger.root logger.level = :debug end usage =<<EOS schemadoc #{VERSION} - Lets you document your database tables, columns, etc. #{cmd.help} Examples: schemadoc schemadoc football.yml Further information: https://github.com/rubylibs/schemadoc EOS ## todo: also add -? if possible as alternative cmd.on_tail( '-h', '--help', 'Show this message' ) do puts usage exit end end opt.parse!( args ) puts SchemaDoc. arg = args[0] || './schemadoc.yml' config = YAML.load_file( arg ) pp config ## check for .rb file w/ same name but .rb extension ## require/load if present boot_path = arg.sub( '.yml', '.rb' ) if File.exists?( boot_path ) puts "try to boot (load) '#{boot_path}'..." ## note: for now always add ./ current workdir ## fix - check if path is absolute; if not only add ./ current if not absolute require "./#{boot_path}" puts 'ok' end if defined?(MODELS) models = MODELS models.each do |model| # double check model classes if present (loaded) puts "#{model.name}... ok" end else models = [] end worker = Worker.new( config, models ).run puts 'Done.' end |