yandex_client 1.1.0 → 1.3.1
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/.github/workflows/main.yml +1 -1
- data/.rubocop.yml +1 -1
- data/README.md +2 -1
- data/dip.yml +1 -1
- data/lib/yandex_client/dav.rb +21 -4
- data/lib/yandex_client/disk.rb +15 -3
- data/lib/yandex_client/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 847c0309ab86bbacce9d7641f210b90bf9d821987349d0bb76f14dd7717891b5
|
4
|
+
data.tar.gz: b4ea99b824d51a3622fbb93cdd49d968870dfed4e21c88b6d7a0a6d3a7eef6c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54728b848084d16efab9c6a5778df2df1792c8eacdcaaae7ae8a72affc339429e64476107fee94be0993cfc227b3562a9fc1a61084acbb61263eb15fffca9643
|
7
|
+
data.tar.gz: 96d47f2be5847ced46d1c01fa99e4443a3db673b5cc7be092ef3bbfbb8cfb1261932b43cd8f90234f64fd53bf97d1812a10c86c19c17822051483e686952242e
|
data/.github/workflows/main.yml
CHANGED
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -42,7 +42,8 @@ https://yandex.ru/dev/disk/api/reference/content-docpage/
|
|
42
42
|
```ruby
|
43
43
|
YandexClient::Disk['access_token'].info
|
44
44
|
YandexClient::Disk['access_token'].download_url('path/to/file')
|
45
|
-
YandexClient::Disk['access_token'].upload_url('path/to/file')
|
45
|
+
YandexClient::Disk['access_token'].upload_url('path/to/file', overwrite: false)
|
46
|
+
YandexClient::Disk['access_token'].move('path/to/file', 'new_path/to/new_file', overwrite: false)
|
46
47
|
```
|
47
48
|
|
48
49
|
## Auth
|
data/dip.yml
CHANGED
data/lib/yandex_client/dav.rb
CHANGED
@@ -67,6 +67,20 @@ module YandexClient
|
|
67
67
|
)
|
68
68
|
end
|
69
69
|
|
70
|
+
# https://yandex.ru/dev/disk/doc/dg/reference/move.html
|
71
|
+
def move(source, dest, overwrite: false)
|
72
|
+
headers = auth_headers.merge!(
|
73
|
+
'Destination' => absolute_path(dest),
|
74
|
+
'Overwrite' => overwrite ? 'T' : 'F'
|
75
|
+
)
|
76
|
+
|
77
|
+
process_response with_config.request(
|
78
|
+
:move,
|
79
|
+
url_for(source),
|
80
|
+
headers: headers
|
81
|
+
)
|
82
|
+
end
|
83
|
+
|
70
84
|
def propfind(dest = '', depth = 1)
|
71
85
|
headers = auth_headers.merge!(
|
72
86
|
Depth: depth.to_s,
|
@@ -88,10 +102,7 @@ module YandexClient
|
|
88
102
|
|
89
103
|
def url_for(dest)
|
90
104
|
URI.parse(ACTION_URL).tap do |uri|
|
91
|
-
path = dest
|
92
|
-
path = "/#{path}" unless path.match?(%r{^/})
|
93
|
-
|
94
|
-
uri.path = path
|
105
|
+
uri.path = absolute_path(dest)
|
95
106
|
end
|
96
107
|
end
|
97
108
|
|
@@ -100,5 +111,11 @@ module YandexClient
|
|
100
111
|
|
101
112
|
error_for_response(response)
|
102
113
|
end
|
114
|
+
|
115
|
+
def absolute_path(path)
|
116
|
+
return path if path.match?(%r{^/})
|
117
|
+
|
118
|
+
"/#{path}"
|
119
|
+
end
|
103
120
|
end
|
104
121
|
end
|
data/lib/yandex_client/disk.rb
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
require 'json'
|
4
4
|
|
5
5
|
module YandexClient
|
6
|
-
# https://yandex.ru/dev/disk/api/reference/capacity
|
7
|
-
# https://yandex.ru/dev/disk/api/reference/content
|
6
|
+
# https://yandex.ru/dev/disk/api/reference/capacity.html
|
7
|
+
# https://yandex.ru/dev/disk/api/reference/content.html
|
8
|
+
# https://yandex.ru/dev/disk/api/reference/move.html
|
8
9
|
#
|
9
10
|
# YandexClient::Disk[access_token].info
|
10
11
|
# YandexClient::Disk[access_token].download_url('path/to/file')
|
@@ -49,7 +50,7 @@ module YandexClient
|
|
49
50
|
def upload_url(path, overwrite: false)
|
50
51
|
url = URI.parse(ACTION_URL).tap do |uri|
|
51
52
|
uri.path = '/v1/disk/resources/upload'
|
52
|
-
uri.query = URI.encode_www_form(path:
|
53
|
+
uri.query = URI.encode_www_form(path: path, overwrite: overwrite)
|
53
54
|
end
|
54
55
|
|
55
56
|
process_response(
|
@@ -57,6 +58,17 @@ module YandexClient
|
|
57
58
|
).fetch(:href)
|
58
59
|
end
|
59
60
|
|
61
|
+
def move(from, to, overwrite: false)
|
62
|
+
url = URI.parse(ACTION_URL).tap do |uri|
|
63
|
+
uri.path = '/v1/disk/resources/move'
|
64
|
+
uri.query = URI.encode_www_form(from: from, path: to, overwrite: overwrite)
|
65
|
+
end
|
66
|
+
|
67
|
+
process_response(
|
68
|
+
with_config.post(url, headers: auth_headers)
|
69
|
+
).fetch(:href)
|
70
|
+
end
|
71
|
+
|
60
72
|
private
|
61
73
|
|
62
74
|
def auth_headers
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxim Tretyakov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
- !ruby/object:Gem::Version
|
174
174
|
version: '0'
|
175
175
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
176
|
+
rubygems_version: 3.3.5
|
177
177
|
signing_key:
|
178
178
|
specification_version: 4
|
179
179
|
summary: Yandex Client
|