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:

The "facets" element

The "facets" element is applicable to the Ruby module to configure which facets are to be included/excluded from the Ruby artifacts. For more information, see API Facets

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 addFacetExclude(String name)
          Add a facet exclude.
 void addFacetInclude(String name)
          Add a facet include.
 void doFreemarkerGenerate()
           
protected  boolean existsAnyJsonResourceMethod(List<RootResource> rootResources)
          Whether any root resources exist that produce json.
 org.apache.commons.digester.RuleSet getConfigurationRules()
           
 Set<String> getFacetExcludes()
          The set of facets to exclude.
 Set<String> getFacetIncludes()
          The set of facets to include.
 String getLabel()
          The label for the Ruby API.
 String getName()
           
protected  freemarker.template.ObjectWrapper getObjectWrapper()
           
 Map<String,String> getPackageToModuleConversions()
          The package-to-module conversions.
protected  String getSourceFileName()
          The name of the generated Ruby source file.
protected  URL getTemplateURL(String template)
          Get a template URL for the template of the given name.
 Validator getValidator()
           
 void initModel(EnunciateFreemarkerModel model)
           
 boolean isDisabled()
           
 boolean isForceEnable()
          Whether to force-enable the Ruby module.
 void onClassesFound(Set<String> classes)
           
protected  String packageToModule(String pckg)
           
protected  String readResource(String resource)
          Reads a resource into string form.
 void setForceEnable(boolean forceEnable)
          Whether to force-enable the Ruby module.
 void setLabel(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 String getName()
Specified by:
getName in interface DeploymentModule
Overrides:
getName in class BasicDeploymentModule
Returns:
"ruby"

onClassesFound

public void onClassesFound(Set<String> classes)
Specified by:
onClassesFound in interface EnunciateClasspathListener

initModel

public void initModel(EnunciateFreemarkerModel model)
Specified by:
initModel in interface EnunciateModelAware
Overrides:
initModel in class FreemarkerDeploymentModule

packageToModule

protected String packageToModule(String pckg)

doFreemarkerGenerate

public void doFreemarkerGenerate()
                          throws IOException,
                                 freemarker.template.TemplateException,
                                 EnunciateException
Specified by:
doFreemarkerGenerate in class FreemarkerDeploymentModule
Throws:
IOException
freemarker.template.TemplateException
EnunciateException

readResource

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

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

getSourceFileName

protected 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()
Overrides:
getObjectWrapper in class FreemarkerDeploymentModule

getTemplateURL

protected URL getTemplateURL(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 String getLabel()
The label for the Ruby API.

Returns:
The label for the Ruby API.

setLabel

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

Parameters:
label - The label for the Ruby API.

getPackageToModuleConversions

public Map<String,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()
Specified by:
getConfigurationRules in interface DeploymentModule
Overrides:
getConfigurationRules in class BasicDeploymentModule

getValidator

public Validator getValidator()
Specified by:
getValidator in interface DeploymentModule
Overrides:
getValidator in class BasicDeploymentModule

getFacetIncludes

public Set<String> getFacetIncludes()
The set of facets to include.

Returns:
The set of facets to include.

addFacetInclude

public void addFacetInclude(String name)
Add a facet include.

Parameters:
name - The name.

getFacetExcludes

public Set<String> getFacetExcludes()
The set of facets to exclude.

Returns:
The set of facets to exclude.

addFacetExclude

public void addFacetExclude(String name)
Add a facet exclude.

Parameters:
name - The name.

isDisabled

public boolean isDisabled()
Specified by:
isDisabled in interface DeploymentModule
Overrides:
isDisabled in class BasicDeploymentModule

existsAnyJsonResourceMethod

protected boolean existsAnyJsonResourceMethod(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.


Copyright © 2015. All rights reserved.