pcloud 0.0.1 → 0.0.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 +13 -0
- data/README.md +9 -7
- data/lib/pcloud.rb +1 -5
- data/lib/pcloud/client.rb +9 -10
- data/lib/pcloud/version.rb +1 -1
- metadata +12 -51
- data/spec/client_spec.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f149800e09ac0b4f7e8f73604197bfb8a471e35f5402a03f7e238c34791b412c
|
4
|
+
data.tar.gz: cb22e032de376f1fe61ea06dad968c7cf0c61f52d9c9c7d35b55c2e1802bbae0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8312ecf45d3d0d5c43414d994fa5014152664820e22e7d175cc29a5d4d5dd57d080dd462d97de5e95c9545330f6906a0193d9af2b4c7d261fe8227afbef374a
|
7
|
+
data.tar.gz: b04c21315cfccc22e6e68bfb39b00d40e900348de038ed61958cba2f4bd1f8e5537818e8b8bad84f6b270ed26815abbdefaf395a7adfed8c0c2b039e3f6fb9a1
|
data/Changelog.md
ADDED
data/README.md
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
This Gem provides a Ruby interface to [Pcloud.com](https://pcloud.com).
|
4
4
|
|
5
|
-
[]() [](https://
|
5
|
+
[](https://github.com/7urkm3n/pcloud/actions?query=workflow%3Abuild) [](https://rubygems.org/gems/pcloud) [](https://badge.fury.io/rb/pcloud)
|
6
|
+
|
7
|
+
<!-- [](https://rubygems.org/gems/pcloud) -->
|
6
8
|
|
7
9
|
## Installation and Configuration
|
8
10
|
|
@@ -64,18 +66,18 @@ Pcloud.logger = Rails.logger
|
|
64
66
|
|
65
67
|
Currently, only available custom Get method.
|
66
68
|
|
67
|
-
File
|
69
|
+
File Upload and Download methods are coming soon.
|
68
70
|
|
69
71
|
|
70
72
|
#### Get methods
|
71
73
|
|
72
74
|
``` ruby
|
73
|
-
|
74
|
-
|
75
|
+
Pcloud.get("getip")
|
76
|
+
Pcloud.get("getdigest")
|
75
77
|
|
76
78
|
# with params
|
77
|
-
|
78
|
-
|
79
|
+
Pcloud.get("listfolder", folderid: 0)
|
80
|
+
Pcloud.get("createfolder", folderid: 0, name: "new folder name", ...)
|
79
81
|
```
|
80
82
|
|
81
83
|
<!-- #### Post methods
|
@@ -86,4 +88,4 @@ pcloud.get("createfolder", folderid: 0, name: "new folder name")
|
|
86
88
|
``` -->
|
87
89
|
|
88
90
|
### Supported Ruby versions
|
89
|
-
2.
|
91
|
+
2.2+
|
data/lib/pcloud.rb
CHANGED
@@ -11,7 +11,7 @@ module Pcloud
|
|
11
11
|
class << self
|
12
12
|
extend Forwardable
|
13
13
|
def_delegators :default_client, :username=, :password=
|
14
|
-
def_delegators :default_client, :get
|
14
|
+
def_delegators :default_client, :get
|
15
15
|
|
16
16
|
attr_writer :logger
|
17
17
|
|
@@ -28,9 +28,5 @@ module Pcloud
|
|
28
28
|
Pcloud::Client.new
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
32
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
data/lib/pcloud/client.rb
CHANGED
@@ -6,7 +6,7 @@ module Pcloud
|
|
6
6
|
class Client
|
7
7
|
attr_writer :username, :password
|
8
8
|
|
9
|
-
def initialize(options)
|
9
|
+
def initialize(options = {})
|
10
10
|
@username, @password = options.values_at(:username, :password)
|
11
11
|
end
|
12
12
|
|
@@ -29,15 +29,11 @@ module Pcloud
|
|
29
29
|
raise ConfigurationError, :username unless @username
|
30
30
|
raise ConfigurationError, :password unless @password
|
31
31
|
digest = JSON.parse(RestClient.get("#{BASE_URL}/getdigest"))['digest']
|
32
|
-
passworddigest =
|
33
|
-
|
34
|
-
{
|
35
|
-
|
36
|
-
|
37
|
-
passworddigest: passworddigest
|
38
|
-
}
|
39
|
-
}
|
40
|
-
JSON.parse(RestClient.get("#{BASE_URL}/userinfo?getauth=1&logout=1", params))['auth']
|
32
|
+
passworddigest = digest_data(@password + digest_data( @username.downcase ) + digest)
|
33
|
+
JSON.parse(
|
34
|
+
RestClient.get("#{BASE_URL}/userinfo?getauth=1&logout=1",
|
35
|
+
{params: {username: @username, digest: digest, passworddigest: passworddigest}})
|
36
|
+
)['auth']
|
41
37
|
end
|
42
38
|
end
|
43
39
|
|
@@ -47,5 +43,8 @@ module Pcloud
|
|
47
43
|
Resource.new(self, path)
|
48
44
|
end
|
49
45
|
|
46
|
+
def digest_data text
|
47
|
+
Digest::SHA1.hexdigest(text)
|
48
|
+
end
|
50
49
|
end
|
51
50
|
end
|
data/lib/pcloud/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pcloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rovshen Gurdov
|
@@ -52,56 +52,15 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.2.0
|
55
|
-
|
56
|
-
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '3.0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '3.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 10.4.2
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 10.4.2
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rack
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - "~>"
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 1.6.4
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 1.6.4
|
97
|
-
description: Pcloud is online storage upload/download/share from pcloud.com. Currently
|
98
|
-
not supports all API URLs. Please, check available methods in Github Doc...
|
55
|
+
description: Pcloud is cloud storage upload/download/share from pcloud.com. Please,
|
56
|
+
check available methods in Github Doc...
|
99
57
|
email:
|
100
58
|
- rovshen@gurdov.com
|
101
59
|
executables: []
|
102
60
|
extensions: []
|
103
61
|
extra_rdoc_files: []
|
104
62
|
files:
|
63
|
+
- Changelog.md
|
105
64
|
- LICENSE
|
106
65
|
- README.md
|
107
66
|
- lib/generators/pcloud.rb
|
@@ -112,11 +71,14 @@ files:
|
|
112
71
|
- lib/pcloud/request.rb
|
113
72
|
- lib/pcloud/resource.rb
|
114
73
|
- lib/pcloud/version.rb
|
115
|
-
|
116
|
-
homepage: https://rubygems.org/gems/pcloud
|
74
|
+
homepage: https://github.com/7urkm3n/pcloud/
|
117
75
|
licenses:
|
118
76
|
- MIT
|
119
|
-
metadata:
|
77
|
+
metadata:
|
78
|
+
bug_tracker_uri: https://github.com/7urkm3n/pcloud/issues
|
79
|
+
changelog_uri: https://github.com/7urkm3n/pcloud/blob/v0.0.2/Changelog.md
|
80
|
+
documentation_uri: https://github.com/7urkm3n/pcloud
|
81
|
+
source_code_uri: https://github.com/7urkm3n/pcloud
|
120
82
|
post_install_message:
|
121
83
|
rdoc_options: []
|
122
84
|
require_paths:
|
@@ -125,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
87
|
requirements:
|
126
88
|
- - ">="
|
127
89
|
- !ruby/object:Gem::Version
|
128
|
-
version: 2.
|
90
|
+
version: '2.2'
|
129
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
92
|
requirements:
|
131
93
|
- - ">="
|
@@ -136,5 +98,4 @@ rubygems_version: 3.0.3
|
|
136
98
|
signing_key:
|
137
99
|
specification_version: 4
|
138
100
|
summary: Secure and simple to use cloud storage for your datas...
|
139
|
-
test_files:
|
140
|
-
- spec/client_spec.rb
|
101
|
+
test_files: []
|
data/spec/client_spec.rb
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
describe Pcloud do
|
2
|
-
[lambda { Pcloud }, lambda { Pcloud::Client.new }].each do |client_gen|
|
3
|
-
before :each do
|
4
|
-
@client = client_gen.call
|
5
|
-
end
|
6
|
-
|
7
|
-
describe 'default configuration' do
|
8
|
-
it 'should be preconfigured for api host' do
|
9
|
-
expect(@client.host).to eq('api.pusherapp.com')
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'should be preconfigured for port 80' do
|
13
|
-
expect(@client.port).to eq(80)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should use standard logger if no other logger if defined' do
|
17
|
-
Pusher.logger.debug('foo')
|
18
|
-
expect(Pusher.logger).to be_kind_of(Logger)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'logging configuration' do
|
23
|
-
it "can be configured to use any logger" do
|
24
|
-
logger = double("ALogger")
|
25
|
-
expect(logger).to receive(:debug).with('foo')
|
26
|
-
Pusher.logger = logger
|
27
|
-
Pusher.logger.debug('foo')
|
28
|
-
Pusher.logger = nil
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "configuration using url" do
|
33
|
-
it "should be possible to configure everything by setting the url" do
|
34
|
-
@client.url = "test://somekey:somesecret@api.staging.pusherapp.com:8080/apps/87"
|
35
|
-
|
36
|
-
expect(@client.scheme).to eq('test')
|
37
|
-
expect(@client.host).to eq('api.staging.pusherapp.com')
|
38
|
-
expect(@client.port).to eq(8080)
|
39
|
-
expect(@client.key).to eq('somekey')
|
40
|
-
expect(@client.secret).to eq('somesecret')
|
41
|
-
expect(@client.app_id).to eq('87')
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
it "should fail on bad urls" do
|
47
|
-
expect { @client.url = "gopher/somekey:somesecret@://api.staging.pusherapp.co://m:8080\apps\87" }.to raise_error(URI::InvalidURIError)
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should raise exception if app_id is not configured" do
|
51
|
-
@client.app_id = nil
|
52
|
-
expect {
|
53
|
-
@client.url
|
54
|
-
}.to raise_error(Pusher::ConfigurationError)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|