org.codehaus.enunciate.modules.ruby
Class RubyDeploymentModule

java.lang.Object
  extended by org.codehaus.enunciate.modules.BasicDeploymentModule
      extended by org.codehaus.enunciate.modules.FreemarkerDeploymentModule
          extended by org.codehaus.enunciate.modules.ruby.RubyDeploymentModule
All Implemented Interfaces:
EnunciateClasspathListener, EnunciateModelAware, DeploymentModule

public class RubyDeploymentModule
extends FreemarkerDeploymentModule
implements EnunciateClasspathListener

Ruby Module

The Ruby module generates Ruby data types that can be used in conjunction with the Ruby JSON implementation to (de)serialize the REST resources as they are represented as JSON data.

The order of the Ruby deployment module is 0, as it doesn't depend on any artifacts exported by any other module.

Configuration

The Ruby module is configured with the "ruby" element under the "modules" element of the enunciate configuration file. It supports the following attributes:

The "package-conversions" element

The "package-conversions" subelement of the "ruby" element is used to map packages from the original API packages to Ruby modules. This element supports an arbitrary number of "convert" child elements that are used to specify the conversions. These "convert" elements support the following attributes:

Author:
Ryan Heaton

Field Summary
 
Fields inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
enunciate
 
Constructor Summary
RubyDeploymentModule()
           
 
Method Summary
 void addClientPackageConversion(PackageModuleConversion conversion)
          Add a client package conversion.
 void doFreemarkerGenerate()
          Generate using Freemarker.
protected  boolean existsAnyJsonResourceMethod(java.util.List<RootResource> rootResources)
          Whether any root resources exist that produce json.
 org.apache.commons.digester.RuleSet getConfigurationRules()
          Default implementation returns null.
 java.lang.String getLabel()
          The label for the Ruby API.
 java.lang.String getName()
          The name of the deployment module.
protected  freemarker.template.ObjectWrapper getObjectWrapper()
          The object wrapper to use for the model.
 java.util.Map<java.lang.String,java.lang.String> getPackageToModuleConversions()
          The package-to-module conversions.
protected  java.lang.String getSourceFileName()
          The name of the generated Ruby source file.
protected  java.net.URL getTemplateURL(java.lang.String template)
          Get a template URL for the template of the given name.
 Validator getValidator()
          Get the validator for this module, or null if none.
 void initModel(EnunciateFreemarkerModel model)
          Initialize the model.
 boolean isDisabled()
          Whether this deployment module has been disabled, e.g.
 boolean isForceEnable()
          Whether to force-enable the Ruby module.
 void onClassesFound(java.util.Set<java.lang.String> classes)
          Logic for handling a set of classes that were found on the Enunciate classpath.
protected  java.lang.String packageToModule(java.lang.String pckg)
           
protected  java.lang.String readResource(java.lang.String resource)
          Reads a resource into string form.
 void setForceEnable(boolean forceEnable)
          Whether to force-enable the Ruby module.
 void setLabel(java.lang.String label)
          The label for the Ruby API.
 
Methods inherited from class org.codehaus.enunciate.modules.FreemarkerDeploymentModule
close, doGenerate, getConfiguration, getModel, getModelInternal, getTemplateExceptionHandler, getTemplateLoader, processTemplate, processTemplate, processTemplate, processTemplate
 
Methods inherited from class org.codehaus.enunciate.modules.BasicDeploymentModule
debug, doBuild, doCompile, doPackage, getAliases, getBuildDir, getCompileDir, getEnunciate, getGenerateDir, getOrder, getPackageDir, info, init, setBuildDir, setCompileDir, setDisabled, setGenerateDir, setPackageDir, step, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RubyDeploymentModule

public RubyDeploymentModule()
Method Detail

getName

public java.lang.String getName()
Description copied from interface: DeploymentModule
The name of the deployment module. Identifies its section in the enunciate configuration.

Specified by:
getName in interface DeploymentModule
Overrides:
getName in class BasicDeploymentModule
Returns:
"ruby"

onClassesFound

public void onClassesFound(java.util.Set<java.lang.String> classes)
Description copied from interface: EnunciateClasspathListener
Logic for handling a set of classes that were found on the Enunciate classpath.

