onlyoffice_file_helper 0.4.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1912f88662a16d0b908b258a3f95843eb24f20e3c83585905d39a79bcda9d043
|
4
|
+
data.tar.gz: 9bea4bca48018dcfd22bfdab65f14b5eb5ee54158bd0b6bd63dfa601e6f3687a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e81341cdd686eac779125def4dfdd94c889d8e6e91268977b41a25039f29a33bdf9974a48536d040cb30db387f21297f8aa04dcb00b5ce2ee1da4b26ee61de3b
|
7
|
+
data.tar.gz: 50a806204f8edd4fc0d17eaac89b52fcec3d9f2ab1c0e7392d18c8ee4336d26695e0b6bdbb7b6832bb46664fec9dcb419f36bc1cdc435d1848925bb3bcbb418a
|
@@ -17,7 +17,7 @@ module OnlyofficeFileHelper
|
|
17
17
|
# @param [String] content content of file
|
18
18
|
# @return [String] path to created file
|
19
19
|
def create_file_with_content(file_path: '/tmp/temp_file.ext', content: '')
|
20
|
-
File.
|
20
|
+
File.write(file_path, content)
|
21
21
|
OnlyofficeLoggerHelper.log("Created file: #{file_path} with content: #{content}")
|
22
22
|
file_path
|
23
23
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module OnlyofficeFileHelper
|
4
|
+
# Methods used to work with files
|
5
|
+
module FileMethods
|
6
|
+
# Copies a file
|
7
|
+
# @param [String] file_path path to file to be copied
|
8
|
+
# @param [String] destination path to where to copy file
|
9
|
+
def copy_file(file_path, destination)
|
10
|
+
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
11
|
+
FileUtils.copy(file_path, destination)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Moves a file
|
15
|
+
# @param [String] file_path path to file to be moved
|
16
|
+
# @param [String] destination path to where to move file
|
17
|
+
def move_file(file_path, destination)
|
18
|
+
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
19
|
+
FileUtils.move(file_path, destination)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get file size in bytes
|
23
|
+
# @param [String] file_path path to file
|
24
|
+
# @return [Integer] size of file in bytes
|
25
|
+
def file_size(file_path)
|
26
|
+
size = File.size?(file_path)
|
27
|
+
size = 0 if size.nil?
|
28
|
+
size
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -7,6 +7,7 @@ require 'onlyoffice_logger_helper'
|
|
7
7
|
require 'find'
|
8
8
|
require 'onlyoffice_file_helper/create_methods'
|
9
9
|
require 'onlyoffice_file_helper/directory_methods'
|
10
|
+
require 'onlyoffice_file_helper/file_methods'
|
10
11
|
require 'onlyoffice_file_helper/read_methods'
|
11
12
|
require 'onlyoffice_file_helper/version'
|
12
13
|
require 'onlyoffice_file_helper/linux_helper'
|
@@ -20,12 +21,14 @@ module OnlyofficeFileHelper
|
|
20
21
|
extend CreateMethods
|
21
22
|
extend DirectoryMethods
|
22
23
|
extend ReadMethods
|
24
|
+
extend FileMethods
|
23
25
|
|
24
26
|
class << self
|
25
27
|
# Return name of file from full path
|
26
|
-
# @param [
|
28
|
+
# @param [String] file_path to get name
|
29
|
+
# @param [Boolean] keep_extension keep extension in result?
|
27
30
|
# @return [Sting] name of file, with extension or not
|
28
|
-
def
|
31
|
+
def filename_from_path(file_path, keep_extension: true)
|
29
32
|
name = Pathname.new(file_path).basename
|
30
33
|
name = File.basename(name, File.extname(name)) unless keep_extension
|
31
34
|
name.to_s
|
@@ -34,7 +37,8 @@ module OnlyofficeFileHelper
|
|
34
37
|
# Wait for downloading file
|
35
38
|
# @param path [String] path to waiting download
|
36
39
|
# @param timeout [Integer] timeout to wait
|
37
|
-
# @
|
40
|
+
# @raise [StandardError] exception if file not downloaded during timeout
|
41
|
+
# @return [True] always successful, if not - raising Exception
|
38
42
|
def wait_file_to_download(path, timeout = 300)
|
39
43
|
timer = 0
|
40
44
|
OnlyofficeLoggerHelper.log("Start waiting to download file: #{path}")
|
@@ -45,18 +49,16 @@ module OnlyofficeFileHelper
|
|
45
49
|
raise "Timeout #{timeout} for downloading file #{path} is exceed" if timer > timeout
|
46
50
|
end
|
47
51
|
sleep 1
|
48
|
-
|
52
|
+
true
|
49
53
|
end
|
50
54
|
|
51
55
|
# Extract archive to folder
|
52
56
|
# @param path_to_archive [String] path of file
|
53
|
-
# @param path_to_extract [String] result path
|
54
57
|
# @return [Void]
|
55
|
-
def extract_to_folder(path_to_archive
|
56
|
-
|
57
|
-
raise "File not found: #{path_to_archive}" unless wait_file_to_download(path_to_archive)
|
58
|
+
def extract_to_folder(path_to_archive)
|
59
|
+
wait_file_to_download(path_to_archive)
|
58
60
|
|
59
|
-
path_to_extract
|
61
|
+
path_to_extract = path_to_archive.chomp(File.basename(path_to_archive))
|
60
62
|
path_to_file = path_to_extract + File.basename(path_to_archive)
|
61
63
|
Zip::File.open(path_to_file) do |zip_file|
|
62
64
|
zip_file.each do |file|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlyoffice_file_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ONLYOFFICE
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: onlyoffice_logger_helper
|
@@ -39,20 +39,6 @@ dependencies:
|
|
39
39
|
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: codecov
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "~>"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "~>"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
56
42
|
- !ruby/object:Gem::Dependency
|
57
43
|
name: overcommit
|
58
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -151,6 +137,20 @@ dependencies:
|
|
151
137
|
- - "~>"
|
152
138
|
- !ruby/object:Gem::Version
|
153
139
|
version: '2'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: simplecov
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
154
|
- !ruby/object:Gem::Dependency
|
155
155
|
name: yard
|
156
156
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- lib/onlyoffice_file_helper.rb
|
182
182
|
- lib/onlyoffice_file_helper/create_methods.rb
|
183
183
|
- lib/onlyoffice_file_helper/directory_methods.rb
|
184
|
+
- lib/onlyoffice_file_helper/file_methods.rb
|
184
185
|
- lib/onlyoffice_file_helper/linux_helper.rb
|
185
186
|
- lib/onlyoffice_file_helper/linux_helper/xdotool_helper.rb
|
186
187
|
- lib/onlyoffice_file_helper/name.rb
|
@@ -197,6 +198,7 @@ metadata:
|
|
197
198
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_file_helper
|
198
199
|
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper
|
199
200
|
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper
|
201
|
+
rubygems_mfa_required: 'true'
|
200
202
|
post_install_message:
|
201
203
|
rdoc_options: []
|
202
204
|
require_paths:
|
@@ -205,14 +207,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
205
207
|
requirements:
|
206
208
|
- - ">="
|
207
209
|
- !ruby/object:Gem::Version
|
208
|
-
version: '2.
|
210
|
+
version: '2.7'
|
209
211
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
212
|
requirements:
|
211
213
|
- - ">="
|
212
214
|
- !ruby/object:Gem::Version
|
213
215
|
version: '0'
|
214
216
|
requirements: []
|
215
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.3.20
|
216
218
|
signing_key:
|
217
219
|
specification_version: 4
|
218
220
|
summary: ONLYOFFICE Helper Gem for File operation
|