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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8b82741c31dd638b0ff6793b208d6c7ab33e9b5dc613f6c9ffd3482fb5dcde3
4
- data.tar.gz: 510f836e9b6566ba397342544c9430232f7c88a39607261450d413c82b998367
3
+ metadata.gz: 847c0309ab86bbacce9d7641f210b90bf9d821987349d0bb76f14dd7717891b5
4
+ data.tar.gz: b4ea99b824d51a3622fbb93cdd49d968870dfed4e21c88b6d7a0a6d3a7eef6c6
5
5
  SHA512:
6
- metadata.gz: 91e69d64b589fc868bb0bc18956cb81c85031e6f4bef8ffd8619a2578f1f5f4e269635b11d818f801230b0e7c0b491a6cd55a7a98bcab1cb6021e92d49f7f677
7
- data.tar.gz: 2fff713b5cc2fe4dae297347edb3a54d4ee93c31d233d1406ad61a8d2f76ec1792c7693e5c56422b2f9a4011131c5d49454c4d9c3f44c0040d08f490298ad005
6
+ metadata.gz: 54728b848084d16efab9c6a5778df2df1792c8eacdcaaae7ae8a72affc339429e64476107fee94be0993cfc227b3562a9fc1a61084acbb61263eb15fffca9643
7
+ data.tar.gz: 96d47f2be5847ced46d1c01fa99e4443a3db673b5cc7be092ef3bbfbb8cfb1261932b43cd8f90234f64fd53bf97d1812a10c86c19c17822051483e686952242e
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ["2.5", "2.6", "2.7", "3.0"]
14
+ ruby-version: ["2.7", "3.0", "3.1"]
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v2
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 3.0
2
+ TargetRubyVersion: 2.7
3
3
  NewCops: enable
4
4
  SuggestExtensions: false
5
5
  Exclude:
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
@@ -1,7 +1,7 @@
1
1
  version: '3.3'
2
2
 
3
3
  environment:
4
- DOCKER_RUBY_VERSION: 3.0
4
+ DOCKER_RUBY_VERSION: 3.1
5
5
 
6
6
  compose:
7
7
  files:
@@ -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
@@ -3,8 +3,9 @@
3
3
  require 'json'
4
4
 
5
5
  module YandexClient
6
- # https://yandex.ru/dev/disk/api/reference/capacity-docpage/
7
- # https://yandex.ru/dev/disk/api/reference/content-docpage/
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: ::CGI.escape(path), overwrite: overwrite)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module YandexClient
4
- VERSION = '1.1.0'
4
+ VERSION = '1.3.1'
5
5
  end
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.0
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: 2021-12-06 00:00:00.000000000 Z
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.2.5
176
+ rubygems_version: 3.3.5
177
177
  signing_key:
178
178
  specification_version: 4
179
179
  summary: Yandex Client