Class: Bootstrap::Db::Adapter

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/bootstrap/db/adapter.rb

Direct Known Subclasses

Mysql, Postgres

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Command

#display_and_execute, #execute_command

Constructor Details

#initialize(config) ⇒ Adapter

Returns a new instance of Adapter.



8
9
10
11
12
13
# File 'lib/bootstrap/db/adapter.rb', line 8

def initialize(config)
  @config = config

  @file_name = ENV['FILE_NAME'] || default_file_name
  @file_path = File.expand_path(File.join(config.bootstrap_dir, file_name))
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/bootstrap/db/adapter.rb', line 6

def config
  @config
end

#file_nameObject (readonly)

Returns the value of attribute file_name.



6
7
8
# File 'lib/bootstrap/db/adapter.rb', line 6

def file_name
  @file_name
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



6
7
8
# File 'lib/bootstrap/db/adapter.rb', line 6

def file_path
  @file_path
end

Instance Method Details

#additional_parametersObject



31
32
33
34
35
# File 'lib/bootstrap/db/adapter.rb', line 31

def additional_parameters
  @optional_parameters ||= begin
    ENV['ADDITIONAL_PARAMS'].split(',') if ENV['ADDITIONAL_PARAMS']
  end
end

#command_stringObject

implemented by adapters

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/bootstrap/db/adapter.rb', line 16

def command_string
  raise NotImplementedError
end

#current_db_timeObject



37
38
39
40
41
42
43
44
45
46
47
# File 'lib/bootstrap/db/adapter.rb', line 37

def current_db_time
  if Time.respond_to?(:zone)
    #Handle custom timezones
    if time_zone = (ENV['TZ'] || ENV['ZONEBIE_TZ'])
      Time.zone ||= time_zone
    end
    Time.zone.now
  else
    Time.now
  end.to_formatted_s(:db)
end

#default_file_nameObject

implemented by adapters

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/bootstrap/db/adapter.rb', line 21

def default_file_name
  raise NotImplementedError
end

#ignore_tablesObject



25
26
27
28
29
# File 'lib/bootstrap/db/adapter.rb', line 25

def ignore_tables
  @ignore_tables ||= begin
    ENV['IGNORE_TABLES'].split(',') if ENV['IGNORE_TABLES']
  end
end