onlyoffice_file_helper 0.4.0 → 0.5.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: 7a2fce65649f29c5896b478a8b5786d6c850a91e3d4cc13fefd410a14d70f065
4
- data.tar.gz: 47be12b2f7e6e19b2beee6a4cc0afb398827e4559106fc695d8c03a0c77d7693
3
+ metadata.gz: b18003c971b29ad3a526be4c6a1c5a9715a679852e9f1f669b5df5556af68d84
4
+ data.tar.gz: 830540033c0e29f1c6407102cb635a3988889533bb3bc8fd047c2972aaa24e50
5
5
  SHA512:
6
- metadata.gz: 46ab25b8bf3ce467eca640b777c38cb6ed58aeb6ce9815b68dee6ced19f33fdb3cbf20beb2fccaaec4e19147717d89f275c3f465ad39beccbe4904e8f6bfdeda
7
- data.tar.gz: 741fd7bcc0ee7baf61d9d866a51ea633ff3e4bca08c0804fe8286ca08971e1eca3c83097bb18be2afbeed8229fa6fd2b5af82a4c250ca43dd675367af68f53ca
6
+ metadata.gz: f02f38cced0b75b7d4c203d9b8c7c92d463a67a1948cf512ffecc3b5a07e46adea14ebd9d5f0e2347d00cd144b2eecba1337648bc3a854d1a181df87171967ec
7
+ data.tar.gz: 4ce796b78aebc6478b4d88ef9ad304b13e43710ff7ba69cab1a8290b6437ee2182d990a21cd64869b4d088b32c85dcd8be95c389c25274b3418cb3a1d89d50f7
@@ -2,5 +2,5 @@
2
2
 
3
3
  module OnlyofficeFileHelper
4
4
  # @return [String] version of gem
5
- VERSION = '0.4.0'
5
+ VERSION = '0.5.0'
6
6
  end
@@ -23,18 +23,31 @@ module OnlyofficeFileHelper
23
23
 
24
24
  class << self
25
25
  # Return name of file from full path
26
- # @param [true, false] keep_extension keep extension in result?
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 get_filename(file_path, keep_extension = true)
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
32
33
  end
33
34
 
35
+ # Return name of file from full path
36
+ # @param [String] file_path full file path
37
+ # @param [true, false] keep_extension keep extension in result?
38
+ # @return [Sting] name of file, with extension or not
39
+ def get_filename(file_path, keep_extension = true)
40
+ filename_from_path(file_path, keep_extension: keep_extension)
41
+ end
42
+
43
+ extend Gem::Deprecate
44
+ deprecate :get_filename, :filename_from_path, 2025, 1
45
+
34
46
  # Wait for downloading file
35
47
  # @param path [String] path to waiting download
36
48
  # @param timeout [Integer] timeout to wait
37
- # @return [True, False] result
49
+ # @raise [StandardError] exception if file not downloaded during timeout
50
+ # @return [True] always successful, if not - raising Exception
38
51
  def wait_file_to_download(path, timeout = 300)
39
52
  timer = 0
40
53
  OnlyofficeLoggerHelper.log("Start waiting to download file: #{path}")
@@ -45,18 +58,16 @@ module OnlyofficeFileHelper
45
58
  raise "Timeout #{timeout} for downloading file #{path} is exceed" if timer > timeout
46
59
  end
47
60
  sleep 1
48
- timer <= timeout
61
+ true
49
62
  end
50
63
 
51
64
  # Extract archive to folder
52
65
  # @param path_to_archive [String] path of file
53
- # @param path_to_extract [String] result path
54
66
  # @return [Void]
55
- def extract_to_folder(path_to_archive,
56
- path_to_extract = path_to_archive.chomp(File.basename(path_to_archive)))
57
- raise "File not found: #{path_to_archive}" unless wait_file_to_download(path_to_archive)
67
+ def extract_to_folder(path_to_archive)
68
+ wait_file_to_download(path_to_archive)
58
69
 
59
- path_to_extract += '/' unless path_to_extract[-1] == '/'
70
+ path_to_extract = path_to_archive.chomp(File.basename(path_to_archive))
60
71
  path_to_file = path_to_extract + File.basename(path_to_archive)
61
72
  Zip::File.open(path_to_file) do |zip_file|
62
73
  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.0
4
+ version: 0.5.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: 2020-11-28 00:00:00.000000000 Z
12
+ date: 2021-09-16 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
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  - !ruby/object:Gem::Version
213
213
  version: '0'
214
214
  requirements: []
215
- rubygems_version: 3.1.4
215
+ rubygems_version: 3.2.27
216
216
  signing_key:
217
217
  specification_version: 4
218
218
  summary: ONLYOFFICE Helper Gem for File operation