platformcraft-filespot 0.0.4 → 0.1.0

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
  SHA1:
3
- metadata.gz: b3d2b33ba24d26cc68e01cb49807c7ceaf04a31a
4
- data.tar.gz: 9bedc8895465e41f61343c650fc0f82e08c1e15e
3
+ metadata.gz: ce9b8ca97b45d1bd725051781cab4895a77cbf9f
4
+ data.tar.gz: 0bf5eebbdf1402e9668e90f92446c0186e508de4
5
5
  SHA512:
6
- metadata.gz: 6f05ff51f02b870835d5e9c1780e9ab411736db04186110d4227f181cc34e34548460d044d1f1131f5001e1998c4ef588cb55e258ac9870c3ed42c7a839b219b
7
- data.tar.gz: 732aea3821e71b77b3e3fb67d78a2e4c62b470e8a4dbb20b09b4ffc31f81b9622fc9d007a89b50a128cfad40433144993d33cad0f7a160e939c6c46310959f2d
6
+ metadata.gz: de9d88d716c115541d00fe96671c0b689556408c6c24a7fbbf3a43aa531de6d40a834e323b5c5e169d9858f477259b484e34d9991bfa0487b38f56fd4dc6d31a
7
+ data.tar.gz: ab831422fcbeeeb6ec0baea3e0d391e792de277943e39dd23fa323b2aad7761317c42190e46c984cabd93aa87a8d137f2b4e8de6941de45d933ace4d3707ed2f
@@ -1,7 +1,9 @@
1
1
  require 'filespot/client/objects'
2
+ require 'filespot/client/download'
2
3
 
3
4
  module Filespot
4
5
  class Client
5
6
  extend Objects
7
+ extend Download
6
8
  end
7
9
  end
@@ -0,0 +1,39 @@
1
+ module Filespot
2
+ module Download
3
+ def post_download(url, path = nil)
4
+ res = Response.new(Request.post("/download", {}, { url: url, path: path }))
5
+ return nil unless res.code == 200
6
+ res.data['task_id']
7
+ end
8
+
9
+ def get_download_tasks
10
+ res = Response.new(Request.get("/download_tasks"))
11
+ return [] unless res.code == 200
12
+
13
+ arr = []
14
+ count, tasks = res.data['count'].to_i, res.data['tasks']
15
+ count.times { |i| arr << Task.new(tasks[i]) }
16
+ arr
17
+ end
18
+
19
+ def get_download_task(task_id)
20
+ res = Response.new(Request.get("/download_tasks/#{task_id}"))
21
+ return nil unless res.code == 200
22
+ Task.new(res.data['task'], res.data['files'])
23
+ end
24
+
25
+ def delete_download_task(task_id)
26
+ res = Response.new(Request.delete("/download_tasks/#{task_id}"))
27
+ res
28
+ end
29
+ end
30
+
31
+ class Task
32
+ attr_reader :files
33
+
34
+ def initialize(data, files = [])
35
+ data.each { |k, v| define_singleton_method(k.to_sym) { v } }
36
+ @files = files
37
+ end
38
+ end
39
+ end
@@ -6,7 +6,7 @@ module Filespot
6
6
 
7
7
  arr = []
8
8
  count, objects = res.data['count'].to_i, res.data['objects']
9
- count.times { |i| arr << Object.new(res.data['objects'][i]) }
9
+ count.times { |i| arr << Object.new(objects[i]) }
10
10
  arr
11
11
  end
12
12
 
@@ -16,9 +16,9 @@ module Filespot
16
16
  Object.new(res.data['object'])
17
17
  end
18
18
 
19
- def post_object(file, type)
20
- file_io = Faraday::UploadIO.new(file, type)
21
- res = Response.new(Request.post("/objects", {}, { file: file_io }))
19
+ def post_object(file, name = nil)
20
+ file_io = Faraday::UploadIO.new(file, 'application/octet-stream')
21
+ res = Response.new(Request.post("/objects", {}, { file: file_io, name: name }))
22
22
  return res unless res.code == 200
23
23
 
24
24
  Object.new(res.data['object'])
@@ -1,3 +1,3 @@
1
1
  module Filespot
2
- VERSION = '0.0.4'.freeze
2
+ VERSION = '0.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: platformcraft-filespot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - droff
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-14 00:00:00.000000000 Z
11
+ date: 2016-04-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -77,6 +77,7 @@ files:
77
77
  - Gemfile
78
78
  - lib/filespot.rb
79
79
  - lib/filespot/client.rb
80
+ - lib/filespot/client/download.rb
80
81
  - lib/filespot/client/objects.rb
81
82
  - lib/filespot/configuration.rb
82
83
  - lib/filespot/digest.rb
@@ -108,13 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
109
  version: '0'
109
110
  requirements: []
110
111
  rubyforge_project:
111
- rubygems_version: 2.6.2
112
+ rubygems_version: 2.5.0
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: http://doc.platformcraft.ru/filespot/api/
115
- test_files:
116
- - spec/fixtures/objects.json
117
- - spec/lib/client/objects_spec.rb
118
- - spec/lib/client_spec.rb
119
- - spec/lib/digest_spec.rb
120
- - spec/spec_helper.rb
116
+ test_files: []