Module: ActiveDesigner
- Defined in:
- lib/active_designer.rb,
lib/active_designer/file_converter.rb,
lib/active_designer/schema_creator.rb
Defined Under Namespace
Classes: FileConverter, SchemaCreator
Class Method Summary collapse
Class Method Details
.call(argv, stdin, stdout, stderr) ⇒ Object
6 7 8 9 10 11 12 13 14 15 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 |
# File 'lib/active_designer.rb', line 6 def self.call(argv,stdin,stdout,stderr) command = argv[0] if !command stderr.puts "No command was provided, use -h or --help for more information" return 1 end if command == "--help" || command == "-h" stdout.puts "To create a schema run '$ active-designer --create filepath'" stdout.puts "If youre in the root of a Sinatra or Ruby on Rails project the filepath should be './db/schema.rb'" return 0 end if command == "--create" input_path = argv[1] output_path = "active_designer/index.html" output_dir = File.dirname output_path if !input_path stderr.puts "No path was provided, use -h or --help for more information" return 1 end if !File.exist?(input_path) stderr.puts "#{input_path.inspect} does not exist, use -h or --help for more information" return 1 end Dir.mkdir output_dir unless Dir.exist?(output_dir) if File.exist?(output_path) && !overwrite?(stdin, stdout, output_path) stderr.puts "Aborted" return 1 end return create(output_path,input_path,stdout) end if command stderr.puts "#{command.inspect} is not a known command, use -h or --help for more information" return 1 end end |