From dafc66d5d842b3338d6d5bca215a0264c30d1a71 Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Sun, 19 Nov 2023 02:38:42 +0300 Subject: [PATCH] ruby: Style/Documentation correct --- .../ruby/app/configuration/configuration.rb | 1 + .../app/configuration/configuration_tests.rb | 16 ++++++++++++++++ .../ruby/app/controllers/home_controller.rb | 1 + .../ruby/app/format/format.rb | 2 ++ .../ruby/app/format/format_tests.rb | 9 +++++++++ .../ruby/app/helpers/application_helper.rb | 1 + .../ruby/app/helpers/home_helper.rb | 1 + .../ruby/app/models/document_helper.rb | 1 + .../ruby/app/models/file_model.rb | 1 + .../ruby/app/models/file_utility.rb | 1 + .../ruby/app/models/jwt_helper.rb | 1 + .../ruby/app/models/service_converter.rb | 1 + .../ruby/app/models/track_helper.rb | 1 + .../ruby/app/models/users.rb | 2 ++ .../ruby/app/proxy/proxy.rb | 1 + .../ruby/app/proxy/proxy_tests.rb | 6 ++++++ .../ruby/config/application.rb | 1 + 17 files changed, 47 insertions(+) diff --git a/web/documentserver-example/ruby/app/configuration/configuration.rb b/web/documentserver-example/ruby/app/configuration/configuration.rb index c2c1846f..c4efd7fe 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration.rb @@ -22,6 +22,7 @@ require 'pathname' require 'sorbet-runtime' require 'uri' +# ConfigurationManager manages configuration settings for the application. class ConfigurationManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb index d98e8977..ccf94cdf 100644 --- a/web/documentserver-example/ruby/app/configuration/configuration_tests.rb +++ b/web/documentserver-example/ruby/app/configuration/configuration_tests.rb @@ -20,6 +20,7 @@ require 'test/unit' require_relative 'configuration' +# Enviroment module provides a mechanism for capturing and restoring the environment. module Enviroment def initialize(name) @env = ENV.to_hash @@ -31,6 +32,7 @@ module Enviroment end end +# For testing the ConfigurationManager class. class ConfigurationManagerTests < Test::Unit::TestCase def test_corresponds_the_latest_version config_manager = ConfigurationManager.new @@ -38,6 +40,7 @@ class ConfigurationManagerTests < Test::Unit::TestCase end end +# For testing the example_uri method of ConfigurationManager. class ConfigurationManagerExampleURITests < Test::Unit::TestCase include Enviroment @@ -55,6 +58,7 @@ class ConfigurationManagerExampleURITests < Test::Unit::TestCase end end +# For testing the document_server_public_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPublicURITests < Test::Unit::TestCase include Enviroment @@ -72,6 +76,7 @@ class ConfigurationManagerDocumentServerPublicURITests < Test::Unit::TestCase end end +# For testing the document_server_private_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPrivateURITests < Test::Unit::TestCase include Enviroment @@ -89,6 +94,7 @@ class ConfigurationManagerDocumentServerPrivateURITests < Test::Unit::TestCase end end +# For testing the document_server_api_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerAPIURITests < Test::Unit::TestCase include Enviroment @@ -112,6 +118,7 @@ class ConfigurationManagerDocumentServerAPIURITests < Test::Unit::TestCase end end +# For testing the document_server_preloader_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerPreloaderURITests < Test::Unit::TestCase include Enviroment @@ -135,6 +142,7 @@ class ConfigurationManagerDocumentServerPreloaderURITests < Test::Unit::TestCase end end +# For testing the document_server_command_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerCommandURITests < Test::Unit::TestCase include Enviroment @@ -158,6 +166,7 @@ class ConfigurationManagerDocumentServerCommandURITests < Test::Unit::TestCase end end +# For testing the document_server_converter_uri method of ConfigurationManager. class ConfigurationManagerDocumentServerConverterURITests < Test::Unit::TestCase include Enviroment @@ -181,6 +190,7 @@ class ConfigurationManagerDocumentServerConverterURITests < Test::Unit::TestCase end end +# For testing the jwt_secret method of ConfigurationManager. class ConfigurationManagerJWTSecretTests < Test::Unit::TestCase include Enviroment @@ -198,6 +208,7 @@ class ConfigurationManagerJWTSecretTests < Test::Unit::TestCase end end +# For testing the jwt_header method of ConfigurationManager. class ConfigurationManagerJWTHeaderTests < Test::Unit::TestCase include Enviroment @@ -215,6 +226,7 @@ class ConfigurationManagerJWTHeaderTests < Test::Unit::TestCase end end +# For testing the jwt_use_for_request method of ConfigurationManager. class ConfigurationManagerJWTUseForRequest < Test::Unit::TestCase include Enviroment @@ -232,6 +244,7 @@ class ConfigurationManagerJWTUseForRequest < Test::Unit::TestCase end end +# For testing the ssl_verify_peer_mode_enabled method of ConfigurationManager. class ConfigurationManagerSSLTests < Test::Unit::TestCase include Enviroment @@ -249,6 +262,7 @@ class ConfigurationManagerSSLTests < Test::Unit::TestCase end end +# For testing the storage_path method of ConfigurationManager. class ConfigurationManagerStoragePathTests < Test::Unit::TestCase include Enviroment @@ -275,6 +289,7 @@ class ConfigurationManagerStoragePathTests < Test::Unit::TestCase end end +# For testing the maximum_file_size method of ConfigurationManager. class ConfigurationManagerMaximumFileSizeTests < Test::Unit::TestCase include Enviroment @@ -292,6 +307,7 @@ class ConfigurationManagerMaximumFileSizeTests < Test::Unit::TestCase end end +# For testing the convertation_timeout method of ConfigurationManager. class ConfigurationManagerConversionTimeoutTests < Test::Unit::TestCase def test_assigns_a_default_value config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 7f1e5c09..fb1dcbd6 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -21,6 +21,7 @@ require 'net/http' require 'mimemagic' require_relative '../configuration/configuration' +# Handling requests controller class HomeController < ApplicationController @config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/format/format.rb b/web/documentserver-example/ruby/app/format/format.rb index 59bb56ea..03f1a04e 100644 --- a/web/documentserver-example/ruby/app/format/format.rb +++ b/web/documentserver-example/ruby/app/format/format.rb @@ -20,6 +20,7 @@ require 'pathname' require 'sorbet-runtime' +# Struct representing a document format with properties. class Format < T::Struct extend T::Sig @@ -40,6 +41,7 @@ class Format < T::Struct end end +# FormatManager is responsible for managing document formats and providing various lists of supported extensions. class FormatManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/format/format_tests.rb b/web/documentserver-example/ruby/app/format/format_tests.rb index 62fba266..8f199c24 100644 --- a/web/documentserver-example/ruby/app/format/format_tests.rb +++ b/web/documentserver-example/ruby/app/format/format_tests.rb @@ -21,6 +21,7 @@ require 'json' require 'test/unit' require_relative 'format' +# Test case for the Format class. class FormatTests < Test::Unit::TestCase def test_generates_extension content = @@ -39,6 +40,7 @@ class FormatTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "all" formats. class FormatManagerAllTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -46,6 +48,7 @@ class FormatManagerAllTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "documents" formats. class FormatManagerDocumentsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -53,6 +56,7 @@ class FormatManagerDocumentsTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "presentations" formats. class FormatManagerPresentationsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -60,6 +64,7 @@ class FormatManagerPresentationsTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "spreadsheets" formats. class FormatManagerSpreadsheetsTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -67,6 +72,7 @@ class FormatManagerSpreadsheetsTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "all convertible" formats. class FormatManagerConvertibleTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -74,6 +80,7 @@ class FormatManagerConvertibleTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "all editable" formats. class FormatManagerEditableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -81,6 +88,7 @@ class FormatManagerEditableTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "all viewable" formats. class FormatManagerViewableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new @@ -88,6 +96,7 @@ class FormatManagerViewableTests < Test::Unit::TestCase end end +# Test case for the FormatManager class, checks availability "all filable" formats. class FormatManagerFilableTests < Test::Unit::TestCase def test_loads format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/helpers/application_helper.rb b/web/documentserver-example/ruby/app/helpers/application_helper.rb index 8e77b5bd..4715a54e 100644 --- a/web/documentserver-example/ruby/app/helpers/application_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/application_helper.rb @@ -16,5 +16,6 @@ # limitations under the License. # +# Helper for application module ApplicationHelper end diff --git a/web/documentserver-example/ruby/app/helpers/home_helper.rb b/web/documentserver-example/ruby/app/helpers/home_helper.rb index de869727..71cde17a 100644 --- a/web/documentserver-example/ruby/app/helpers/home_helper.rb +++ b/web/documentserver-example/ruby/app/helpers/home_helper.rb @@ -16,5 +16,6 @@ # limitations under the License. # +# Helper for home module HomeHelper end diff --git a/web/documentserver-example/ruby/app/models/document_helper.rb b/web/documentserver-example/ruby/app/models/document_helper.rb index b31fec82..e1cc3495 100755 --- a/web/documentserver-example/ruby/app/models/document_helper.rb +++ b/web/documentserver-example/ruby/app/models/document_helper.rb @@ -19,6 +19,7 @@ require_relative '../configuration/configuration' require_relative '../format/format' +# Class that provides various utility methods related to documents. class DocumentHelper @config_manager = ConfigurationManager.new @format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index fab5a02f..afd86c1f 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -18,6 +18,7 @@ require_relative '../configuration/configuration' +# Class for handling file-related operations and information. class FileModel attr_accessor :file_name, :mode, :type, :user_ip, :lang, :user, :action_data, :direct_url attr_reader :config_manager diff --git a/web/documentserver-example/ruby/app/models/file_utility.rb b/web/documentserver-example/ruby/app/models/file_utility.rb index b25c3d3b..52551f2a 100644 --- a/web/documentserver-example/ruby/app/models/file_utility.rb +++ b/web/documentserver-example/ruby/app/models/file_utility.rb @@ -18,6 +18,7 @@ require_relative '../format/format' +# Determination file type based on extensions, utilizing `@format_manager` for format management. class FileUtility @format_manager = FormatManager.new diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 1ca70519..1a76b114 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -19,6 +19,7 @@ require 'jwt' require_relative '../configuration/configuration' +# Helper class for JSON Web Token (JWT) operations, including encoding and decoding. class JwtHelper @jwt_secret = ConfigurationManager.new.jwt_secret @token_use_for_request = ConfigurationManager.new.jwt_use_for_request diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index 15db3f25..c5475d6c 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -18,6 +18,7 @@ require_relative '../configuration/configuration' +# Class responsible for converting documents using a document conversion service. class ServiceConverter @config_manager = ConfigurationManager.new diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 558850dd..a396ccd2 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -21,6 +21,7 @@ require 'uri' require_relative '../configuration/configuration' require_relative '../proxy/proxy' +# Helper class for managing document tracking functionalities, such as saving and processing documents. class TrackHelper @config_manager = ConfigurationManager.new @proxy_manager = ProxyManager.new(config_manager: @config_manager) diff --git a/web/documentserver-example/ruby/app/models/users.rb b/web/documentserver-example/ruby/app/models/users.rb index 146dee2c..cb58a04e 100644 --- a/web/documentserver-example/ruby/app/models/users.rb +++ b/web/documentserver-example/ruby/app/models/users.rb @@ -16,6 +16,7 @@ # limitations under the License. # +# Represents a user with various attributes class User attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, :deniedPermissions, :descriptions, :templates, :avatar @@ -37,6 +38,7 @@ class User end end +# Manages user-related data and operations. class Users @descr_user_1 = [ 'File author by default', diff --git a/web/documentserver-example/ruby/app/proxy/proxy.rb b/web/documentserver-example/ruby/app/proxy/proxy.rb index fd5a364c..8fee7df3 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy.rb @@ -21,6 +21,7 @@ require 'sorbet-runtime' require 'uri' require_relative '../configuration/configuration' +# Class manages URI resolution, redirecting public URLs to private ones based on the configuration. class ProxyManager extend T::Sig diff --git a/web/documentserver-example/ruby/app/proxy/proxy_tests.rb b/web/documentserver-example/ruby/app/proxy/proxy_tests.rb index e51d69d8..2240d09b 100644 --- a/web/documentserver-example/ruby/app/proxy/proxy_tests.rb +++ b/web/documentserver-example/ruby/app/proxy/proxy_tests.rb @@ -20,7 +20,9 @@ require 'test/unit' require_relative 'proxy' +# Test case for ProxyManager resolving URIs that refer to public and non-public URLs. class ProxyManagerRefersTests < Test::Unit::TestCase + # Mocked configuration manager for testing. class MockedConfigurationManager < ConfigurationManager def document_server_public_uri URI('http://localhost') @@ -31,6 +33,7 @@ class ProxyManagerRefersTests < Test::Unit::TestCase end end + # Test case to ensure resolving a URI that refers to the public URI. def test_resolves_a_uri_that_refers_to_the_public_uri config_manager = MockedConfigurationManager.new proxy_manager = ProxyManager.new(config_manager:) @@ -43,13 +46,16 @@ class ProxyManagerRefersTests < Test::Unit::TestCase end end +# Test case for ProxyManager resolving a URL that does not refer to the public URL. class ProxyManagerDoesNotRefersTests < Test::Unit::TestCase + # Mocked configuration manager for testing. class MockedConfigurationManager < ConfigurationManager def document_server_public_uri URI('http://localhost') end end + # Test case to ensure resolving a URL that does not refer to the public URL. def test_resolves_a_url_that_does_not_refers_to_the_public_url config_manager = MockedConfigurationManager.new proxy_manager = ProxyManager.new(config_manager:) diff --git a/web/documentserver-example/ruby/config/application.rb b/web/documentserver-example/ruby/config/application.rb index 94076a0f..f9c59aa3 100644 --- a/web/documentserver-example/ruby/config/application.rb +++ b/web/documentserver-example/ruby/config/application.rb @@ -11,6 +11,7 @@ Bundler.require(*Rails.groups) require 'securerandom' +# Configuration for the Rails application. class Application < Rails::Application config.middleware.insert_before 0, Rack::Cors do allow do