class DBViz

Public Instance Methods

columns() click to toggle source
# File bin/dbviz, line 42
def columns
  @columns ||= tables
               .map { |t| { t => db[t].columns } }
               .reduce(&:merge)
end
config() click to toggle source
# File bin/dbviz, line 19
def config
  @config ||= YAML.load_file(config_path).symbolize_keys
end
config_path() click to toggle source
# File bin/dbviz, line 14
def config_path
  @config_path ||= ARGV.first || ENV['DBVIZ_CONFIG'] || File.expand_path('~/.config/dbviz.yaml')
end
db() click to toggle source
# File bin/dbviz, line 24
def db
  @db ||= Sequel.connect(config)
end
foreign_keys() click to toggle source
# File bin/dbviz, line 34
def foreign_keys
  @foreign_keys ||= tables
                    .map { |t| { t => db.foreign_key_list(t) } }
                    .reduce(&:merge)
                    .reject { |_, v| v.empty? }
end
interesting() click to toggle source
# File bin/dbviz, line 48
def interesting
  columns.select { |k, _| foreign_keys.keys.include? k }
end
tables() click to toggle source
# File bin/dbviz, line 29
def tables
  @tables ||= db.tables
end