Class: Mobilis::PostgresqlInstance

Inherits:
GenericProject show all
Defined in:
lib/mobilis/postgresql_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/postgresql_instance.rb', line 12

def child_env_vars
  [ ]
end

#data_dirObject



27
28
29
# File 'lib/mobilis/postgresql_instance.rb', line 27

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

#env_varsObject



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

def env_vars
  vars = []
  if linked_to_rails_project
    vars << "POSTGRES_DB=#{ linked_to_rails_project.name }_production"
  end
  vars.concat [
   "POSTGRES_USER=#{ name }",
   "POSTGRES_PASSWORD=#{ password }"
  ]
end

#generateObject



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

def generate
  FileUtils.mkdir_p data_dir
end

#has_local_buildObject



31
32
33
# File 'lib/mobilis/postgresql_instance.rb', line 31

def has_local_build
  false
end

#passwordObject



43
44
45
# File 'lib/mobilis/postgresql_instance.rb', line 43

def password
  "#{name}_password"
end

#urlObject



35
36
37
# File 'lib/mobilis/postgresql_instance.rb', line 35

def url
  "postgres://#{ username }:#{ password }@#{ name }:5432/"
end

#usernameObject



39
40
41
# File 'lib/mobilis/postgresql_instance.rb', line 39

def username
  name
end