class Pantry::Commands::EditApplication
Edit the configuration of the requested Application.
Application configuration is stored on the Server
under Pantry.root
/applications/[app name]/config.yml and is where all configuration lives for how Pantry
manages this application.
Public Instance Methods
perform(message)
click to toggle source
Read or create a new config file for the given application and return the contents of this config file, which will always be a YAML document
# File lib/pantry/commands/edit_application.rb, line 31 def perform(message) application = message.body[0] config_file = Pantry.root.join("applications", application, "config.yml") FileUtils.mkdir_p(File.dirname(config_file)) if File.exists?(config_file) [File.read(config_file)] else [{"name" => application}.to_yaml] end end
prepare_message(options)
click to toggle source
Calls superclass method
Pantry::Command#prepare_message
# File lib/pantry/commands/edit_application.rb, line 16 def prepare_message(options) @application = options[:application] raise Pantry::MissingOption, 'Missing required option "application"' unless @application # Let the EDITOR check run before we do any communication @editor = Pantry::FileEditor.new super.tap do |msg| msg << @application end end
receive_server_response(message)
click to toggle source
# File lib/pantry/commands/edit_application.rb, line 44 def receive_server_response(message) current_config = message.body[0] new_config = @editor.edit(current_config, :yaml) if new_config != current_config send_request!( Pantry::Commands::UpdateApplication.new( @application, new_config ).to_message ) end end