Sha256: 25588efbc211f880a0b0f5eaf85338e756f14215a37a00a536da81db41a2ecde

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

module Oci8Simple
  class Show
    include Command
    
    TYPES={
      "functions" =>  "Function",
      "packages"  =>  "Package",
      "procedures" => "Procedure",
      "sequences" =>  "Sequence",
      "synonyms"  =>  "Synonym",
      "tables" =>     "Table",
      "types" =>      "Type",
      "views" =>      "View"
    }
    
    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
    
    def initialize(env=nil)
      @env = env || "development"
    end
    
    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
    
    def self.usage
      <<-STR
Usage: #{$0} TYPE [ENVIRONMENT]

TYPE is one of: #{TYPES.keys.sort.join(", ")}
STR
    end
    
    private
    
    def client
      @client ||= Oci8Simple::Client.new(@env)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
oci8_simple-0.9.2 lib/oci8_simple/show.rb
oci8_simple-0.9.1 lib/oci8_simple/show.rb
oci8_simple-0.9.0 lib/oci8_simple/show.rb
oci8_simple-0.8.5 lib/oci8_simple/show.rb
oci8_simple-0.8.4 lib/oci8_simple/show.rb
oci8_simple-0.8.3 lib/oci8_simple/show.rb
oci8_simple-0.8.2 lib/oci8_simple/show.rb
oci8_simple-0.8.1 lib/oci8_simple/show.rb
oci8_simple-0.8.0 lib/oci8_simple/show.rb
oci8_simple-0.7.0 lib/oci8_simple/show.rb
oci8_simple-0.6.1 lib/oci8_simple/show.rb
oci8_simple-0.6.0 lib/oci8_simple/show.rb