Module: OraUtils::Schemas
- Defined in:
- lib/orabase/utils/schemas.rb
Constant Summary collapse
- BOOLEAN =
[TrueClass, 'Yes', 'No', 'Y', 'N', 'y', 'n']
- SIZE =
lambda do |v| unless v =~ /^(\d+\s?[K|k|M|m|G|g|T|t|P|p|E|e]?)|unlimited$/ return "valid size value" else true end end
- AUTOEXTEND =
{ 'next' => [:optional, SIZE], 'maxsize' => [:optional, SIZE], }
- DATAFILE =
{ 'file_name' => [:optional, String], 'reuse' => [:optional, BOOLEAN], 'size' => [:optional, SIZE], 'autoextend' => [:optional, AUTOEXTEND] }
- EXTENT_MANAGEMENT =
{ 'type' => lambda {|v|['local', 'dictionary'].include?(v.downcase) || 'local or dictonary'}, 'autoallocate' => [:optional, BOOLEAN], 'uniform_size' => [:optional, SIZE] }
- TABLESPACE_TYPE =
lambda {|v|['bigfile', 'smallfile'].include?(v.downcase) || 'bigfile or smallfile'}
Instance Method Summary collapse
- #autoextend(value) ⇒ Object
- #datafiles(value) ⇒ Object
- #extent_management(value) ⇒ Object
- #file_specification(value) ⇒ Object
- #validate_extent_management(value) ⇒ Object
Instance Method Details
#autoextend(value) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/orabase/utils/schemas.rb', line 74 def autoextend(value) entry = ["autoextend on"] with_hash(value) do entry << content_if('size') entry << content_if('maxsize') end entry.compact.join(' ') end |
#datafiles(value) ⇒ Object
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/orabase/utils/schemas.rb', line 63 def datafiles(value) value = [value] unless value.is_a?(Array) # values can be either a Hash or an Array value.collect do | v | entry = [] with_hash(v) do entry << file_specification(v) end entry.compact.join(' ') end.compact.join(', ') end |
#extent_management(value) ⇒ Object
83 84 85 86 87 88 89 90 91 |
# File 'lib/orabase/utils/schemas.rb', line 83 def extent_management(value) return_value = [] with_hash(value) do return_value << "extent management #{value_for('type')}" return_value << key_if('autoallocate') return_value << content_if('uniform_size') end return_value.compact.join(' ') end |
#file_specification(value) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/orabase/utils/schemas.rb', line 51 def file_specification(value) entry = [] with_hash(value) do autoextend_value = value_for('autoextend') entry << "'#{value_for('file_name')}'" if value_for('file_name') entry << content_if('size') entry << key_if('reuse') entry << autoextend(autoextend_value).to_s if exists?('autoextend') end entry.join(' ') end |
#validate_extent_management(value) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/orabase/utils/schemas.rb', line 37 def validate_extent_management(value) if value with_hash(value) do type = value_for('type') if type.downcase == 'dictionary' && exists?('autoallocate') raise ArgumentError, 'extent management dictionary, incompatible with autoallocate' end if type.downcase == 'dictionary' && exists?('uniform_size') raise ArgumentError, 'extent management dictionary, incompatible with uniform_size' end end end end |