staging/spec/support/staging_spec_helpers.rb
def stage(framework, env = {})
    raise "Call 'app_fixture :name_of_app' before staging" unless @app_fixture
    plugin_klass = StagingPlugin.load_plugin_for(framework)
    working_dir = Dir.mktmpdir("#{@app_fixture}-staged")
    source_tempdir = nil
    # TODO - There really needs to be a single helper to track tempdirs.
    source_dir = case framework
                 when /spring|grails|lift|java_web/
                   source_tempdir = Dir.mktmpdir(@app_fixture)
                   app_source(source_tempdir)
                 else
                   app_source
                 end
    stager = plugin_klass.new(source_dir, working_dir, env)
    # I still don't get why it's an array of single key hashes
    # instead of a hash of {name => attrs}
    StagingPlugin.manifests[framework.to_s]['runtimes'].each do |runtime|
      runtime.each do |name, attrs|
        if ENV["VCAP_RUNTIME_#{name.upcase}"]
          attrs['executable'] = ENV["VCAP_RUNTIME_#{name.upcase}"]
          # When we aren't doing anything patchlevel specific, the runtime
          # version can be overridden here
          if ENV["VCAP_RUNTIME_#{name.upcase}_VER"]
            attrs['version'] = ENV["VCAP_RUNTIME_#{name.upcase}_VER"]
          end
        end
      end
    end
    stager.stage_application
    return working_dir unless block_given?
    Dir.chdir(working_dir) do
      yield Pathname.new(working_dir), Pathname.new(source_dir)
    end
    nil
  ensure
    if block_given?
      FileUtils.rm_r(working_dir) if working_dir
    end
    FileUtils.rm_r(source_tempdir) if source_tempdir
  end
# If called without a block, returns the staging output directory as a string.
# You must manually clean up the directory thus created.
# If called with a block, yields the staged directory as a Pathname, and
# automatically deletes it when the block returns.
If called without a block, returns the staging output directory as a string.
You must manually clean up the directory thus created.
If called with a block, yields the staged directory as a Pathname, and
automatically deletes it when the block returns.
If called without a block returns the staging output directory as a string . You must manually clean up the directory thus created . If called with a block yields the staged directory as a Pathname and automatically deletes it when the block returns .
def stage(framework, env = {})
    raise "Call 'app_fixture :name_of_app' before staging" unless @app_fixture
    plugin_klass = StagingPlugin.load_plugin_for(framework)
    working_dir = Dir.mktmpdir("#{@app_fixture}-staged")
    source_tempdir = nil
    source_dir = case framework
                 when /spring|grails|lift|java_web/
                   source_tempdir = Dir.mktmpdir(@app_fixture)
                   app_source(source_tempdir)
                 else
                   app_source
                 end
    stager = plugin_klass.new(source_dir, working_dir, env)
    StagingPlugin.manifests[framework.to_s]['runtimes'].each do |runtime|
      runtime.each do |name, attrs|
        if ENV["VCAP_RUNTIME_#{name.upcase}"]
          attrs['executable'] = ENV["VCAP_RUNTIME_#{name.upcase}"]
          if ENV["VCAP_RUNTIME_#{name.upcase}_VER"]
            attrs['version'] = ENV["VCAP_RUNTIME_#{name.upcase}_VER"]
          end
        end
      end
    end
    stager.stage_application
    return working_dir unless block_given?
    Dir.chdir(working_dir) do
      yield Pathname.new(working_dir), Pathname.new(source_dir)
    end
    nil
  ensure
    if block_given?
      FileUtils.rm_r(working_dir) if working_dir
    end
    FileUtils.rm_r(source_tempdir) if source_tempdir
  end
def stage ( framework , env = { } ) raise "Call 'app_fixture :name_of_app' before staging" unless @app_fixture plugin_klass = StagingPlugin . load_plugin_for ( framework ) working_dir = Dir . mktmpdir ( "#{@app_fixture}-staged" ) source_tempdir = nil source_dir = case framework when / spring|grails|lift|java_web / source_tempdir = Dir . mktmpdir ( @app_fixture ) app_source ( source_tempdir ) else app_source end stager = plugin_klass . new ( source_dir , working_dir , env ) StagingPlugin . manifests [ framework . to_s ] [ 'runtimes' ] . each do | runtime | runtime . each do | name , attrs | if ENV [ "VCAP_RUNTIME_#{name.upcase}" ] attrs [ 'executable' ] = ENV [ "VCAP_RUNTIME_#{name.upcase}" ] if ENV [ "VCAP_RUNTIME_#{name.upcase}_VER" ] attrs [ 'version' ] = ENV [ "VCAP_RUNTIME_#{name.upcase}_VER" ] end end end end stager . stage_application return working_dir unless block_given? Dir . chdir ( working_dir ) do yield Pathname . new ( working_dir ) , Pathname . new ( source_dir ) end nil ensure if block_given? FileUtils . rm_r ( working_dir ) if working_dir end FileUtils . rm_r ( source_tempdir ) if source_tempdir end
If called without a block, returns the staging output directory as a string.
If called without a block returns the staging output directory as a string .
# TODO - There really needs to be a single helper to track tempdirs. # I still don't get why it's an array of single key hashes # instead of a hash of {name => attrs} # When we aren't doing anything patchlevel specific, the runtime # version can be overridden here
framework
env