Class: JunglePath::DBAccess::Import::DBDir
- Inherits:
-
Object
- Object
- JunglePath::DBAccess::Import::DBDir
- Defined in:
- lib/jungle_path/db_access/import/db_dir.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#delete ⇒ Object
readonly
Returns the value of attribute delete.
-
#insert ⇒ Object
readonly
Returns the value of attribute insert.
-
#log_path ⇒ Object
readonly
Returns the value of attribute log_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#select ⇒ Object
readonly
Returns the value of attribute select.
Instance Method Summary collapse
- #clear_import_files ⇒ Object
-
#initialize(config, logger = nil) ⇒ DBDir
constructor
A new instance of DBDir.
- #reset_sequence_for_table(table_name) ⇒ Object
- #transaction ⇒ Object
Constructor Details
#initialize(config, logger = nil) ⇒ DBDir
Returns a new instance of DBDir.
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 18 def initialize(config, logger=nil) @logger = logger @config = config @path = config.import_file_path @log_path = config.import_log_path Dir.mkdir(path) unless Dir.exist?(path) clear_import_files @select = JunglePath::DBAccess::Import::Select.new @config, @logger @insert = JunglePath::DBAccess::Import::Insert.new @config, @logger @delete = JunglePath::DBAccess::Import::Delete.new @config, @logger @schema = JunglePath::DBAccess::Import::Schema.new @config, @logger end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 10 def config @config end |
#delete ⇒ Object (readonly)
Returns the value of attribute delete.
15 16 17 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 15 def delete @delete end |
#insert ⇒ Object (readonly)
Returns the value of attribute insert.
14 15 16 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 14 def insert @insert end |
#log_path ⇒ Object (readonly)
Returns the value of attribute log_path.
12 13 14 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 12 def log_path @log_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 11 def path @path end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
16 17 18 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 16 def schema @schema end |
#select ⇒ Object (readonly)
Returns the value of attribute select.
13 14 15 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 13 def select @select end |
Instance Method Details
#clear_import_files ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 44 def clear_import_files if Dir.exist?(path) data_files = Dir.glob(File.join(path, "*.dat")) data_files.each do |file_name| File.delete file_name end end end |
#reset_sequence_for_table(table_name) ⇒ Object
31 32 33 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 31 def reset_sequence_for_table(table_name) @insert.db.reset_sequence_for_table(table_name) end |
#transaction ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/jungle_path/db_access/import/db_dir.rb', line 35 def transaction begin_transaction yield commit_transaction rescue rollback_transaction raise end |