Class: DbMeta::Oracle::Oracle
- Includes:
- Helper
- Defined in:
- lib/db_meta/oracle/oracle.rb
Constant Summary
Constants inherited from Abstract
Instance Method Summary collapse
- #extract(args = {}) ⇒ Object
- #fetch(args = {}) ⇒ Object
-
#initialize(args = {}) ⇒ Oracle
constructor
A new instance of Oracle.
Methods included from Helper
#block, #create_folder, #pluralize, #remove_folder, #type_sequence, #write_buffer_to_file
Methods inherited from Abstract
Constructor Details
#initialize(args = {}) ⇒ Oracle
Returns a new instance of Oracle.
20 21 22 23 24 25 26 |
# File 'lib/db_meta/oracle/oracle.rb', line 20 def initialize(args = {}) super(args) Connection.instance.set(@username, @password, @instance, @worker) @objects = Objects.new end |
Instance Method Details
#extract(args = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/db_meta/oracle/oracle.rb', line 48 def extract(args = {}) format = args[:format] || :sql # validate args raise "Format [#{format}] is not supported" unless EXTRACT_FORMATS.include?(format) remove_folder(@base_folder) create_folder(@base_folder) @objects.detect_system_objects @objects.merge_synonyms @objects.merge_grants @objects. @objects. @objects.merge_constraints @objects. @objects.handle_table_data(args) extract_summary extract_create_all(args) extract_drop_all(args) # extract all default objects @objects.default_each do |object| folder = File.join(@base_folder, "#{"%02d" % type_sequence(object.type)}_#{object.type}") create_folder(folder) filename = File.join(folder, "#{object.name}.#{format}") write_buffer_to_file(object.extract(args), filename) end end |
#fetch(args = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/db_meta/oracle/oracle.rb', line 28 def fetch(args = {}) @include_pattern = args[:include] @exclude_pattern = args[:exclude] Objects.all.each do |object| if @exclude_pattern next if @exclude_pattern&.match?(object.name) end if @include_pattern next unless @include_pattern&.match?(object.name) end @objects << object end # parallel fetching of object details @objects.fetch ensure Connection.instance.disconnect end |