Sha256: 34c089feccd6b2aec0930197256f9e2db3b3cc8a7bdafe20860ffc02e4c34280

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

# -*- coding: utf-8 -*-

require 'arxutils/dbutil/dbinit'

require 'date'
require 'pp'

module Arxutils
  module Dbutil
    class DbMgr
      def DbMgr.init( migrate_dir , config_dir , dbconfig, log_fname, forced = false )
        dbinit = Dbinit.new( migrate_dir , config_dir , dbconfig, log_fname, forced )
        DbMgr.setup( dbinit )
      end
      
      def DbMgr.setup( dbinit )
        @@ret ||= nil
        unless @@ret
          begin
            dbinit.setup
            @@ret = DateTime.now.new_offset
          rescue => ex
            pp ex.class
            pp ex.message
            pp ex.backtrace
          end
        end

        @@ret
      end
      def DbMgr.conv_string(value , encoding)
        if value.class == String
          if value.encodingy != encoding
            value.encode(encoding)
          else
            value
          end
        else
          value
        end
      end
      
      def DbMgr.conv_boolean( k , v )
        ret = v
        if k =~ /enable/
          if v.class == String
            case v
            when 'T'
              ret = true
            when 'F'
              ret = false
            else
              raise
            end
          elsif v.class == TrueClass
            # do nothin
          elsif v.class == FalseClass
            # do nothin
          else
            p v.class
            p v
            raise
          end
        end
        ret
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arxutils-0.1.35 lib/arxutils/dbutil/dbmgr.rb