Class: Shiplane::ConvertComposeFile
- Inherits:
-
Object
- Object
- Shiplane::ConvertComposeFile
- Extended by:
- Forwardable
- Defined in:
- lib/shiplane/convert_compose_file.rb
Instance Attribute Summary collapse
-
#project_folder ⇒ Object
Returns the value of attribute project_folder.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#shiplane_config ⇒ Object
readonly
Returns the value of attribute shiplane_config.
Class Method Summary collapse
Instance Method Summary collapse
- #compose_config ⇒ Object
- #compose_filepath ⇒ Object
- #convert_output! ⇒ Object
- #converted_compose_hash ⇒ Object
- #converted_output ⇒ Object
-
#initialize(project_folder, sha, config: nil) ⇒ ConvertComposeFile
constructor
A new instance of ConvertComposeFile.
Constructor Details
#initialize(project_folder, sha, config: nil) ⇒ ConvertComposeFile
Returns a new instance of ConvertComposeFile.
13 14 15 16 17 |
# File 'lib/shiplane/convert_compose_file.rb', line 13 def initialize(project_folder, sha, config: nil) @project_folder = project_folder @sha = sha @shiplane_config = config || Shiplane::Configuration.new end |
Instance Attribute Details
#project_folder ⇒ Object
Returns the value of attribute project_folder.
8 9 10 |
# File 'lib/shiplane/convert_compose_file.rb', line 8 def project_folder @project_folder end |
#sha ⇒ Object
Returns the value of attribute sha.
8 9 10 |
# File 'lib/shiplane/convert_compose_file.rb', line 8 def sha @sha end |
#shiplane_config ⇒ Object (readonly)
Returns the value of attribute shiplane_config.
9 10 11 |
# File 'lib/shiplane/convert_compose_file.rb', line 9 def shiplane_config @shiplane_config end |
Class Method Details
.convert_output!(project_folder, sha, config: nil) ⇒ Object
49 50 51 |
# File 'lib/shiplane/convert_compose_file.rb', line 49 def self.convert_output!(project_folder, sha, config: nil) new(project_folder, sha, config: config).convert_output! end |
Instance Method Details
#compose_config ⇒ Object
19 20 21 |
# File 'lib/shiplane/convert_compose_file.rb', line 19 def compose_config @compose_config ||= build_config.fetch('compose', {}) end |
#compose_filepath ⇒ Object
23 24 25 |
# File 'lib/shiplane/convert_compose_file.rb', line 23 def compose_filepath @compose_filepath ||= File.join(project_folder, build_config.fetch('compose_filepath', Shiplane::DEFAULT_COMPOSEFILE_FILEPATH)) end |
#convert_output! ⇒ Object
43 44 45 46 47 |
# File 'lib/shiplane/convert_compose_file.rb', line 43 def convert_output! puts "Converting Compose File..." File.write(compose_filepath, converted_output.to_yaml) puts "Compose File Converted..." end |
#converted_compose_hash ⇒ Object
27 28 29 |
# File 'lib/shiplane/convert_compose_file.rb', line 27 def converted_compose_hash @converted_compose_hash ||= Shiplane::ComposeHash.new(File.new(compose_filepath), compose_config).production_yml end |
#converted_output ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shiplane/convert_compose_file.rb', line 31 def converted_output @converted_output ||= converted_compose_hash.dup.tap do |hash| hash.traverse! do |key, value| if (key == 'env_file' && value == '.env.development') [key, '.env.production'] else [key, value] end end end end |