Module: DbMeta::Oracle::Helper

Included in:
Base, ConstraintCollection, GrantCollection, Objects, Objects, Oracle, SynonymCollection, TableDataCollection
Defined in:
lib/db_meta/oracle/helper.rb

Instance Method Summary collapse

Instance Method Details

#block(title, size = 80) ⇒ Object



5
6
7
8
# File 'lib/db_meta/oracle/helper.rb', line 5

def block(title, size = 80)
  line = '-- ' + ('-' * (size-3))
  buffer = [line, "-- #{title}", line].join("\n")
end

#create_folder(folder) ⇒ Object



25
26
27
28
# File 'lib/db_meta/oracle/helper.rb', line 25

def create_folder(folder)
  Dir.mkdir(folder.downcase.gsub(' ', '_'))
rescue
end

#pluralize(n, singular, plural = nil) ⇒ Object



30
31
32
33
# File 'lib/db_meta/oracle/helper.rb', line 30

def pluralize(n, singular, plural=nil)
  return singular if n == 1
  return (plural || (singular + 's'))
end

#remove_folder(folder) ⇒ Object



21
22
23
# File 'lib/db_meta/oracle/helper.rb', line 21

def remove_folder(folder)
  FileUtils.rm_rf(folder)
end

#type_sequence(type) ⇒ Object



10
11
12
# File 'lib/db_meta/oracle/helper.rb', line 10

def type_sequence(type)
  return TYPE_SEQUENCE[type] || 99
end

#write_buffer_to_file(buffer, file) ⇒ Object



14
15
16
17
18
19
# File 'lib/db_meta/oracle/helper.rb', line 14

def write_buffer_to_file(buffer, file)
  buffer = buffer.join("\n") if buffer.is_a?(Array)
  File.open(file.downcase.gsub(' ', '_'), 'w') do |output|
    output.write(buffer)
  end
end