Class: Oraora::Meta::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/oraora/meta/database.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_oci(oci) ⇒ Object



10
11
12
# File 'lib/oraora/meta/database.rb', line 10

def self.from_oci(oci)
  new.load_from_oci(oci)
end

Instance Method Details

#describe(options = {}) ⇒ Object



14
15
16
17
18
19
# File 'lib/oraora/meta/database.rb', line 14

def describe(options = {})
  "    Database \#{@name}\n    Created:      \#{@created}\n  HERE\nend\n".reset_indentation

#list(options = {}, filter = nil) ⇒ Object



21
22
23
24
# File 'lib/oraora/meta/database.rb', line 21

def list(options = {}, filter = nil)
  schemas = @schemas.select! { |o| o =~ /^#{Regexp.escape(filter).gsub('\*', '.*').gsub('\?', '.')}$/ } if filter
  schemas || @schemas
end

#load_from_oci(oci) ⇒ Object



4
5
6
7
8
# File 'lib/oraora/meta/database.rb', line 4

def load_from_oci(oci)
  @name, @created = oci.select_one("SELECT name, created FROM v$database")
  @schemas = oci.pluck_one("SELECT username FROM all_users ORDER BY username")
  self
end