Skip to content

Commit

Permalink
[Ruby - In Review] Restructuring generated Ruby & Azure.Ruby code int…
Browse files Browse the repository at this point in the history
…o generated sub-folder (Azure#1189)

* Restructuring generated Ruby & Azure.Ruby code into generated sub-folder

* Update Ruby and Azure.Ruby tests to look inside generated folder

* Moving version file back inside the sdkpath
  • Loading branch information
vishrutshah authored and fearthecowboy committed Jun 29, 2016
1 parent 987e8db commit 0c0e87b
Show file tree
Hide file tree
Showing 33 changed files with 91 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/azure_report'

require 'azure_report'
require 'generated/azure_report'

include AzureReportModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'rspec'
require 'securerandom'

require 'azure_special_properties'
require 'generated/azure_special_properties'

include AzureSpecialPropertiesModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'rspec'
require 'securerandom'

require 'subscription_id_api_version'
require 'generated/subscription_id_api_version'

include AzureUrlModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/custom_base_uri'

require 'custom_base_url'
require 'generated/custom_base_url'
require 'uri'

module CustomBaseUriModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/head_exceptions'

require 'rspec'
require 'head_exceptions'
require 'generated/head_exceptions'

include HeadExceptionsModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/head'

require 'rspec'
require 'head'
require 'generated/head'

include HeadModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/lro'

require 'rspec'
require 'lro'
require 'generated/lro'

include LroModule
include LroModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/paging'

require 'rspec'
require 'paging'
require 'generated/paging'

include PagingModule

Expand Down
23 changes: 12 additions & 11 deletions AutoRest/Generators/Ruby/Azure.Ruby/AzureRubyCodeGenerator.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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),
Expand All @@ -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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -31,8 +32,9 @@ protected override bool ExcludeModel(CompositeType model)
/// <param name="sdkName">The name of the generated SDK, required for proper folder structuring.</param>
/// <param name="filesExtension">The files extension.</param>
/// <param name="ns">The namespace of the SDK.</param>
public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns)
: base(serviceClient, sdkName, filesExtension, ns)
/// <param name="packageVersion">The name of the package version to be used in creating a version.rb file.</param>
public AzureRequirementsTemplateModel(ServiceClient serviceClient, string sdkName, string filesExtension, string ns, string packageVersion)
: base(serviceClient, sdkName, filesExtension, ns, packageVersion)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$: << 'RspecTests/Generated/array'

require 'rspec'
require 'body_array'
require 'generated/body_array'
require 'helper'

module ArrayModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests'
$: << 'RspecTests/Generated/boolean'

require 'body_boolean'
require 'generated/body_boolean'

module BooleanModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/byte'

require 'body_byte'
require 'generated/body_byte'

module ByteModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/complex'

require 'base64'
require 'body_complex'
require 'generated/body_complex'

module ComplexModule
include ComplexModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/date'

require 'rspec'
require 'body_date'
require 'generated/body_date'

describe DateModule::Date do

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/datetime_rfc1123'

require 'rspec'
require 'body_datetime_rfc1123'
require 'generated/body_datetime_rfc1123'
require_relative './helper'

include DatetimeRfc1123Module
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/datetime'

require 'rspec'
require 'body_datetime'
require 'generated/body_datetime'
require_relative './helper'

include DatetimeModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$: << 'RspecTests'

require 'base64'
require 'body_dictionary'
require 'generated/body_dictionary'
require 'helper'

include DictionaryModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


require "base64"
require 'header'
require 'generated/header'

module HeaderModule
include HeaderModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
$: << 'RspecTests'

require 'rspec'
require 'http_infrastructure.rb'
require 'generated/http_infrastructure.rb'
require 'helper'

module HttpInfrastructureModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/integer'

require 'body_integer'
require 'generated/body_integer'

include IntegerModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/model_flattening'

require 'securerandom'
require 'model_flattening'
require 'generated/model_flattening'

include ModelFlatteningModule
include ModelFlatteningModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/number'

require 'body_number'
require 'generated/body_number'

include NumberModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/Generated/parameter_grouping'

require 'rspec'
require 'azure_parameter_grouping'
require 'generated/azure_parameter_grouping'

include ParameterGroupingModule
include ParameterGroupingModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/url_items'

require 'url'
require 'generated/url'

include UrlModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/url'

require 'url'
require 'generated/url'

include UrlModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
$: << 'RspecTests/url_query'

require 'rspec'
require 'url'
require 'generated/url'

include UrlModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/report'

require 'report'
require 'generated/report'

include ReportModule

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/required_optional'

require 'required_optional'
require 'generated/required_optional'

include RequiredOptionalModule
include RequiredOptionalModule::Models
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

$: << 'RspecTests/Generated/string'

require 'body_string'
require 'generated/body_string'

include StringModule

Expand Down
Loading

0 comments on commit 0c0e87b

Please sign in to comment.