diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_report_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_report_spec.rb
index 6c69f914f76f..b0f8ec0d7298 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_report_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_report_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/azure_report'
-require 'azure_report'
+require 'generated/azure_report'
include AzureReportModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb
index 6ff29ac47749..45d7abcd09ad 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_special_properties_spec.rb
@@ -5,7 +5,7 @@
require 'rspec'
require 'securerandom'
-require 'azure_special_properties'
+require 'generated/azure_special_properties'
include AzureSpecialPropertiesModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_url_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_url_spec.rb
index ef1b8322f3a1..7124691360b0 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_url_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/azure_url_spec.rb
@@ -5,7 +5,7 @@
require 'rspec'
require 'securerandom'
-require 'subscription_id_api_version'
+require 'generated/subscription_id_api_version'
include AzureUrlModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_more_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_more_spec.rb
index 29a5dff237a7..e1ef43d73651 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_more_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_more_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/custom_base_uri_more'
-require 'custom_base_url_more_options'
+require 'generated/custom_base_url_more_options'
require 'uri'
module CustomBaseUriMoreModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_spec.rb
index c3eb81c719d5..87896e127907 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/custom_base_uri_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/custom_base_uri'
-require 'custom_base_url'
+require 'generated/custom_base_url'
require 'uri'
module CustomBaseUriModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_exception_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_exception_spec.rb
index b7ac162949eb..4117dde4422e 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_exception_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_exception_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/head_exceptions'
require 'rspec'
-require 'head_exceptions'
+require 'generated/head_exceptions'
include HeadExceptionsModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_spec.rb
index 7b4cd203fb35..6be813c0508f 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/head_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/head'
require 'rspec'
-require 'head'
+require 'generated/head'
include HeadModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/lro_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/lro_spec.rb
index 02895779f142..d5701bc983b8 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/lro_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/lro_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/lro'
require 'rspec'
-require 'lro'
+require 'generated/lro'
include LroModule
include LroModule::Models
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb
index a6e6ea41726b..e78f08e8c533 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb
+++ b/AutoRest/Generators/Ruby/Azure.Ruby.Tests/RspecTests/paging_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/paging'
require 'rspec'
-require 'paging'
+require 'generated/paging'
include PagingModule
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
index d3aa58bea099..b70c7463d5e3 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
+++ b/AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
+using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
@@ -108,13 +109,13 @@ public override async Task Generate(ServiceClient serviceClient)
// Models
foreach (var model in serviceClient.ModelTypes)
{
- if ((model.Extensions.ContainsKey(AzureExtensions.ExternalExtension) &&
- (bool) model.Extensions[AzureExtensions.ExternalExtension])
+ if ((model.Extensions.ContainsKey(AzureExtensions.ExternalExtension) &&
+ (bool)model.Extensions[AzureExtensions.ExternalExtension])
|| model.Name == "Resource" || model.Name == "SubResource")
{
continue;
}
-
+
var modelTemplate = new ModelTemplate
{
Model = new AzureModelTemplateModel(model, serviceClient.ModelTypes),
@@ -136,28 +137,28 @@ public override async Task Generate(ServiceClient serviceClient)
// Requirements
var requirementsTemplate = new RequirementsTemplate
{
- Model = new AzureRequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace),
+ Model = new AzureRequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace, this.packageVersion),
};
await Write(requirementsTemplate, RubyCodeNamer.UnderscoreCase(this.packageName ?? this.sdkName) + ImplementationFileExtension);
-
- // Version File
- if(this.packageVersion != null)
+
+ // Version File
+ if (this.packageVersion != null)
{
var versionTemplate = new VersionTemplate
{
Model = new VersionTemplateModel(packageVersion),
};
- await Write(versionTemplate, Path.Combine(sdkPath, "version" + ImplementationFileExtension));
+ await Write(versionTemplate, Path.Combine(sdkPath, "version" + ImplementationFileExtension));
}
-
+
// Module Definition File
- if(Settings.Namespace != null)
+ if (Settings.Namespace != null)
{
var modTemplate = new ModuleDefinitionTemplate
{
Model = new ModuleDefinitionTemplateModel(Settings.Namespace),
};
- await Write(modTemplate, Path.Combine(sdkPath, "module_definition" + ImplementationFileExtension));
+ await Write(modTemplate, Path.Combine(sdkPath, "module_definition" + ImplementationFileExtension));
}
}
}
diff --git a/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs b/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
index 345d6e2f7e19..cf80bebf54c0 100644
--- a/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
+++ b/AutoRest/Generators/Ruby/Azure.Ruby/TemplateModels/AzureRequirementsTemplateModel.cs
@@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.
using System;
+using System.Globalization;
using Microsoft.Rest.Generator.ClientModel;
using Microsoft.Rest.Generator.Ruby;
@@ -31,8 +32,9 @@ protected override bool ExcludeModel(CompositeType model)
/// The name of the generated SDK, required for proper folder structuring.
/// The files extension.
/// The namespace of the SDK.
- public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns)
- : base(serviceClient, sdkName, filesExtension, ns)
+ /// The name of the package version to be used in creating a version.rb file.
+ public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns, string packageVersion)
+ : base(serviceClient, sdkName, filesExtension, ns, packageVersion)
{
}
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/array_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/array_spec.rb
index d85c50307e6a..c78494c9ec7e 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/array_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/array_spec.rb
@@ -4,7 +4,7 @@
$: << 'RspecTests/Generated/array'
require 'rspec'
-require 'body_array'
+require 'generated/body_array'
require 'helper'
module ArrayModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/bool_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/bool_spec.rb
index 3f1948f8a664..e1e20b9e28c5 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/bool_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/bool_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests'
$: << 'RspecTests/Generated/boolean'
-require 'body_boolean'
+require 'generated/body_boolean'
module BooleanModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/byte_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/byte_spec.rb
index a7a1f9f7a0bb..a0d24f67a003 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/byte_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/byte_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/byte'
-require 'body_byte'
+require 'generated/body_byte'
module ByteModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/complex_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/complex_spec.rb
index bf9ba30c52d8..2274cc9edeaa 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/complex_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/complex_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/complex'
require 'base64'
-require 'body_complex'
+require 'generated/body_complex'
module ComplexModule
include ComplexModule::Models
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/date_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/date_spec.rb
index 616f1289f90b..a14a62091661 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/date_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/date_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/date'
require 'rspec'
-require 'body_date'
+require 'generated/body_date'
describe DateModule::Date do
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_rfc1123_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_rfc1123_spec.rb
index 1ba32b69debc..883ed2f31162 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_rfc1123_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_rfc1123_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/datetime_rfc1123'
require 'rspec'
-require 'body_datetime_rfc1123'
+require 'generated/body_datetime_rfc1123'
require_relative './helper'
include DatetimeRfc1123Module
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_spec.rb
index 42e20c9a818b..2f77591d43b3 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/datetime_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/datetime'
require 'rspec'
-require 'body_datetime'
+require 'generated/body_datetime'
require_relative './helper'
include DatetimeModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/dictionary_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/dictionary_spec.rb
index 592efbc78dc1..ed86695c6429 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/dictionary_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/dictionary_spec.rb
@@ -4,7 +4,7 @@
$: << 'RspecTests'
require 'base64'
-require 'body_dictionary'
+require 'generated/body_dictionary'
require 'helper'
include DictionaryModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/header_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/header_spec.rb
index 6378ca13c6ed..91e2bcbced96 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/header_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/header_spec.rb
@@ -5,7 +5,7 @@
require "base64"
-require 'header'
+require 'generated/header'
module HeaderModule
include HeaderModule::Models
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/http_infrastructure_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/http_infrastructure_spec.rb
index e14e17d324a7..211f3cada7d1 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/http_infrastructure_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/http_infrastructure_spec.rb
@@ -4,7 +4,7 @@
$: << 'RspecTests'
require 'rspec'
-require 'http_infrastructure.rb'
+require 'generated/http_infrastructure.rb'
require 'helper'
module HttpInfrastructureModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/integer_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/integer_spec.rb
index f7556f6741a2..b8a55ad54fa7 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/integer_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/integer_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/integer'
-require 'body_integer'
+require 'generated/body_integer'
include IntegerModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/model_flattening_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/model_flattening_spec.rb
index 4f78dae9e224..679ff5e33af9 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/model_flattening_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/model_flattening_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/model_flattening'
require 'securerandom'
-require 'model_flattening'
+require 'generated/model_flattening'
include ModelFlatteningModule
include ModelFlatteningModule::Models
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/number_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/number_spec.rb
index 2d3ee83e457a..2027da0ee5c5 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/number_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/number_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/number'
-require 'body_number'
+require 'generated/body_number'
include NumberModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/parameter_grouping_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/parameter_grouping_spec.rb
index a17beabd5303..3ac8dbf28c07 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/parameter_grouping_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/parameter_grouping_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/parameter_grouping'
require 'rspec'
-require 'azure_parameter_grouping'
+require 'generated/azure_parameter_grouping'
include ParameterGroupingModule
include ParameterGroupingModule::Models
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_items_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_items_spec.rb
index 680aff9ccb5d..6c4411c51230 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_items_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_items_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/url_items'
-require 'url'
+require 'generated/url'
include UrlModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb
index 3c2676513fc9..3dfcf908e960 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/url'
-require 'url'
+require 'generated/url'
include UrlModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/query_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/query_spec.rb
index 0fac09f395dc..2e1e20634095 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/query_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/query_spec.rb
@@ -3,7 +3,7 @@
$: << 'RspecTests/url_query'
require 'rspec'
-require 'url'
+require 'generated/url'
include UrlModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/report_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/report_spec.rb
index 1fe06709bc53..72c5b92f9d11 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/report_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/report_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/report'
-require 'report'
+require 'generated/report'
include ReportModule
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/required_optional_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/required_optional_spec.rb
index fbcc0ecaf694..531dd672b534 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/required_optional_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/required_optional_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/required_optional'
-require 'required_optional'
+require 'generated/required_optional'
include RequiredOptionalModule
include RequiredOptionalModule::Models
diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/string_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/string_spec.rb
index 223d1cfdb6c1..3ee8fa777d43 100644
--- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/string_spec.rb
+++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/string_spec.rb
@@ -2,7 +2,7 @@
$: << 'RspecTests/Generated/string'
-require 'body_string'
+require 'generated/body_string'
include StringModule
diff --git a/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs b/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
index e111d37612e4..3e3a7fdc8c72 100644
--- a/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
+++ b/AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
@@ -13,6 +13,11 @@ namespace Microsoft.Rest.Generator.Ruby
///
public class RubyCodeGenerator : CodeGenerator
{
+ ///
+ /// Name of the generated sub-folder inside ourput directory.
+ ///
+ private const string GeneratedFolderName = "generated";
+
///
/// The name of the SDK. Determined in the following way:
/// if the parameter 'Name' is provided that it becomes the
@@ -25,7 +30,7 @@ public class RubyCodeGenerator : CodeGenerator
/// The name of the package version to be used in creating a version.rb file
///
protected readonly string packageVersion;
-
+
///
/// The name of the package name to be used in creating a version.rb file
///
@@ -74,6 +79,9 @@ public RubyCodeGenerator(Settings settings) : base(settings)
this.sdkName = RubyCodeNamer.UnderscoreCase(CodeNamer.RubyRemoveInvalidCharacters(this.sdkName));
this.sdkPath = this.packageName ?? this.sdkName;
this.modelsPath = Path.Combine(this.sdkPath, "models");
+
+ // AutoRest generated code for Ruby and Azure.Ruby generator will live inside "generated" sub-folder
+ settings.OutputDirectory = Path.Combine(settings.OutputDirectory, GeneratedFolderName);
}
///
@@ -190,28 +198,28 @@ await Write(enumTemplate,
// Requirements
var requirementsTemplate = new RequirementsTemplate
{
- Model = new RequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace),
+ Model = new RequirementsTemplateModel(serviceClient, this.packageName ?? this.sdkName, this.ImplementationFileExtension, this.Settings.Namespace, this.packageVersion),
};
await Write(requirementsTemplate, RubyCodeNamer.UnderscoreCase(this.packageName ?? this.sdkName) + ImplementationFileExtension);
-
+
// Version File
- if(!string.IsNullOrEmpty(this.packageVersion))
+ if (!string.IsNullOrEmpty(this.packageVersion))
{
var versionTemplate = new VersionTemplate
{
Model = new VersionTemplateModel(packageVersion),
};
- await Write(versionTemplate, Path.Combine(sdkPath, "version" + ImplementationFileExtension));
+ await Write(versionTemplate, Path.Combine(sdkPath, "version" + ImplementationFileExtension));
}
-
+
// Module Definition File
- if(!string.IsNullOrEmpty(Settings.Namespace))
+ if (!string.IsNullOrEmpty(Settings.Namespace))
{
var modTemplate = new ModuleDefinitionTemplate
{
Model = new ModuleDefinitionTemplateModel(Settings.Namespace),
};
- await Write(modTemplate, Path.Combine(sdkPath, "module_definition" + ImplementationFileExtension));
+ await Write(modTemplate, Path.Combine(sdkPath, "module_definition" + ImplementationFileExtension));
}
}
}
diff --git a/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs b/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
index 6fbcf8e55a1b..d38a1b73b7c8 100644
--- a/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
+++ b/AutoRest/Generators/Ruby/Ruby/TemplateModels/RequirementsTemplateModel.cs
@@ -16,6 +16,16 @@ namespace Microsoft.Rest.Generator.Ruby
///
public class RequirementsTemplateModel : ServiceClient
{
+ ///
+ /// Name of the generated sub-folder inside ourput directory.
+ ///
+ private const string GeneratedFolderName = "generated";
+
+ ///
+ /// Format for the autoload module.
+ ///
+ private const string AutoloadFormat = "autoload :{0},{1}'" + GeneratedFolderName + "/{2}/{3}'";
+
///
/// Number of spaces between class name and file name required for better readability.
///
@@ -30,12 +40,16 @@ public class RequirementsTemplateModel : ServiceClient
/// Files extensions.
///
private readonly string implementationFileExtension;
-
+
///
/// Namspace of the service client.
///
private readonly string ns;
+ ///
+ /// The name of the package version to be used in creating a version.rb file.
+ ///
+ private readonly string packageVersion;
///
/// Returns the ordered list of models. Ordered means that if some model has
@@ -87,7 +101,7 @@ private string GetAutoloadFormat(string typeName, string fileName)
spacing = sb.ToString();
}
- return string.Format("autoload :{0},{1}'{2}/{3}'", typeName, spacing, this.sdkName, fileName);
+ return string.Format(AutoloadFormat, typeName, spacing, this.sdkName, fileName);
}
///
@@ -107,10 +121,12 @@ protected virtual bool ExcludeModel(CompositeType model)
/// The name of the SDK.
/// The files extension.
/// The namespace of the SDK.
- public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension, string ns)
+ /// The name of the package version to be used in creating a version.rb file.
+ public RequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string implementationFileExtension, string ns, string packageVersion)
{
this.LoadFrom(serviceClient);
this.ns = ns;
+ this.packageVersion = packageVersion;
this.sdkName = sdkName;
this.implementationFileExtension = implementationFileExtension;
}
@@ -174,16 +190,22 @@ public virtual string GetDependencyGems()
require 'faraday-cookie_jar'
require 'concurrent'
require 'ms_rest'";
- if(!string.IsNullOrEmpty(this.ns))
+
+ if(!string.IsNullOrWhiteSpace(this.ns))
{
- return requirements
+ requirements = requirements
+ Environment.NewLine
- + string.Format(CultureInfo.InvariantCulture, "require '{0}/module_definition'", this.sdkName);
+ + string.Format(CultureInfo.InvariantCulture, "require '{0}/{1}/module_definition'", GeneratedFolderName, this.sdkName);
}
- else
+
+ if (!string.IsNullOrWhiteSpace(this.packageVersion))
{
- return requirements;
+ requirements = requirements
+ + Environment.NewLine
+ + string.Format(CultureInfo.InvariantCulture, "require '{0}/{1}/version'", GeneratedFolderName, this.sdkName);
}
+
+ return requirements;
}
}
}