/// <summary> /// Initializes a new instance of the class RubyCodeGenerator. /// </summary> /// <param name="settings">The settings.</param> public RubyCodeGenerator(Settings settings) : base(settings) { CodeNamer = new RubyCodeNamer(); this.packageVersion = Settings.PackageVersion; this.packageName = Settings.PackageName; if (Settings.CustomSettings.ContainsKey("Name")) { this.sdkName = Settings.CustomSettings["Name"]; } if (sdkName == null) { this.sdkName = Path.GetFileNameWithoutExtension(Settings.Input); } if (sdkName == null) { sdkName = "client"; } this.sdkName = RubyCodeNamer.UnderscoreCase(CodeNamer.RubyRemoveInvalidCharacters(this.sdkName)); this.sdkPath = this.packageName ?? this.sdkName; this.modelsPath = Path.Combine(this.sdkPath, "models"); }
/// <summary> /// Initializes a new instance of the class RubyCodeGenerator. /// </summary> /// <param name="settings">The settings.</param> public RubyCodeGenerator(Settings settings) : base(settings) { CodeNamer = new RubyCodeNamer(); this.packageVersion = Settings.PackageVersion; this.packageName = Settings.PackageName; if (Settings.CustomSettings.ContainsKey("Name")) { this.sdkName = Settings.CustomSettings["Name"].ToString(); } if (sdkName == null) { this.sdkName = Path.GetFileNameWithoutExtension(Settings.Input); } if (sdkName == null) { sdkName = "client"; } 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); }
public string GetOperationsRequiredFiles() { var sb = new IndentedStringBuilder(); this.MethodGroups.ForEach(method => sb.AppendLine("{0}", this.GetRequiredFormat(RubyCodeNamer.UnderscoreCase(method) + ".rb"))); return(sb.ToString()); }
/// <summary> /// Generates C# code for service client. /// </summary> /// <param name="serviceClient">The service client.</param> /// <returns>Async task for generating SDK files.</returns> public override async Task Generate(ServiceClient serviceClient) { // Service client var serviceClientTemplate = new ServiceClientTemplate { Model = new ServiceClientTemplateModel(serviceClient), }; await Write(serviceClientTemplate, Path.Combine(sdkPath, RubyCodeNamer.UnderscoreCase(serviceClient.Name) + ImplementationFileExtension)); // Method groups foreach (var group in serviceClient.MethodGroups) { var groupTemplate = new MethodGroupTemplate { Model = new MethodGroupTemplateModel(serviceClient, group), }; await Write(groupTemplate, Path.Combine(sdkPath, RubyCodeNamer.UnderscoreCase(group) + ImplementationFileExtension)); } // Models foreach (var model in serviceClient.ModelTypes) { var modelTemplate = new ModelTemplate { Model = new ModelTemplateModel(model, serviceClient.ModelTypes) }; await Write(modelTemplate, Path.Combine(modelsPath, RubyCodeNamer.UnderscoreCase(model.Name) + ImplementationFileExtension)); } // Enums foreach (var enumType in serviceClient.EnumTypes) { var enumTemplate = new EnumTemplate { Model = new EnumTemplateModel(enumType), }; await Write(enumTemplate, Path.Combine(modelsPath, RubyCodeNamer.UnderscoreCase(enumTemplate.Model.TypeDefinitionName) + ImplementationFileExtension)); } // Requirements var requirementsTemplate = new RequirementsTemplate { Model = new RequirementsTemplateModel(serviceClient, sdkName, this.ImplementationFileExtension), }; await Write(requirementsTemplate, RubyCodeNamer.UnderscoreCase(sdkName) + ImplementationFileExtension); }
/// <summary> /// Initializes a new instance of the class RubyCodeGenerator. /// </summary> /// <param name="settings">The settings.</param> public RubyCodeGenerator(Settings settings) : base(settings) { CodeNamer = new RubyCodeNamer(); if (Settings.CustomSettings.ContainsKey("Name")) { sdkName = Settings.CustomSettings["Name"]; } else { sdkName = Path.GetFileNameWithoutExtension(Settings.Input); } sdkName = RubyCodeNamer.UnderscoreCase(CodeNamer.RubyRemoveInvalidCharacters(sdkName)); sdkPath = sdkName; modelsPath = Path.Combine(sdkPath, "models"); }
/// <summary> /// Initializes a new instance of the class RubyCodeGenerator. /// </summary> /// <param name="settings">The settings.</param> public RubyCodeGenerator(Settings settings) : base(settings) { codeNamer = new RubyCodeNamer(); }
public RubyCodeGenerator(Settings settings) : base(settings) { namingFramework = new RubyCodeNamer(); }
/// <summary> /// Generates Ruby code for service client. /// </summary> /// <param name="serviceClient">The service client.</param> /// <returns>Async task for generating SDK files.</returns> public override async Task Generate(ServiceClient serviceClient) { // Service client var serviceClientTemplate = new ServiceClientTemplate { Model = new ServiceClientTemplateModel(serviceClient), }; await Write(serviceClientTemplate, Path.Combine(sdkPath, RubyCodeNamer.UnderscoreCase(serviceClient.Name) + ImplementationFileExtension)); // Method groups foreach (var group in serviceClient.MethodGroups) { var groupTemplate = new MethodGroupTemplate { Model = new MethodGroupTemplateModel(serviceClient, group), }; await Write(groupTemplate, Path.Combine(sdkPath, RubyCodeNamer.UnderscoreCase(group) + ImplementationFileExtension)); } // Models foreach (var model in serviceClient.ModelTypes) { var modelTemplate = new ModelTemplate { Model = new ModelTemplateModel(model, serviceClient.ModelTypes) }; await Write(modelTemplate, Path.Combine(modelsPath, RubyCodeNamer.UnderscoreCase(model.Name) + ImplementationFileExtension)); } // Enums foreach (var enumType in serviceClient.EnumTypes) { var enumTemplate = new EnumTemplate { Model = new EnumTemplateModel(enumType), }; await Write(enumTemplate, Path.Combine(modelsPath, RubyCodeNamer.UnderscoreCase(enumTemplate.Model.TypeDefinitionName) + ImplementationFileExtension)); } // Requirements var requirementsTemplate = new RequirementsTemplate { 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 (!string.IsNullOrEmpty(this.packageVersion)) { var versionTemplate = new VersionTemplate { Model = new VersionTemplateModel(packageVersion), }; await Write(versionTemplate, Path.Combine(sdkPath, "version" + ImplementationFileExtension)); } // Module Definition File if (!string.IsNullOrEmpty(Settings.Namespace)) { var modTemplate = new ModuleDefinitionTemplate { Model = new ModuleDefinitionTemplateModel(Settings.Namespace), }; await Write(modTemplate, Path.Combine(sdkPath, "module_definition" + ImplementationFileExtension)); } }
/// <summary> /// Returns the list of model files for 'autoloading' them. /// </summary> /// <returns>Model files list in form of string.</returns> public string GetModelsRequiredFiles() { var sb = new IndentedStringBuilder(); this.GetOrderedModels() .Where(m => !ExcludeModel(m)) .ForEach(model => sb.AppendLine(this.GetAutoloadFormat(model.Name, "models/" + RubyCodeNamer.UnderscoreCase(model.Name) + this.implementationFileExtension))); this.EnumTypes.ForEach(enumType => sb.AppendLine(this.GetAutoloadFormat(enumType.Name, "models/" + RubyCodeNamer.UnderscoreCase(enumType.Name) + this.implementationFileExtension))); return(sb.ToString()); }
/// <summary> /// Returns a list of methods groups for 'autoloading' them. /// </summary> /// <returns>Method groups list in form of string.</returns> public string GetOperationsRequiredFiles() { var sb = new IndentedStringBuilder(); this.MethodGroups.ForEach(method => sb.AppendLine("{0}", this.GetAutoloadFormat(method, RubyCodeNamer.UnderscoreCase(method) + this.implementationFileExtension))); return(sb.ToString()); }
/// <summary> /// Returns the API client fils for 'autoloading'. /// </summary> /// <returns>The API client client name in form of string.</returns> public string GetClientRequiredFile() { return(this.GetAutoloadFormat(this.Name, RubyCodeNamer.UnderscoreCase(this.Name) + this.implementationFileExtension)); }
public string GetModelsRequiredFiles() { var sb = new IndentedStringBuilder(); this.GetOrderedModels().Where(m => !m.Extensions.ContainsKey(ExternalExtension)).ForEach(model => sb.AppendLine("{0}", this.GetRequiredFormat("models/" + RubyCodeNamer.UnderscoreCase(model.Name) + ".rb"))); this.EnumTypes.ForEach(enumType => sb.AppendLine(this.GetRequiredFormat("models/" + RubyCodeNamer.UnderscoreCase(enumType.Name) + ".rb"))); return(sb.ToString()); }
public string GetClientRequiredFile() { return(this.GetRequiredFormat(RubyCodeNamer.UnderscoreCase(this.Name) + ".rb")); }