diff --git a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
index 1f2061affd..42c6686cc0 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
+++ b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
@@ -141,7 +141,7 @@ public override async Task Generate(ServiceClient serviceClient)
// Requirements
var requirementsTemplate = new RequirementsTemplate
{
- Model = new AzureRequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension),
+ Model = new AzureRequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace),
};
await Write(requirementsTemplate, RubyCodeNamer.UnderscoreCase(this.packageName ?? this.sdkName) + ImplementationFileExtension);
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs b/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
index 2b20dab125..345d6e2f7e 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
+++ b/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
@@ -30,8 +30,9 @@ protected override bool ExcludeModel(CompositeType model)
/// The service client (main point of access to SDK).
/// The name of the generated SDK, required for proper folder structuring.
/// The files extension.
- public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension)
- : base(serviceClient, sdkName, filesExtension)
+ /// The namespace of the SDK.
+ public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns)
+ : base(serviceClient, sdkName, filesExtension, ns)
{
}
diff --git a/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs b/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
index 31821f2795..5b875665df 100644
--- a/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
+++ b/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
@@ -189,12 +189,12 @@ await Write(enumTemplate,
// Requirements
var requirementsTemplate = new RequirementsTemplate
{
- Model = new RequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension),
+ Model = new RequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace),
};
await Write(requirementsTemplate, RubyCodeNamer.UnderscoreCase(this.packageName ?? this.sdkName) + ImplementationFileExtension);
// Version File
- if(this.packageVersion != null)
+ if(!string.IsNullOrEmpty(this.packageVersion))
{
var versionTemplate = new VersionTemplate
{
@@ -204,7 +204,7 @@ await Write(enumTemplate,
}
// Module Definition File
- if(Settings.Namespace != null)
+ if(!string.IsNullOrEmpty(Settings.Namespace))
{
var modTemplate = new ModuleDefinitionTemplate
{
diff --git a/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs b/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
index ed1534776a..6fbcf8e55a 100644
--- a/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
+++ b/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
@@ -6,6 +6,8 @@
using System.Text;
using Microsoft.Rest.Generator.ClientModel;
using Microsoft.Rest.Generator.Utilities;
+using System;
+using System.Globalization;
namespace Microsoft.Rest.Generator.Ruby
{
@@ -28,6 +30,12 @@ public class RequirementsTemplateModel : ServiceClient
/// Files extensions.
///
private readonly string implementationFileExtension;
+
+ ///
+ /// Namspace of the service client.
+ ///
+ private readonly string ns;
+
///
/// Returns the ordered list of models. Ordered means that if some model has
@@ -98,9 +106,11 @@ protected virtual bool ExcludeModel(CompositeType model)
/// The service client.
/// The name of the SDK.
/// The files extension.
- public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension)
+ /// The namespace of the SDK.
+ public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension, string ns)
{
this.LoadFrom(serviceClient);
+ this.ns = ns;
this.sdkName = sdkName;
this.implementationFileExtension = implementationFileExtension;
}
@@ -151,7 +161,7 @@ public string GetModelsRequiredFiles()
/// The list of 'required' gems in form of string.
public virtual string GetDependencyGems()
{
- return @"require 'uri'
+ var requirements = @"require 'uri'
require 'cgi'
require 'date'
require 'json'
@@ -164,6 +174,16 @@ public virtual string GetDependencyGems()
require 'faraday-cookie_jar'
require 'concurrent'
require 'ms_rest'";
+ if(!string.IsNullOrEmpty(this.ns))
+ {
+ return requirements
+ + Environment.NewLine
+ + string.Format(CultureInfo.InvariantCulture, "require '{0}/module_definition'", this.sdkName);
+ }
+ else
+ {
+ return requirements;
+ }
}
}
}
diff --git a/ChangeLog.md b/ChangeLog.md
index 23a345a70f..c4affb34a9 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -1,3 +1,6 @@
+## VNext (not released yet)
+* Fix ruby require module_definition if namespace is specified. See [#831](https://github.com/Azure/autorest/issues/831)
+
##2016.03.04 Version 0.15.0
* Added Java code generator!
* Added support for constants whenever parameters or properties are marked as required and have only one enum value (#281, #488)