Class: Mobilis::MysqlInstance

Inherits:
GenericProject show all
Defined in:
lib/mobilis/mysql_instance.rb

Instance Method Summary collapse

Methods inherited from GenericProject

#children, #display, #docker_image_name, #generate_build_sh, #git_commit_all, #initialize, #linked_to_rails_project, #links, #name, #options, #parents, #set_links, #type

Methods included from ActionsProjectsTake

#append_line, #oblivious_run_command, #run_command, #run_docker, #set_file_contents, #set_second_line, #write_file

Constructor Details

This class inherits a constructor from Mobilis::GenericProject

Instance Method Details

#child_env_varsObject



12
13
14
# File 'lib/mobilis/mysql_instance.rb', line 12

def child_env_vars
  [ ]
end

#data_dirObject



28
29
30
# File 'lib/mobilis/mysql_instance.rb', line 28

def data_dir
  "./data/#{ name }"
end

#env_varsObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mobilis/mysql_instance.rb', line 16

def env_vars
  vars = []
  if linked_to_rails_project
    vars << "MYSQL_DATABASE=#{ linked_to_rails_project.name }_production"
  end
  vars.concat [
    "MYSQL_USER=#{ name }",
    "MYSQL_PASSWORD=#{ name }_password",
    "MYSQL_RANDOM_ROOT_PASSWORD=true"
  ]
end

#generateObject



8
9
10
# File 'lib/mobilis/mysql_instance.rb', line 8

def generate
  FileUtils.mkdir_p data_dir
end

#has_local_buildObject



32
33
34
# File 'lib/mobilis/mysql_instance.rb', line 32

def has_local_build
  false
end

#passwordObject



44
45
46
# File 'lib/mobilis/mysql_instance.rb', line 44

def password
  "#{name}_password"
end

#urlObject



36
37
38
# File 'lib/mobilis/mysql_instance.rb', line 36

def url
  "mysql2://#{ username }:#{ password }@#{ name }:3306/?pool=5"
end

#usernameObject



40
41
42
# File 'lib/mobilis/mysql_instance.rb', line 40

def username
  name
end