Class: Oci8Simple::Show

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/oci8_simple/show.rb

Constant Summary collapse

TYPES =
{
  "functions" =>  "Function",
  "packages"  =>  "Package",
  "procedures" => "Procedure",
  "sequences" =>  "Sequence",
  "synonyms"  =>  "Synonym",
  "tables" =>     "Table",
  "types" =>      "Type",
  "views" =>      "View"
}

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

included

Constructor Details

#initialize(env = nil) ⇒ Show

Returns a new instance of Show.



22
23
24
# File 'lib/oci8_simple/show.rb', line 22

def initialize(env=nil)
  @env = env || "development"
end

Class Method Details

.run_from_argvObject



26
27
28
29
30
31
32
33
# File 'lib/oci8_simple/show.rb', line 26

def self.run_from_argv
  o = parse_options(self.usage)
  if(ARGV[0].nil? || TYPES[ARGV[0]].nil?)
    puts o
  else
    puts self.new(ARGV[1]).run(ARGV[0])
  end
end

.usageObject



35
36
37
38
39
40
41
# File 'lib/oci8_simple/show.rb', line 35

def self.usage
  <<-STR
Usage: #{$0} TYPE [ENVIRONMENT]

TYPE is one of: #{TYPES.keys.sort.join(", ")}
STR
end

Instance Method Details

#run(type) ⇒ Object



16
17
18
19
20
# File 'lib/oci8_simple/show.rb', line 16

def run(type)
  clazz = eval("OCI8::Metadata::#{TYPES[type]}")
  objects = client.send(:conn).describe_schema(client.config["username"]).all_objects.find_all{|f| f.class == clazz}
  objects.map(&:obj_name).map(&:downcase).sort
end