onlyoffice_file_helper 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebad99290f1b01ca78c2c2ff8d1d387d39aa6680d9c1f79e34e5c8a5fd88c92a
|
4
|
+
data.tar.gz: 9a6030f9416d7d8e195c5de56102550b297fdcb7d971ad5053fc2a8029b2b4de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a76a442f4083aa6e26ae4513249bb100954a03923474116b145dec81b07268c2310875b16935f2e166967426fa25919186e6856cbf2d7f9ae5298c28ee6aec68
|
7
|
+
data.tar.gz: 5810ca797300bbf5ec5aa99092cc0f53b8046db7e0000e176fb989834275c7b302d68a75afd5710687b52ecd938c02ec46c3832a04c200f4fd3715b9f7e26659
|
@@ -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
|
@@ -3,11 +3,14 @@
|
|
3
3
|
module OnlyofficeFileHelper
|
4
4
|
# Methods used to work with directories
|
5
5
|
module DirectoryMethods
|
6
|
+
# @return [Array<String>] list of linux special dirs
|
7
|
+
LINUX_SPECIAL_DIRS = %w[.. .].freeze
|
8
|
+
|
6
9
|
# Delete directory only if it exists
|
7
10
|
# @param path [String] directory to delete
|
8
11
|
# @return [Void]
|
9
12
|
def delete_directory(path)
|
10
|
-
FileUtils.rm_rf(path)
|
13
|
+
FileUtils.rm_rf(path)
|
11
14
|
end
|
12
15
|
|
13
16
|
# List of files in directory as array
|
@@ -16,7 +19,7 @@ module OnlyofficeFileHelper
|
|
16
19
|
def directory_hash(path)
|
17
20
|
files = []
|
18
21
|
Dir.foreach(path).sort.each do |entry|
|
19
|
-
next if
|
22
|
+
next if LINUX_SPECIAL_DIRS.include?(entry)
|
20
23
|
|
21
24
|
full_path = File.join(path, entry)
|
22
25
|
files = root_dir_hash(files, full_path)
|
@@ -8,7 +8,7 @@ module OnlyofficeFileHelper
|
|
8
8
|
# @return [String] result of read
|
9
9
|
def read_file_to_string(file_name)
|
10
10
|
result_string = ''
|
11
|
-
raise
|
11
|
+
raise "File not found: #{file_name}" unless File.exist?(file_name)
|
12
12
|
|
13
13
|
File.open(file_name, 'r') do |infile|
|
14
14
|
while (line = infile.gets)
|
@@ -23,9 +23,10 @@ module OnlyofficeFileHelper
|
|
23
23
|
|
24
24
|
class << self
|
25
25
|
# Return name of file from full path
|
26
|
-
# @param [
|
26
|
+
# @param [String] file_path to get name
|
27
|
+
# @param [Boolean] keep_extension keep extension in result?
|
27
28
|
# @return [Sting] name of file, with extension or not
|
28
|
-
def
|
29
|
+
def filename_from_path(file_path, keep_extension: true)
|
29
30
|
name = Pathname.new(file_path).basename
|
30
31
|
name = File.basename(name, File.extname(name)) unless keep_extension
|
31
32
|
name.to_s
|
@@ -34,29 +35,28 @@ module OnlyofficeFileHelper
|
|
34
35
|
# Wait for downloading file
|
35
36
|
# @param path [String] path to waiting download
|
36
37
|
# @param timeout [Integer] timeout to wait
|
37
|
-
# @
|
38
|
+
# @raise [StandardError] exception if file not downloaded during timeout
|
39
|
+
# @return [True] always successful, if not - raising Exception
|
38
40
|
def wait_file_to_download(path, timeout = 300)
|
39
41
|
timer = 0
|
40
42
|
OnlyofficeLoggerHelper.log("Start waiting to download file: #{path}")
|
41
|
-
until File.exist?(path) && !File.exist?(path
|
43
|
+
until File.exist?(path) && !File.exist?("#{path}.part")
|
42
44
|
OnlyofficeLoggerHelper.log("Waiting for #{timer} seconds from #{timeout}")
|
43
45
|
sleep 1
|
44
46
|
timer += 1
|
45
47
|
raise "Timeout #{timeout} for downloading file #{path} is exceed" if timer > timeout
|
46
48
|
end
|
47
49
|
sleep 1
|
48
|
-
|
50
|
+
true
|
49
51
|
end
|
50
52
|
|
51
53
|
# Extract archive to folder
|
52
54
|
# @param path_to_archive [String] path of file
|
53
|
-
# @param path_to_extract [String] result path
|
54
55
|
# @return [Void]
|
55
|
-
def extract_to_folder(path_to_archive
|
56
|
-
|
57
|
-
raise 'File not found: ' + path_to_archive.to_s unless wait_file_to_download(path_to_archive)
|
56
|
+
def extract_to_folder(path_to_archive)
|
57
|
+
wait_file_to_download(path_to_archive)
|
58
58
|
|
59
|
-
path_to_extract
|
59
|
+
path_to_extract = path_to_archive.chomp(File.basename(path_to_archive))
|
60
60
|
path_to_file = path_to_extract + File.basename(path_to_archive)
|
61
61
|
Zip::File.open(path_to_file) do |zip_file|
|
62
62
|
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: 0.
|
4
|
+
version: 1.0.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-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: onlyoffice_logger_helper
|
@@ -29,36 +29,148 @@ dependencies:
|
|
29
29
|
name: rubyzip
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
35
|
-
|
34
|
+
version: '2'
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '2'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: overcommit
|
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
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rake
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '13'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '13'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
36
75
|
- !ruby/object:Gem::Version
|
37
76
|
version: '3'
|
38
|
-
type: :
|
77
|
+
type: :development
|
39
78
|
prerelease: false
|
40
79
|
version_requirements: !ruby/object:Gem::Requirement
|
41
80
|
requirements:
|
42
|
-
- - "
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
43
89
|
- !ruby/object:Gem::Version
|
44
90
|
version: '1'
|
45
|
-
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
46
96
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
97
|
+
version: '1'
|
48
98
|
- !ruby/object:Gem::Dependency
|
49
|
-
name:
|
99
|
+
name: rubocop-performance
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '1'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: rubocop-rake
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - "~>"
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - "~>"
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: rubocop-rspec
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - "~>"
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '2'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - "~>"
|
138
|
+
- !ruby/object:Gem::Version
|
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
|
+
- !ruby/object:Gem::Dependency
|
155
|
+
name: yard
|
50
156
|
requirement: !ruby/object:Gem::Requirement
|
51
157
|
requirements:
|
52
158
|
- - "~>"
|
53
159
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
160
|
+
version: '0'
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: 0.9.20
|
55
164
|
type: :development
|
56
165
|
prerelease: false
|
57
166
|
version_requirements: !ruby/object:Gem::Requirement
|
58
167
|
requirements:
|
59
168
|
- - "~>"
|
60
169
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
170
|
+
version: '0'
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: 0.9.20
|
62
174
|
description: ONLYOFFICE Helper Gem for File operation. Used in QA
|
63
175
|
email:
|
64
176
|
- shockwavenn@gmail.com
|
@@ -76,15 +188,16 @@ files:
|
|
76
188
|
- lib/onlyoffice_file_helper/ruby_helper.rb
|
77
189
|
- lib/onlyoffice_file_helper/string_helper.rb
|
78
190
|
- lib/onlyoffice_file_helper/version.rb
|
79
|
-
homepage: https://github.com/
|
191
|
+
homepage: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper
|
80
192
|
licenses:
|
81
193
|
- AGPL-3.0
|
82
194
|
metadata:
|
83
|
-
bug_tracker_uri: https://github.com/
|
84
|
-
changelog_uri: https://github.com/
|
195
|
+
bug_tracker_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper/issues
|
196
|
+
changelog_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper/blob/master/CHANGELOG.md
|
85
197
|
documentation_uri: https://www.rubydoc.info/gems/onlyoffice_file_helper
|
86
|
-
homepage_uri: https://github.com/
|
87
|
-
source_code_uri: https://github.com/
|
198
|
+
homepage_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper
|
199
|
+
source_code_uri: https://github.com/ONLYOFFICE-QA/onlyoffice_file_helper
|
200
|
+
rubygems_mfa_required: 'true'
|
88
201
|
post_install_message:
|
89
202
|
rdoc_options: []
|
90
203
|
require_paths:
|
@@ -93,14 +206,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
93
206
|
requirements:
|
94
207
|
- - ">="
|
95
208
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
209
|
+
version: '2.7'
|
97
210
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
211
|
requirements:
|
99
212
|
- - ">="
|
100
213
|
- !ruby/object:Gem::Version
|
101
214
|
version: '0'
|
102
215
|
requirements: []
|
103
|
-
rubygems_version: 3.
|
216
|
+
rubygems_version: 3.3.19
|
104
217
|
signing_key:
|
105
218
|
specification_version: 4
|
106
219
|
summary: ONLYOFFICE Helper Gem for File operation
|