ruby: Style/HashSyntax correct

This commit is contained in:
ZEROM22
2023-11-15 11:07:09 +03:00
parent a407b2b9c7
commit 83843342d4
7 changed files with 141 additions and 141 deletions

View File

@ -1,24 +1,24 @@
source 'https://rubygems.org'
gem 'byebug', '~> 11.1', :groups => %i[development test]
gem 'byebug', '~> 11.1', groups: %i[development test]
gem 'coffee-rails', '~> 5.0'
gem 'dalli', '~> 3.2', :group => :development
gem 'dalli', '~> 3.2', group: :development
gem 'jbuilder', '~> 2.11'
gem 'jquery-rails', '~> 4.5'
gem 'jwt', '~> 2.7'
gem 'mimemagic', github: 'mimemagicrb/mimemagic', ref: '01f92d86d15d85cfd0f20dabd025dcbd36a8a60f'
gem 'rack-cors', '~> 2.0'
gem 'rails', '~> 7.0.8'
gem 'rubocop', '~> 1.52', :group => :development
gem 'rubocop', '~> 1.52', group: :development
gem 'sass-rails', '~> 6.0'
gem 'sdoc', '~> 2.6', :group => :doc
gem 'sdoc', '~> 2.6', group: :doc
gem 'sorbet-runtime', '~> 0.5.10871'
gem 'test-unit', '~> 3.6', :groups => %i[development test]
gem 'test-unit', '~> 3.6', groups: %i[development test]
gem 'turbolinks', '~> 5.2'
gem 'tzinfo-data', '~> 1.2023'
gem 'uglifier', '~> 4.2'
gem 'uuid', '~> 2.3'
gem 'web-console', '~> 4.2', :groups => %i[development test]
gem 'web-console', '~> 4.2', groups: %i[development test]
gem 'webrick', '~> 1.8'
# Unfortunately, Sorbet only supports Darwin and Linux-based systems.
@ -28,6 +28,6 @@ gem 'webrick', '~> 1.8'
# https://github.com/sorbet/sorbet/issues/4011
# https://github.com/sorbet/sorbet/issues/4119
install_if -> { RUBY_PLATFORM =~ /darwin/ || RUBY_PLATFORM =~ /x86_64/ } do
gem 'sorbet', '~> 0.5.10871', :group => :development
gem 'tapioca', '~> 0.11.6', :group => :development
gem 'sorbet', '~> 0.5.10871', group: :development
gem 'tapioca', '~> 0.11.6', group: :development
end

View File

