Module: Containers::Configurable
- Extended by:
- ActiveSupport::Concern
- Included in:
- CLI, Generator::CLI
- Defined in:
- lib/containers/concerns/configurable.rb
Constant Summary collapse
- DEFAULT_CONFIGURATION =
{ "organization" => { "name" => gitname }, "app" => { "name" => File.basename(Dir.pwd).parameterize, "directory" => "." }, "docker" => { "directory" => ".", "default_service" => nil, "compose_files" => ["docker-compose.yml"] } }.freeze
Class Method Summary collapse
Instance Method Summary collapse
- #app_directory ⇒ Object
- #app_name ⇒ Object
- #configuration ⇒ Object
- #docker_compose_files ⇒ Object
- #docker_default_service ⇒ Object
- #docker_directory ⇒ Object
- #organization_name ⇒ Object
Class Method Details
.gitname ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/containers/concerns/configurable.rb', line 6 def self.gitname email = begin `git config --get user.email`.strip rescue nil end email&.split("@")&.first || "example" end |
Instance Method Details
#app_directory ⇒ Object
38 39 40 |
# File 'lib/containers/concerns/configurable.rb', line 38 def app_directory configuration["app"]["directory"] end |
#app_name ⇒ Object
34 35 36 |
# File 'lib/containers/concerns/configurable.rb', line 34 def app_name configuration["app"]["name"] end |
#configuration ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/containers/concerns/configurable.rb', line 54 def configuration @configuration ||= if File.exist?(".containers.yml") YAML.load_file(".containers.yml") else DEFAULT_CONFIGURATION end end |
#docker_compose_files ⇒ Object
50 51 52 |
# File 'lib/containers/concerns/configurable.rb', line 50 def docker_compose_files configuration["docker"]["compose_files"] end |
#docker_default_service ⇒ Object
46 47 48 |
# File 'lib/containers/concerns/configurable.rb', line 46 def docker_default_service configuration["docker"]["default_service"] end |
#docker_directory ⇒ Object
42 43 44 |
# File 'lib/containers/concerns/configurable.rb', line 42 def docker_directory configuration["docker"]["directory"] end |
#organization_name ⇒ Object
30 31 32 |
# File 'lib/containers/concerns/configurable.rb', line 30 def organization_name configuration["organization"]["name"] end |