Class: SQLite2DBF
- Inherits:
-
Object
- Object
- SQLite2DBF
- Includes:
- Logging, Translating
- Defined in:
- lib/sqlite2dbf.rb
Overview
The main program class. Does it.
Instance Method Summary collapse
-
#initialize(*args) ⇒ SQLite2DBF
constructor
A new instance of SQLite2DBF.
Methods included from Translating
Methods included from Logging
#init_logger, #log_level=, #log_target=
Methods included from File_Checking
Constructor Details
#initialize(*args) ⇒ SQLite2DBF
Returns a new instance of SQLite2DBF.
39 40 41 42 43 44 45 46 47 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 79 80 81 82 83 |
# File 'lib/sqlite2dbf.rb', line 39 def initialize(*args) = ArgParser::parse(args) init_logger level = (.debug ? Logger::DEBUG : @log.level) @log.level = level @log.debug('options are: ' << .to_s) @date_fields = .datetime ? .datetime : [] @time_fields = .time ? .time : [] if(.source) @dbf_path = nil sqlite_file = .source dbf_file = .target if .target if(.table_name && .out_dir) @dbf_path = .out_dir dbf_file = :table end dbf_file ||= File.dirname(sqlite_file) << File::Separator << File.basename(sqlite_file, '.*') msg = nil if(dbf_file != :table) if(File.exist?(dbf_file)) msg = File_Checking.file_check(dbf_file, :file, :writable) elsif(File.exist?(File.dirname(dbf_file))) msg = File_Checking.file_check(File.dirname(dbf_file), :directory, :writable) end end msg ||= File_Checking.file_check(sqlite_file, :exist, :readable, :file) if(!msg) @log.debug('will transform ' << sqlite_file << ' to ' << dbf_file.to_s << '.dbf') transform(sqlite_file, dbf_file) else msg = trl("ERROR! Unsuitable file") << " : %s" %msg @log.error(msg) exit false end else puts trl("ERROR! Source-file is a mandatory program parameter!") puts trl("Start this program with parameter -h or --help to see the usage-message.") end end |