Module: ModelProbe::Probes::Metadata

Included in:
ModelProbe::Probes
Defined in:
lib/model_probe/probes/metadata.rb

Instance Method Summary collapse

Instance Method Details

#probe_metadataObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/model_probe/probes/metadata.rb', line 4

def 
  puts Rainbow(name).green + Rainbow(" < ").dimgray.faint + Rainbow(superclass.name).green.faint
  puts Rainbow("  Database engine ".ljust(24, ".")).darkgray + " " + Rainbow(connection.adapter_name).skyblue.bright + " " + Rainbow(connection.database_version).skyblue.faint
  puts Rainbow("  Database name ".ljust(24, ".")).darkgray + " " + Rainbow(connection_db_config.database).skyblue
  puts Rainbow("  Table name ".ljust(24, ".")).darkgray + " " + Rainbow(table_name).skyblue
  puts Rainbow("  Default role".ljust(24, ".")).darkgray + " " + Rainbow(default_role).skyblue
  puts Rainbow("  Connection config ".ljust(24, ".")).darkgray
  connection_db_config.configuration_hash.to_yaml.split("\n")[1..].each { |line| puts "    " + Rainbow(line).skyblue.faint }
  puts
  puts Rainbow("  DDL ".ljust(24, ".")).darkgray
  if /create table/i.match?(ddl)
    ddl.split("\n").each do |line|
      line = line.squish
      next if line.blank?
      next if line.start_with?("--")
      next if line.start_with?("/*")
      next if /error|warning|Couldn't execute/i.match?(line)
      puts Rainbow("    #{line}").skyblue.faint
    end
  else
    puts Rainbow("    Failed to generate DDL string! #{ddl}").indianred
  end
end