Class: Ridoku::Db

Inherits:
Base
  • Object
show all
Defined in:
lib/ridoku/db.rb

Constant Summary

Constants inherited from Base

Base::POSTGRES_GROUP_NAME

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

base_command, color_code_logs, configure_ec2_client, configure_iam_client, configure_instance_roles, configure_opsworks_client, configure_roles, configure_service_roles, create_app, create_role, deploy, execute_recipes, extract_instance_ids, fetch_account, fetch_app, fetch_instance, fetch_layer, fetch_permissions, fetch_roles, fetch_stack, get_instances_for_layer, get_layer_ids, if_debug?, initialize_app_environment, instance_by_id, instance_role_configured?, load_config, monitor_deployment, postgresql_group_exists?, pretty_instances, roles_configured?, rollback, run_command, save_app, save_config, save_layer, save_stack, select_instances, service_role_configured?, standard_deploy, update_cookbooks, update_pg_security_group, update_pg_security_groups_in_all_regions, valid_instances?

Instance Attribute Details

#dbaseObject

Returns the value of attribute dbase.



15
16
17
# File 'lib/ridoku/db.rb', line 15

def dbase
  @dbase
end

Class Method Details

.adapter_from_scheme(scheme) ⇒ Object



184
185
186
187
188
# File 'lib/ridoku/db.rb', line 184

def adapter_from_scheme(scheme)
  val = scheme_hash.invert
  return val[scheme] if val.key?(scheme)
  scheme
end

.gen_dbase_url(dbase) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/ridoku/db.rb', line 190

def gen_dbase_url(dbase)
  scheme = scheme_from_adapter(dbase['adapter'])
  username = dbase['username']
  password = dbase['password']
  host = dbase['host']
  port = dbase['port']
  database = dbase['database']

  url = "#{scheme}://"
  url += username if username
  url += ":#{password}"
  url += '@' if username || password
  url += host
  url += ":#{port}" if port
  url += "/#{database}" if database
  url
end

.scheme_from_adapter(adapter) ⇒ Object



178
179
180
181
182
# File 'lib/ridoku/db.rb', line 178

def scheme_from_adapter(adapter)
  val = scheme_hash
  return val[adapter] if val.key?(adapter)
  adapter
end

.scheme_hashObject



171
172
173
174
175
176
# File 'lib/ridoku/db.rb', line 171

def scheme_hash
  {
    'postgresql' => 'postgres',
    'mysql' => 'mysql'
  }
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ridoku/db.rb', line 17

def run
  command = Base.config[:command]
  sub_command = (command.length > 0 && command[1]) || nil
  sub_sub_command = (command.length > 1 && command[2]) || nil

  case sub_command
  when 'list', nil, 'info'
    list(false)
  when 'credentials'
    list(true)
  when 'set', 'add'
    set
  when 'push', 'update'
    push_update
  when 'delete', 'remove', 'rm'
    delete
  when 'url', 'path'
    url(sub_sub_command)
  else
    print_db_help
  end
end