@ -31,7 +31,7 @@ class HomeController < ApplicationController
def editor
DocumentHelper.init(request.remote_ip, request.base_url)
user = Users.get_user(params[:userId])
@file = FileModel.new(:file_name => File.basename(params[:fileName]), :mode => params[:editorsMode], :type => params[:editorsType], :user_ip => request.remote_ip, :lang => cookies[:ulang], :user => user, :action_data => params[:actionLink], :direct_url => params[:directUrl])
@file = FileModel.new(file_name: File.basename(params[:fileName]), mode: params[:editorsMode], type: params[:editorsType], user_ip: request.remote_ip, lang: cookies[:ulang], user:, action_data: params[:actionLink], direct_url: params[:directUrl])
end
# creating a sample document
@ -39,7 +39,7 @@ class HomeController < ApplicationController
DocumentHelper.init(request.remote_ip, request.base_url)
user = Users.get_user(params[:userId])
file_name = DocumentHelper.create_demo(params[:fileExt], params[:sample], user)
redirect_to :controller => 'home', :action => 'editor', :fileName => file_name, :userId => user.id
redirect_to controller: 'home', action: 'editor', fileName: file_name, userId: user.id
end
# uploading a file
@ -154,11 +154,11 @@ class HomeController < ApplicationController
hdr.slice!(0, 'Bearer '.length)
token = JwtHelper.decode(hdr)
if !token || token.eql?('')
render plain: 'JWT validation failed', :status => 403
render plain: 'JWT validation failed', status: 403
return
end
else
render plain: 'JWT validation failed', :status => 403
render plain: 'JWT validation failed', status: 403
return
end
end
@ -171,7 +171,7 @@ class HomeController < ApplicationController
response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type
response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file)}"
send_file file_path, :x_sendfile => true
send_file file_path, x_sendfile: true
rescue StandardError => ex
render plain: '{ "error": "File not found"}'
@ -254,7 +254,7 @@ class HomeController < ApplicationController
response.headers['Content-Type'] = MimeMagic.by_path(csvPath).type
response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}"
send_file csvPath, :x_sendfile => true
send_file csvPath, x_sendfile: true
end
# downloading a file
@ -272,7 +272,7 @@ class HomeController < ApplicationController
token = JwtHelper.decode(hdr)
end
if !token || token.eql?('')
render plain: 'JWT validation failed', :status => 403
render plain: 'JWT validation failed', status: 403
return
end
end
@ -287,7 +287,7 @@ class HomeController < ApplicationController
response.headers['Content-Type'] = MimeMagic.by_path(file_path).eql?(nil) ? nil : MimeMagic.by_path(file_path).type
response.headers['Content-Disposition'] = "attachment;filename*=UTF-8''#{ERB::Util.url_encode(file_name)}"
send_file file_path, :x_sendfile => true
send_file file_path, x_sendfile: true
rescue StandardError => ex
render plain: '{ "error": "File not found"}'
@ -347,7 +347,7 @@ class HomeController < ApplicationController
newfilename += orig_ext if orig_ext != cur_ext
meta = {
:title => newfilename
title: newfilename
}
json_data = TrackHelper.command_request('meta', dockey, meta)
@ -400,16 +400,16 @@ class HomeController < ApplicationController
end
data = {
:fileType => File.extname(fileName).downcase.delete('.'),
:key => ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"),
:url => DocumentHelper.get_download_url(fileName),
:directUrl => body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil,
:referenceData => {
:instanceId => DocumentHelper.get_server_url(false),
:fileKey => { :fileName => fileName, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json
fileType: File.extname(fileName).downcase.delete('.'),
key: ServiceConverter.generate_revision_id("#{"#{DocumentHelper.cur_user_host_address(nil)}/#{fileName}"}.#{File.mtime(DocumentHelper.storage_path(fileName, nil))}"),
url: DocumentHelper.get_download_url(fileName),
directUrl: body['directUrl'] ? DocumentHelper.get_download_url(fileName, false) : nil,
referenceData: {
instanceId: DocumentHelper.get_server_url(false),
fileKey: { fileName:, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json
},
:path => fileName,
:link => "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}"
path: fileName,
link: "#{DocumentHelper.get_server_url(false)}/editor?fileName=#{fileName}"
}
data['token'] = JwtHelper.encode(data) if JwtHelper.is_enabled

View File

@ -179,9 +179,9 @@ class DocumentHelper
# write user name, user uid and the creation time to the json object
json = {
:created => Time.now.to_formatted_s(:db),
:uid => uid,
:uname => uname
created: Time.now.to_formatted_s(:db),
uid:,
uname:
}
# write file meta information to the createdInfo.json file

View File

@ -97,87 +97,87 @@ class FileModel
templatesImageUrl = DocumentHelper.get_template_image_url(document_type) # templates image url in the "From Template" section
templates = [
{
:image => '',
:title => 'Blank',
:url => create_url
image: '',
title: 'Blank',
url: create_url
},
{
:image => templatesImageUrl,
:title => 'With sample content',
:url => "#{create_url}&sample=true"
image: templatesImageUrl,
title: 'With sample content',
url: "#{create_url}&sample=true"
}
]
config = {
:type => type,
:documentType => document_type,
:document => {
:title => @file_name,
:url => download_url,
:directUrl => is_enable_direct_url ? download_url(false) : '',
:fileType => file_ext.delete('.'),
:key => key,
:info => {
:owner => 'Me',
:uploaded => Time.now.to_s,
:favorite => @user.favorite
type:,
documentType: document_type,
document: {
title: @file_name,
url: download_url,
directUrl: is_enable_direct_url ? download_url(false) : '',
fileType: file_ext.delete('.'),
key:,
info: {
owner: 'Me',
uploaded: Time.now.to_s,
favorite: @user.favorite
},
:permissions => { # the permission for the document to be edited and downloaded or not
:comment => !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'),
:copy => !@user.deniedPermissions.include?('copy'),
:download => !@user.deniedPermissions.include?('download'),
:edit => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')),
:print => !@user.deniedPermissions.include?('print'),
:fillForms => !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'),
:modifyFilter => !editorsmode.eql?('filter'),
:modifyContentControl => !editorsmode.eql?('blockcontent'),
:review => canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')),
:chat => !@user.id.eql?('uid-0'),
:reviewGroups => @user.reviewGroups,
:commentGroups => @user.commentGroups,
:userInfoGroups => @user.userInfoGroups,
:protect => !@user.deniedPermissions.include?('protect')
permissions: { # the permission for the document to be edited and downloaded or not
comment: !editorsmode.eql?('view') && !editorsmode.eql?('fillForms') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'),
copy: !@user.deniedPermissions.include?('copy'),
download: !@user.deniedPermissions.include?('download'),
edit: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('view') || editorsmode.eql?('filter') || editorsmode.eql?('blockcontent')),
print: !@user.deniedPermissions.include?('print'),
fillForms: !editorsmode.eql?('view') && !editorsmode.eql?('comment') && !editorsmode.eql?('embedded') && !editorsmode.eql?('blockcontent'),
modifyFilter: !editorsmode.eql?('filter'),
modifyContentControl: !editorsmode.eql?('blockcontent'),
review: canEdit && (editorsmode.eql?('edit') || editorsmode.eql?('review')),
chat: !@user.id.eql?('uid-0'),
reviewGroups: @user.reviewGroups,
commentGroups: @user.commentGroups,
userInfoGroups: @user.userInfoGroups,
protect: !@user.deniedPermissions.include?('protect')
},
:referenceData => {
:instanceId => DocumentHelper.get_server_url(false),
:fileKey => !@user.id.eql?('uid-0') ? { :fileName => @file_name, :userAddress => DocumentHelper.cur_user_host_address(nil) }.to_json : nil
referenceData: {
instanceId: DocumentHelper.get_server_url(false),
fileKey: !@user.id.eql?('uid-0') ? { fileName: @file_name, userAddress: DocumentHelper.cur_user_host_address(nil) }.to_json : nil
}
},
:editorConfig => {
:actionLink => @action_data ? JSON.parse(@action_data) : nil,
:mode => mode,
:lang => @lang || 'en',
:callbackUrl => callback_url, # absolute URL to the document storage service
:coEditing => if editorsmode.eql?('view') && @user.id.eql?('uid-0')
editorConfig: {
actionLink: @action_data ? JSON.parse(@action_data) : nil,
mode:,
lang: @lang || 'en',
callbackUrl: callback_url, # absolute URL to the document storage service
coEditing: if editorsmode.eql?('view') && @user.id.eql?('uid-0')
{
:mode => 'strict',
:change => false
mode: 'strict',
change: false
}
else
nil
end,
:createUrl => !@user.id.eql?('uid-0') ? create_url : nil,
:templates => @user.templates ? templates : nil,
:user => { # the user currently viewing or editing the document
:id => !@user.id.eql?('uid-0') ? @user.id : nil,
:name => @user.name,
:group => @user.group,
:image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil
createUrl: !@user.id.eql?('uid-0') ? create_url : nil,
templates: @user.templates ? templates : nil,
user: { # the user currently viewing or editing the document
id: !@user.id.eql?('uid-0') ? @user.id : nil,
name: @user.name,
group: @user.group,
image: @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil
},
:embedded => { # the parameters for the embedded document type
:saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer
:embedUrl => download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page
:shareUrl => download_url(false), # the absolute URL that will allow other users to share this document
:toolbarDocked => 'top' # the place for the embedded viewer toolbar (top or bottom)
embedded: { # the parameters for the embedded document type
saveUrl: download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer
embedUrl: download_url(false), # the absolute URL to the document serving as a source file for the document embedded into the web page
shareUrl: download_url(false), # the absolute URL that will allow other users to share this document
toolbarDocked: 'top' # the place for the embedded viewer toolbar (top or bottom)
},
:customization => { # the parameters for the editor interface
:about => true, # the About section display
:comments => true,
:feedback => true, # the Feedback & Support menu button display
:forcesave => false, # adding the request for the forced file saving to the callback handler
:submitForm => submitForm, # the Submit form button state
:goback => {
:url => DocumentHelper.get_server_url(false)
customization: { # the parameters for the editor interface
about: true, # the About section display
comments: true,
feedback: true, # the Feedback & Support menu button display
forcesave: false, # adding the request for the forced file saving to the callback handler
submitForm:, # the Submit form button state
goback: {
url: DocumentHelper.get_server_url(false)
}
}
}
@ -226,8 +226,8 @@ class FileModel
# write information about changes to the object
obj['created'] = cr_info['created']
obj['user'] = {
:id => cr_info['uid'],
:name => cr_info['uname']
id: cr_info['uid'],
name: cr_info['uname']
}
end
end
@ -260,16 +260,16 @@ class FileModel
# write key and url information about previous file version with optional direct url
dataObj['previous'] = if is_enable_direct_url == true
{ # write key and url information about previous file version with optional direct url
:fileType => prev['fileType'],
:key => prev['key'],
:url => prev['url'],
:directUrl => prev['directUrl']
fileType: prev['fileType'],
key: prev['key'],
url: prev['url'],
directUrl: prev['directUrl']
}
else
{
:fileType => prev['fileType'],
:key => prev['key'],
:url => prev['url']
fileType: prev['fileType'],
key: prev['key'],
url: prev['url']
}
end
@ -286,11 +286,11 @@ class FileModel
end
return {
:hist => { # write history information about the current file version to the hist
:currentVersion => cur_ver,
:history => hist
hist: { # write history information about the current file version to the hist
currentVersion: cur_ver,
history: hist
},
:histData => histData
histData:
}
end
@ -304,14 +304,14 @@ class FileModel
# direct url to the image
insert_image = if is_enable_direct_url == true
{
:fileType => 'png', # image file type
:url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image
:directUrl => "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image
fileType: 'png', # image file type
url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png", # server url to the image
directUrl: "#{DocumentHelper.get_server_url(false)}/assets/logo.png" # direct url to the image
}
else
{
:fileType => 'png', # image file type
:url => "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image
fileType: 'png', # image file type
url: "#{DocumentHelper.get_server_url(true)}/assets/logo.png" # server url to the image
}
end
@ -329,14 +329,14 @@ class FileModel
# direct url to the compared file
compare_file = if is_enable_direct_url == true
{
:fileType => 'docx', # file type
:url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file
:directUrl => "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file
fileType: 'docx', # file type
url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx", # server url to the compared file
directUrl: "#{DocumentHelper.get_server_url(false)}/asset?fileName=sample.docx" # direct url to the compared file
}
else
{
:fileType => 'docx', # file type
:url => "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file
fileType: 'docx', # file type
url: "#{DocumentHelper.get_server_url(true)}/asset?fileName=sample.docx" # server url to the compared file
}
end
@ -354,14 +354,14 @@ class FileModel
# direct url to the mail merge recipients file
dataSpreadsheet = if is_enable_direct_url == true
{
:fileType => 'csv', # file type
:url => "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file
:directUrl => "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file
fileType: 'csv', # file type
url: "#{DocumentHelper.get_server_url(true)}/csv", # server url to the mail merge recipients file
directUrl: "#{DocumentHelper.get_server_url(false)}/csv" # direct url to the mail merge recipients file
}
else
{
:fileType => 'csv', # file type
:url => "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file
fileType: 'csv', # file type
url: "#{DocumentHelper.get_server_url(true)}/csv" # server url to the mail merge recipients file
}
end

View File

@ -40,14 +40,14 @@ class ServiceConverter
document_revision_id = generate_revision_id(document_revision_id)
payload = { # write all the conversion parameters to the payload
:async => is_async ? true : false,
:url => document_uri,
:outputtype => to_ext.delete('.'),
:filetype => from_ext.delete('.'),
:title => title,
:key => document_revision_id,
:password => file_pass,
:region => lang
async: is_async ? true : false,
url: document_uri,
outputtype: to_ext.delete('.'),
filetype: from_ext.delete('.'),
title:,
key: document_revision_id,
password: file_pass,
region: lang
}
data = nil
@ -66,7 +66,7 @@ class ServiceConverter
if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled
payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload
jwtHeader = ServiceConverter.config_manager.jwt_header; # get signature authorization header
req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix
req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix
end
req.body = payload.to_json

View File

@ -234,11 +234,11 @@ class TrackHelper
def command_request(method, key, meta = nil)
# create a payload object with the method and key
payload = {
:c => method,
:key => key
c: method,
key:
}
payload.merge!({ :meta => meta }) if !meta.nil?
payload.merge!({ meta: }) if !meta.nil?
data = nil
begin
@ -253,7 +253,7 @@ class TrackHelper
if JwtHelper.is_enabled && JwtHelper.use_for_request # if the signature is enabled
payload['token'] = JwtHelper.encode(payload) # get token and save it to the payload
jwtHeader = TrackHelper.config_manager.jwt_header; # get signature authorization header
req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ :payload => payload })}") # set it to the request with the Bearer prefix
req.add_field(jwtHeader, "Bearer #{JwtHelper.encode({ payload: })}") # set it to the request with the Bearer prefix
end
req.body = payload.to_json # convert the payload object into the json format

View File

@ -90,17 +90,17 @@ class Users
nil, [], @@descr_user_1, true, true),
User.new('uid-2', 'Mark Pottato', 'pottato@example.com',
'group-2', ['group-2', ''], {
:view => '',
:edit => ['group-2', ''],
:remove => ['group-2']
view: '',
edit: ['group-2', ''],
remove: ['group-2']
},
['group-2', ''],
true, [], @@descr_user_2, false, true),
User.new('uid-3', 'Hamish Mitchell', nil,
'group-3', ['group-2'], {
:view => %w[group-3 group-2],
:edit => ['group-2'],
:remove => []
view: %w[group-3 group-2],
edit: ['group-2'],
remove: []
},
['group-2'],
false, %w[copy download print], @@descr_user_3, false, false),
@ -126,7 +126,7 @@ class Users
def get_users_for_mentions(id)
usersData = []
@@users.each do |user|
usersData.push({ :name => user.name, :email => user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil?
usersData.push({ name: user.name, email: user.email }) if !user.id.eql?(id) && !user.name.nil? && !user.email.nil?
end
usersData
end