yandex-disk 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8763e1c52715aaa1e93b14e377bd2577938c650c
4
- data.tar.gz: 02d3ab15e02077907cf4b8d8601e642b84f8948f
3
+ metadata.gz: 94b6b93fa82493fec724772f534f1e6e5703ea18
4
+ data.tar.gz: 3e2f77620f4468cdb8d989a70521f090dac10012
5
5
  SHA512:
6
- metadata.gz: e2507fd9f154fbb75dd268314dd5d5cb618821e02c8a048ab40d1d873138d6a38e7605e4ea3456f6ea3dd90ee0893872cb2ac3ed0e8d5ac591a7ebc5eadbf0d5
7
- data.tar.gz: aec291b688b9ed778a23d8b77bc7e53617ca72c5d13e125f1be3c79172028389fa80bf69d89045564b79256a9ec52403d307e09108eb34d00e42803afa1b5a9a
6
+ metadata.gz: ea626f8d1fadb0f37c1e2516d9c1b2971dbd4eb1180224049f93bebed7cc0d429cf8b5578930733fa1283dcf015b216227748d1aba7e96c92ec9561c6de0acc7
7
+ data.tar.gz: 69ba2c1d51420a294f16ab57e8b0b5c1d1ae9e8e3489e36ba5d26f23536d72763d929da5b994fa36309489abb98fe78e2cde982f3871bab262f4da430d27de4a
data/README.md CHANGED
@@ -46,6 +46,11 @@ disk.move('/path/to/remote/file/or/dir', '/path/to/new/remote/file/or/dir')
46
46
  # delete file/dir
47
47
  disk.delete('/path/to/remote/file/or/dir') # returns `true` if everything is ok
48
48
 
49
+ # property update operations:
50
+
51
+ # to make folder or file public
52
+ disk.make_public('/path/to/remote/dir/or/file') # returns hash with public url `=> { :public_url => "https://yadi.sk/i/B98Qjxxx3S5QJc" }` if everything is ok
53
+
49
54
  # to get quotas
50
55
  disk.space # returns hash like { :quota_available_bytes => 2488943615, :quota_used_bytes => 2488943615 }
51
56
 
@@ -5,6 +5,7 @@ require 'faraday'
5
5
  require 'faraday_middleware'
6
6
 
7
7
  Faraday::Connection::METHODS << :propfind
8
+ Faraday::Connection::METHODS << :proppatch
8
9
 
9
10
  module Yandex
10
11
  module Disk
@@ -63,6 +64,11 @@ module Yandex
63
64
  request.perform
64
65
  end
65
66
 
67
+ def make_public path
68
+ request = Request::Publication.new(@http, path)
69
+ request.perform
70
+ end
71
+
66
72
  alias_method :mkdir, :mkcol
67
73
 
68
74
  def mkdir_p path
@@ -1,4 +1,5 @@
1
1
  module Yandex::Disk::Client::Request
2
2
  autoload :Space, 'yandex/disk/client/request/space'
3
3
  autoload :List, 'yandex/disk/client/request/list'
4
+ autoload :Publication, 'yandex/disk/client/request/publication'
4
5
  end
@@ -0,0 +1,51 @@
1
+ require 'nokogiri'
2
+
3
+ class Yandex::Disk::Client::Request::Publication
4
+ BODY =
5
+ '<propertyupdate xmlns="DAV:">
6
+ <set>
7
+ <prop>
8
+ <public_url xmlns="urn:yandex:disk:meta">true</public_url>
9
+ </prop>
10
+ </set>
11
+ </propertyupdate>'
12
+ HEADERS = {
13
+ }
14
+
15
+ def initialize http, path
16
+ @http = http
17
+ @path = path
18
+ end
19
+
20
+ def perform
21
+ response = @http.run_request :proppatch, @path, BODY, HEADERS
22
+ parse_result = parse(response.body)
23
+ { :public_url => parse_result.public_url }
24
+ end
25
+
26
+ private
27
+
28
+ class AttributesParser < Nokogiri::XML::SAX::Document
29
+ attr_reader :public_url
30
+
31
+ def start_element name, attributes = []
32
+ case name
33
+ when 'public_url'
34
+ @public_url = true
35
+ end
36
+ end
37
+
38
+ def characters string
39
+ @public_url = string if (@public_url == true)
40
+ end
41
+ end
42
+
43
+ def parse body
44
+ attributes_parser = AttributesParser.new
45
+
46
+ parser = Nokogiri::XML::SAX::Parser.new(attributes_parser)
47
+ parser.parse(body)
48
+
49
+ attributes_parser
50
+ end
51
+ end
@@ -27,7 +27,7 @@ class Yandex::Disk::Client::Request::Space
27
27
 
28
28
  private
29
29
 
30
- class AttriutesParser < Nokogiri::XML::SAX::Document
30
+ class AttributesParser < Nokogiri::XML::SAX::Document
31
31
  attr_reader :quota_available_bytes, :quota_used_bytes
32
32
 
33
33
  def start_element name, attributes = []
@@ -46,7 +46,7 @@ class Yandex::Disk::Client::Request::Space
46
46
  end
47
47
 
48
48
  def parse body
49
- attributes_parser = AttriutesParser.new
49
+ attributes_parser = AttributesParser.new
50
50
 
51
51
  parser = Nokogiri::XML::SAX::Parser.new(attributes_parser)
52
52
  parser.parse(body)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Yandex
4
4
  module Disk
5
- VERSION = '0.0.7'
5
+ VERSION = '0.0.8'
6
6
  end
7
7
  end
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency('faraday', '~> 0.8')
22
- spec.add_dependency('nokogiri', '~> 1.6.0')
22
+ spec.add_dependency('nokogiri', '>= 1.6.0')
23
23
  spec.add_dependency('faraday_middleware', '~> 0.9.0')
24
24
  spec.add_dependency('excon', '>= 0.16')
25
25
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yandex-disk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yury Korolev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-28 00:00:00.000000000 Z
12
+ date: 2018-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -29,14 +29,14 @@ dependencies:
29
29
  name: nokogiri
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - "~>"
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 1.6.0
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - "~>"
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: 1.6.0
42
42
  - !ruby/object:Gem::Dependency
@@ -113,6 +113,7 @@ files:
113
113
  - lib/yandex/disk/client.rb
114
114
  - lib/yandex/disk/client/request.rb
115
115
  - lib/yandex/disk/client/request/list.rb
116
+ - lib/yandex/disk/client/request/publication.rb
116
117
  - lib/yandex/disk/client/request/space.rb
117
118
  - lib/yandex/disk/version.rb
118
119
  - test/yandex_dist_test.rb
@@ -137,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
138
  version: '0'
138
139
  requirements: []
139
140
  rubyforge_project:
140
- rubygems_version: 2.2.2
141
+ rubygems_version: 2.5.2
141
142
  signing_key:
142
143
  specification_version: 4
143
144
  summary: Ruby client for Yandex.Disk with backup gem support