Class: ConfigManager
- Inherits:
-
Object
- Object
- ConfigManager
- Defined in:
- lib/config_manager.rb
Instance Method Summary collapse
- #get_file_lines ⇒ Object
- #get_wp_container_name ⇒ Object
- #get_wp_container_port ⇒ Object
- #get_wp_environment_name ⇒ Object
- #is_docker_compose_directory ⇒ Object
- #is_docker_compose_folder ⇒ Object
Instance Method Details
#get_file_lines ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/config_manager.rb', line 30 def get_file_lines unless self.is_docker_compose_folder puts "docker-compose.yml does not exists in current directory. Choose one of the available environments." puts wp_docker_list exit end file_lines = File.readlines("docker-compose.yml") unless file_lines.grep(/## wp-docker ##/).any? puts "Invalid docker-compose.yml" exit end file_lines end |
#get_wp_container_name ⇒ Object
2 3 4 5 6 7 8 |
# File 'lib/config_manager.rb', line 2 def get_wp_container_name file_lines = get_file_lines container_line = file_lines.grep(/container_name: wpd_web/) name = container_line[0].scan(/wpd_.+_\d+/)[0] return name end |
#get_wp_container_port ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/config_manager.rb', line 18 def get_wp_container_port file_lines = get_file_lines container_line = file_lines.grep(/:80"/) ret = container_line[0].scan(/(\d+):(\d+)"/) return ret[0][0] end |
#get_wp_environment_name ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/config_manager.rb', line 10 def get_wp_environment_name file_lines = get_file_lines container_line = file_lines.grep(/container_name: wpd_web/) name = container_line[0].scan(/(wpd_[a-z]+)_(.+\d+)/) return name[0][1] end |
#is_docker_compose_directory ⇒ Object
26 27 28 |
# File 'lib/config_manager.rb', line 26 def is_docker_compose_directory end |
#is_docker_compose_folder ⇒ Object
47 48 49 |
# File 'lib/config_manager.rb', line 47 def is_docker_compose_folder File.file?("docker-compose.yml") end |