bestchange-api 0.4 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/bestchange/api.rb +7 -5
- data/lib/bestchange/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3e48dd22229d0446f26b047fd38fee4a9824be55e2981b7bcfeadb49ca4f044
|
4
|
+
data.tar.gz: a098a7884b4b9668974acabc2f73df5837ad54b671c40dec14dc147e23e6d1aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3d574c842366cc7429dc2f197e34767996d265eed053eae2a9f64f00bc5bbd1743bfde48da456e7501473b85acd467378c2223b766db9e11d509805d9994f075
|
7
|
+
data.tar.gz: bd27f374b87e3e18b74e41d952e33e5eb740748d9ae7344dd1895538e477dfd6c5c9cd4f931c8c827d6dd284aa85928c9a96c29426505e91784d50e0e268487d
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/bestchange/api.rb
CHANGED
@@ -10,21 +10,21 @@ module Bestchange
|
|
10
10
|
module Api
|
11
11
|
extend self
|
12
12
|
|
13
|
-
def get_files(filenames)
|
13
|
+
def get_files(filenames, &before_extract)
|
14
14
|
Timeout.timeout(Bestchange.configuration.timeout) do
|
15
|
-
fetch_files(filenames)
|
15
|
+
fetch_files(filenames, &before_extract)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
20
|
|
21
|
-
def fetch_files(filenames)
|
21
|
+
def fetch_files(filenames, &before_extract)
|
22
22
|
response = make_request
|
23
23
|
|
24
24
|
archive = Tempfile.new(ARCHIVE_DATA_FILENAME, encoding: ARCHIVE_DATA_ENCODING)
|
25
25
|
archive.write(response)
|
26
26
|
|
27
|
-
extract_files(
|
27
|
+
extract_files('info.zip', filenames, &before_extract)
|
28
28
|
ensure
|
29
29
|
archive.close if defined?(archive)
|
30
30
|
end
|
@@ -33,13 +33,15 @@ module Bestchange
|
|
33
33
|
Net::HTTP.get(URI(BASE_URI))
|
34
34
|
end
|
35
35
|
|
36
|
-
def extract_files(archive, filenames)
|
36
|
+
def extract_files(archive, filenames, &before_extract)
|
37
37
|
Zip::File.open(archive) do |zip_file|
|
38
38
|
filenames.map do |filename|
|
39
39
|
entry = zip_file.find_entry(filename)
|
40
40
|
|
41
41
|
pathname = Pathname.new(Bestchange.configuration.dir).join(filename)
|
42
42
|
|
43
|
+
before_extract&.call(filename, pathname)
|
44
|
+
|
43
45
|
zip_file.extract(entry, pathname)
|
44
46
|
|
45
47
|
pathname.open
|
data/lib/bestchange/version.rb
CHANGED