if ( rubyAppMetaData == null || rackAppMetaData == null || railsAppMetaData == null ) {
return;
}
RubyRuntimeMetaData runtimeMetaData = unit.getAttachment( RubyRuntimeMetaData.ATTACHMENT_KEY );
if ( runtimeMetaData != null && runtimeMetaData.getRuntimeType() != null ) {
return;
}
if (runtimeMetaData == null) {
runtimeMetaData = new RubyRuntimeMetaData();
unit.putAttachment( RubyRuntimeMetaData.ATTACHMENT_KEY, runtimeMetaData );
}
runtimeMetaData.setBaseDir( rubyAppMetaData.getRoot() );
runtimeMetaData.setEnvironment( rubyAppMetaData.getEnvironmentVariables() );
runtimeMetaData.setRuntimeType( RubyRuntimeMetaData.RuntimeType.RAILS );
runtimeMetaData.appendLoadPath( new RubyLoadPathMetaData( rubyAppMetaData.getRoot() ) );
runtimeMetaData.appendLoadPath( new RubyLoadPathMetaData( new File( rubyAppMetaData.getRoot(), "lib" ) ) );
RuntimeInitializer initializer = new RailsRuntimeInitializer( rubyAppMetaData, rackAppMetaData, railsAppMetaData );
RuntimePreparer preparer = new BundlerAwareRuntimePreparer( rubyAppMetaData );
runtimeMetaData.setRuntimeInitializer( initializer );
runtimeMetaData.setRuntimePreparer( preparer );
}