Skip to content

Commit

Permalink
generate require module_definition when namespace is present
Browse files Browse the repository at this point in the history
  • Loading branch information
devigned committed Mar 15, 2016
1 parent 8d5a0fa commit 9c9e7f6
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ protected override bool ExcludeModel(CompositeType model)
/// <param name="serviceClient">The service client (main point of access to SDK).</param>
/// <param name="sdkName">The name of the generated SDK, required for proper folder structuring.</param>
/// <param name="filesExtension">The files extension.</param>
public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension)
: base(serviceClient, sdkName, filesExtension)
/// <param name="ns">The namespace of the SDK.</param>
public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns)
: base(serviceClient, sdkName, filesExtension, ns)
{
}

Expand Down
6 changes: 3 additions & 3 deletions AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -204,7 +204,7 @@ await Write(enumTemplate,
}

// Module Definition File
if(Settings.Namespace != null)
if(!string.IsNullOrEmpty(Settings.Namespace))
{
var modTemplate = new ModuleDefinitionTemplate
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -28,6 +30,12 @@ public class RequirementsTemplateModel : ServiceClient
/// Files extensions.
/// </summary>
private readonly string implementationFileExtension;

/// <summary>
/// Namspace of the service client.
/// </summary>
private readonly string ns;


/// <summary>
/// Returns the ordered list of models. Ordered means that if some model has
Expand Down Expand Up @@ -98,9 +106,11 @@ protected virtual bool ExcludeModel(CompositeType model)
/// <param name="serviceClient">The service client.</param>
/// <param name="sdkName">The name of the SDK.</param>
/// <param name="implementationFileExtension">The files extension.</param>
public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension)
/// <param name="ns">The namespace of the SDK.</param>
public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension, string ns)
{
this.LoadFrom(serviceClient);
this.ns = ns;
this.sdkName = sdkName;
this.implementationFileExtension = implementationFileExtension;
}
Expand Down Expand Up @@ -151,7 +161,7 @@ public string GetModelsRequiredFiles()
/// <returns>The list of 'required' gems in form of string.</returns>
public virtual string GetDependencyGems()
{
return @"require 'uri'
var requirements = @"require 'uri'
require 'cgi'
require 'date'
require 'json'
Expand All @@ -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;
}
}
}
}
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down

0 comments on commit 9c9e7f6

Please sign in to comment.