From 8f4de5ce0d8b447e065ab91891d819752981b03b Mon Sep 17 00:00:00 2001 From: ZEROM22 Date: Mon, 20 Nov 2023 11:53:13 +0300 Subject: [PATCH] ruby: Naming/PredicateName correct --- .../ruby/app/controllers/home_controller.rb | 6 ++--- .../ruby/app/models/file_model.rb | 24 +++++++++---------- .../ruby/app/models/jwt_helper.rb | 2 +- .../ruby/app/models/service_converter.rb | 2 +- .../ruby/app/models/track_helper.rb | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/web/documentserver-example/ruby/app/controllers/home_controller.rb b/web/documentserver-example/ruby/app/controllers/home_controller.rb index 4e5ae852..443d2707 100755 --- a/web/documentserver-example/ruby/app/controllers/home_controller.rb +++ b/web/documentserver-example/ruby/app/controllers/home_controller.rb @@ -165,7 +165,7 @@ class HomeController < ApplicationController file = params[:file] params[:dmode] - if JwtHelper.is_enabled && JwtHelper.use_for_request + if JwtHelper.enabled? && JwtHelper.use_for_request jwt_header = HomeController.config_manager.jwt_header if request.headers[jwt_header] hdr = request.headers[jwt_header] @@ -281,7 +281,7 @@ class HomeController < ApplicationController user_address = params[:userAddress] is_embedded = params[:dmode] - if JwtHelper.is_enabled && is_embedded.nil? && !user_address.nil? && JwtHelper.use_for_request + if JwtHelper.enabled? && is_embedded.nil? && !user_address.nil? && JwtHelper.use_for_request jwt_header = HomeController.config_manager.jwt_header if request.headers[jwt_header] hdr = request.headers[jwt_header] @@ -434,7 +434,7 @@ class HomeController < ApplicationController link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{file_name}" } - data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled + data['token'] = JwtHelper.encode(data) if JwtHelper.enabled? render plain: data.to_json end diff --git a/web/documentserver-example/ruby/app/models/file_model.rb b/web/documentserver-example/ruby/app/models/file_model.rb index 97b2b635..938f079e 100755 --- a/web/documentserver-example/ruby/app/models/file_model.rb +++ b/web/documentserver-example/ruby/app/models/file_model.rb @@ -120,7 +120,7 @@ class FileModel document: { title: @file_name, url: download_url, - directUrl: is_enable_direct_url ? download_url(is_server_url: false) : '', + directUrl: enable_direct_url? ? download_url(is_server_url: false) : '', fileType: file_ext.delete('.'), key:, info: { @@ -193,7 +193,7 @@ class FileModel } } - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not config['token'] = JwtHelper.encode(config) # encode a payload object into a token and write it to the config end @@ -248,7 +248,7 @@ class FileModel data_obj['fileType'] = file_ext[1..file_ext.length] data_obj['key'] = cur_key data_obj['url'] = i == cur_ver ? doc_uri : DocumentHelper.get_historypath_uri(file_name, i, "prev#{file_ext}") - if is_enable_direct_url == true + if enable_direct_url? == true data_obj['directUrl'] = if i == cur_ver download_url(is_server_url: false) @@ -276,7 +276,7 @@ class FileModel prev = hist_data[(i - 2).to_s] # get the history data from the previous file version # write key and url information about previous file version with optional direct url - data obj['previous'] = if is_enable_direct_url == true + data obj['previous'] = if enable_direct_url? == true { # write key and url information about previous file version with optional directUrl fileType: prev['fileType'], key: prev['key'], @@ -295,7 +295,7 @@ class FileModel data_obj['changesUrl'] = DocumentHelper.get_historypath_uri(file_name, i - 1, 'diff.zip') end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the data object data_obj['token'] = JwtHelper.encode(data_obj) end @@ -321,7 +321,7 @@ class FileModel # image file type # server url to the image # direct url to the image - insert_image = if is_enable_direct_url == true + insert_image = if enable_direct_url? == true { fileType: 'png', # image file type url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image @@ -334,7 +334,7 @@ class FileModel } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the insert_image object insert_image['token'] = JwtHelper.encode(insert_image) end @@ -347,7 +347,7 @@ class FileModel # file type # server url to the compared file # direct url to the compared file - compare_file = if is_enable_direct_url == true + compare_file = if enable_direct_url? == true { fileType: 'docx', # file type # server url to the compared file @@ -363,7 +363,7 @@ class FileModel } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the compare_file object compare_file['token'] = JwtHelper.encode(compare_file) end @@ -376,7 +376,7 @@ class FileModel # file type # server url to the mail merge recipients file # direct url to the mail merge recipients file - data_spreadsheet = if is_enable_direct_url == true + data_spreadsheet = if enable_direct_url? == true { fileType: 'csv', # file type # server url to the mail merge recipients file @@ -392,7 +392,7 @@ class FileModel } end - if JwtHelper.is_enabled # check if a secret key to generate token exists or not + if JwtHelper.enabled? # check if a secret key to generate token exists or not # encode a payload object into a token and write it to the data_spreadsheet object data_spreadsheet['token'] = JwtHelper.encode(data_spreadsheet) end @@ -436,7 +436,7 @@ class FileModel end # get direct url existence flag - def is_enable_direct_url + def enable_direct_url? !@direct_url.nil? && @direct_url == 'true' end end diff --git a/web/documentserver-example/ruby/app/models/jwt_helper.rb b/web/documentserver-example/ruby/app/models/jwt_helper.rb index 1a76b114..48679d79 100644 --- a/web/documentserver-example/ruby/app/models/jwt_helper.rb +++ b/web/documentserver-example/ruby/app/models/jwt_helper.rb @@ -26,7 +26,7 @@ class JwtHelper class << self # check if a secret key to generate token exists or not - def is_enabled + def enabled? @jwt_secret && !@jwt_secret.empty? ? true : false end diff --git a/web/documentserver-example/ruby/app/models/service_converter.rb b/web/documentserver-example/ruby/app/models/service_converter.rb index e1731c29..39bbff8f 100755 --- a/web/documentserver-example/ruby/app/models/service_converter.rb +++ b/web/documentserver-example/ruby/app/models/service_converter.rb @@ -66,7 +66,7 @@ class ServiceConverter req.add_field('Accept', 'application/json') # set headers req.add_field('Content-Type', 'application/json') - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwt_header = ServiceConverter.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix diff --git a/web/documentserver-example/ruby/app/models/track_helper.rb b/web/documentserver-example/ruby/app/models/track_helper.rb index 120c4f4a..68918384 100755 --- a/web/documentserver-example/ruby/app/models/track_helper.rb +++ b/web/documentserver-example/ruby/app/models/track_helper.rb @@ -42,7 +42,7 @@ class TrackHelper file_data = JSON.parse(body) # parse file data # check if a secret key to generate token exists or not - if JwtHelper.is_enabled && JwtHelper.use_for_request + if JwtHelper.enabled? && JwtHelper.use_for_request in_header = false token = nil jwt_header = TrackHelper.config_manager.jwt_header; # get the authorization header from the config @@ -283,7 +283,7 @@ class TrackHelper req = Net::HTTP::Post.new(uri.request_uri) # create the post request req.add_field('Content-Type', 'application/json') # set headers - if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled + if JwtHelper.enabled? && JwtHelper.use_for_request # if the signature is enabled payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload jwt_header = TrackHelper.config_manager.jwt_header; # get signature authorization header # set it to the request with the Bearer prefix