Specified by:
onClassesFound in interface EnunciateClasspathListener
Parameters:
classes - The classes that were found.

initModel

public void initModel(EnunciateFreemarkerModel model)
Description copied from interface: EnunciateModelAware
Initialize the model.

Specified by:
initModel in interface EnunciateModelAware
Overrides:
initModel in class FreemarkerDeploymentModule
Parameters:
model - The model to initialize.

packageToModule

protected java.lang.String packageToModule(java.lang.String pckg)

doFreemarkerGenerate

public void doFreemarkerGenerate()
                          throws java.io.IOException,
                                 freemarker.template.TemplateException,
                                 EnunciateException
Description copied from class: FreemarkerDeploymentModule
Generate using Freemarker. Same as FreemarkerDeploymentModule.doGenerate() but can throw a TemplateException.

Specified by:
doFreemarkerGenerate in class FreemarkerDeploymentModule
Throws:
java.io.IOException
freemarker.template.TemplateException
EnunciateException

readResource

protected java.lang.String readResource(java.lang.String resource)
                                 throws java.io.IOException,
                                        EnunciateException
Reads a resource into string form.

Parameters:
resource - The resource to read.
Returns:
The string form of the resource.
Throws:
java.io.IOException
EnunciateException

getSourceFileName

protected java.lang.String getSourceFileName()
The name of the generated Ruby source file.

Returns:
The name of the generated Ruby source file.

getObjectWrapper

protected freemarker.template.ObjectWrapper getObjectWrapper()
Description copied from class: FreemarkerDeploymentModule
The object wrapper to use for the model.

Overrides:
getObjectWrapper in class FreemarkerDeploymentModule
Returns:
The object wrapper to use for the model.

getTemplateURL

protected java.net.URL getTemplateURL(java.lang.String template)
Get a template URL for the template of the given name.

Parameters:
template - The specified template.
Returns:
The URL to the specified template.

isForceEnable

public boolean isForceEnable()
Whether to force-enable the Ruby module.

Returns:
Whether to force-enable the Ruby module.

setForceEnable

public void setForceEnable(boolean forceEnable)
Whether to force-enable the Ruby module.

Parameters:
forceEnable - Whether to force-enable the Ruby module.

getLabel

public java.lang.String getLabel()
The label for the Ruby API.

Returns:
The label for the Ruby API.

setLabel

public void setLabel(java.lang.String label)
The label for the Ruby API.

Parameters:
label - The label for the Ruby API.

getPackageToModuleConversions

public java.util.Map<java.lang.String,java.lang.String> getPackageToModuleConversions()
The package-to-module conversions.

Returns:
The package-to-module conversions.

addClientPackageConversion

public void addClientPackageConversion(PackageModuleConversion conversion)
Add a client package conversion.

Parameters:
conversion - The conversion to add.

getConfigurationRules

public org.apache.commons.digester.RuleSet getConfigurationRules()
Description copied from class: BasicDeploymentModule
Default implementation returns null.

Specified by:
getConfigurationRules in interface DeploymentModule
Overrides:
getConfigurationRules in class BasicDeploymentModule
Returns:
null.

getValidator

public Validator getValidator()
Description copied from interface: DeploymentModule
Get the validator for this module, or null if none.

Specified by:
getValidator in interface DeploymentModule
Overrides:
getValidator in class BasicDeploymentModule
Returns:
null

isDisabled

public boolean isDisabled()
Description copied from interface: DeploymentModule
Whether this deployment module has been disabled, e.g. in the config file. Since the discovery mechanism is used to discover the modules on the classpath, it may be necessary to be able to disable a module.

Specified by:
isDisabled in interface DeploymentModule
Overrides:
isDisabled in class BasicDeploymentModule
Returns:
Whether this deployment module has been disabled.

existsAnyJsonResourceMethod

protected boolean existsAnyJsonResourceMethod(java.util.List<RootResource> rootResources)
Whether any root resources exist that produce json.

Parameters:
rootResources - The root resources.
Returns:
Whether any root resources exist that produce json.