pcloud 0.3.0 → 0.3.2
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/pcloud/client.rb +2 -3
- data/lib/pcloud/exceptions.rb +5 -0
- data/lib/pcloud/files/file_handler.rb +9 -11
- data/lib/pcloud/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3df45fba37065a0d00e1ef805a2754f6d7da0cfb62a780bcd6e2f9a73bb3dad
|
4
|
+
data.tar.gz: 975423282e2a3919243368ace288b2f61d47eeb5408ee34f7f6578ad4852799d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2b0b1fbca1e202c8503259bf8035defab0a1dea551f94e907323c447511a37f250225b7e942fe73c1ffe581023ddd89d7e36992220bf47fa722230cc8e00b87
|
7
|
+
data.tar.gz: '088f4cec04d35a5eb422f2ae59e4d6affdf849dd4614bbe99edad6212233ffaf0b44c29812103b0aa0c23101276f0fd38967d2d1816324597d348a36a7589886'
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
### [0.3.2](https://www.github.com/7urkm3n/pcloud/compare/v0.3.1...v0.3.2) (2021-09-05)
|
4
|
+
|
5
|
+
|
6
|
+
### Bug Fixes
|
7
|
+
|
8
|
+
* filehandle error fixed ([45fae7c](https://www.github.com/7urkm3n/pcloud/commit/45fae7c42fd483b86d42c80fd9e6a11619933a40))
|
9
|
+
|
3
10
|
### [0.3.1](https://www.github.com/7urkm3n/pcloud/compare/v0.3.0...v0.3.1) (2021-09-04)
|
4
11
|
|
5
12
|
|
data/lib/pcloud/client.rb
CHANGED
@@ -34,12 +34,11 @@ module Pcloud
|
|
34
34
|
self
|
35
35
|
end
|
36
36
|
|
37
|
-
private
|
38
|
-
|
39
37
|
def request(verb, path, params, payload = {})
|
40
38
|
Pcloud::Request.call(self, verb, path, params, payload)
|
41
39
|
end
|
42
|
-
|
40
|
+
|
41
|
+
private
|
43
42
|
def authorize(options)
|
44
43
|
raise ConfigurationError, :username unless @username
|
45
44
|
raise ConfigurationError, :password unless @password
|
data/lib/pcloud/exceptions.rb
CHANGED
@@ -6,6 +6,11 @@ module Pcloud
|
|
6
6
|
super "missing key `#{key}' in the client configuration"
|
7
7
|
end
|
8
8
|
end
|
9
|
+
class NotFoundError < Error
|
10
|
+
def initialize(key, message)
|
11
|
+
super "not found `#{key}' with value of #{message}"
|
12
|
+
end
|
13
|
+
end
|
9
14
|
class HTTPError < Error
|
10
15
|
def initialize(key, message)
|
11
16
|
super "#{key} Bad request: #{message}"
|
@@ -9,7 +9,7 @@ module Pcloud
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def upload(params, payload)
|
12
|
-
request(:post, 'uploadfile', params, payload)
|
12
|
+
@client.request(:post, 'uploadfile', params, payload)
|
13
13
|
end
|
14
14
|
|
15
15
|
def download(params)
|
@@ -22,30 +22,28 @@ module Pcloud
|
|
22
22
|
destination = params[:destination] || '.'
|
23
23
|
filename = params[:filename] || nil
|
24
24
|
if !filename
|
25
|
-
stat = request(:get, "stat", {fileid: params[:fileid]})
|
25
|
+
stat = @client.request(:get, "stat", {fileid: params[:fileid]})
|
26
|
+
raise NotFoundError.new(:fileid, params[:fileid]) if stat[:error]
|
26
27
|
filename = stat[:metadata][:name]
|
27
28
|
end
|
28
|
-
File.write("#{destination}/#{filename}", request(:get, "gettextfile", {fileid: params[:fileid], raw: true}))
|
29
|
-
end
|
29
|
+
File.write("#{destination}/#{filename}", @client.request(:get, "gettextfile", {fileid: params[:fileid], raw: true}))
|
30
|
+
end
|
30
31
|
|
31
32
|
def download_folder(params)
|
32
|
-
data = request(:get, "listfolder", {folderid: params[:folderid]})
|
33
|
+
data = @client.request(:get, "listfolder", {folderid: params[:folderid]})
|
34
|
+
raise NotFoundError.new(:folderid, params[:folderid]) if data[:error]
|
35
|
+
|
33
36
|
destination = params[:destination] || '.'
|
34
37
|
folder_name = params[:filename] || data[:metadata][:name] << ".zip"
|
35
38
|
stringio = Zip::OutputStream::write_buffer do |zio|
|
36
39
|
data[:metadata][:contents].each do |content|
|
37
40
|
zio.put_next_entry(content[:name])
|
38
|
-
zio.write(request(:get, "gettextfile", {fileid: content[:fileid], raw: true}))
|
41
|
+
zio.write(@client.request(:get, "gettextfile", {fileid: content[:fileid], raw: true}))
|
39
42
|
end
|
40
43
|
end
|
41
44
|
stringio.rewind #reposition buffer pointer to the beginning
|
42
45
|
File.new("#{destination}/#{folder_name}","wb").write(stringio.sysread) #write buffer to zipfile
|
43
46
|
end
|
44
47
|
|
45
|
-
private
|
46
|
-
|
47
|
-
def request(verb, path, params, payload = {})
|
48
|
-
Pcloud::Request.call(@client, verb, path, params, payload)
|
49
|
-
end
|
50
48
|
end
|
51
49
|
end
|
data/lib/pcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rovshen Gurdov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|