Sha256: 10443b4535691d7940a9ec94154072e9fa6df7026db652542e3ddab40f4640bb

Contents?: true

Size: 990 Bytes

Versions: 3

Compression:

Stored size: 990 Bytes

Contents

require 'mvc_deployment'

class DeployCommandCreator
  def convert_from_config(config, environment_being_deployed)
    deploy_config = create_object(config)
    
    populate_object_from_config(deploy_config, config.environment, environment_being_deployed)
    
    return deploy_config
  end
  
  private 
  def create_object(config)
    cls_name = config.environment.configured_as
    # raise if cls_name.nil?
    Kernel.const_get(cls_name.to_s.capitalize + "Deployment").new    
  end
  
  def populate_object_from_config(obj, environments, environment_being_deployed)
    obj.set_environment(environment_being_deployed)
    obj.set_description(environments.desc) if environments.has_key? :desc
    
    env = environments[environment_being_deployed]
    env.keys.each do |k|
      call_method(obj, k, env[k])
    end
    
  end
  
  def call_method(obj, name, param)
    method_name = "set_" + name.to_s
    obj.send(method_name.to_sym, param)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dolphindeploy-0.0.3-universal-dotnet lib/deploycommandcreator.rb
dolphindeploy-0.0.2-universal-dotnet lib/deploycommandcreator.rb
dolphindeploy-0.0.1 lib/deploycommandcreator.rb