platformcraft-filespot 0.1.5 → 0.1.6

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: f3cbc70d020bcd62346f1726886acc00a20b4a2e
4
- data.tar.gz: cdb832f47944d0f0378c0678de16da3f1d6679ad
3
+ metadata.gz: 96b2cbbf8419db3f0ee1694b7954417441946387
4
+ data.tar.gz: fff0f63033cbb2c76197513fae2ad719ae9e2bbe
5
5
  SHA512:
6
- metadata.gz: 975d1d2ba3f209d8c98470dfb7ccb2a1aacaa0fe6c849fcafdb196ef691da914f50efeee8de72e708a95e64294beee93a42db8d3c6fc3649e6b69ac8453a629c
7
- data.tar.gz: c3c7e031f6cfa2a79943e5f793f474b723d8fc3e7578ea42d90d456bd3c3e002c20821616e2fd54ab8fb3365625d8e43fb1fe297a9f49a3d2226248ad1a2bd6f
6
+ metadata.gz: 7eb7cab06ddfa53433744dfaf29d1a48398f5d2effa1117650b3f208acfcb5fa9a580647776d0b1d5b04b016b7e044d7ba1913e18457079b907190b92c626408
7
+ data.tar.gz: 45cc86e0d83d084fe585172887d8f843dc9aeadd9cc80b3bd243e18a0f94b8ed790d06580010b9efa63d699a4f565fe71dd6dd77e04df49fb7300fdcbd314476
data/lib/filespot.rb CHANGED
@@ -9,4 +9,7 @@ require 'filespot/client'
9
9
  # Filespot gem module
10
10
  module Filespot
11
11
  extend Configuration
12
+
13
+ Error = Class.new(StandardError)
14
+ TaskError = Class.new(Error)
12
15
  end
@@ -2,6 +2,8 @@ module Filespot
2
2
  ##
3
3
  # Download module wraps methods with `/download` resource[http://doc.platformcraft.ru/filespot/api/#download]
4
4
  module Download
5
+ STATUS_ERROR = 'Error'.freeze
6
+
5
7
  # POST /download
6
8
  # returns task_id
7
9
  def post_download(url, path = nil)
@@ -27,7 +29,10 @@ module Filespot
27
29
  def get_download_task(task_id)
28
30
  res = Response.new(Request.get("/download_tasks/#{task_id}"))
29
31
  return nil unless res.code == 200
30
- Task.new(res.data['task'], res.data['files'])
32
+ task = Task.new(res.data['task'], res.data['files'])
33
+
34
+ raise(Filespot::TaskError, task.body) if task.status == STATUS_ERROR
35
+ task
31
36
  end
32
37
 
33
38
  # DELETE /download_tasks/{:task_id}
@@ -1,4 +1,3 @@
1
1
  module Filespot
2
- # gem version
3
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
4
3
  end
@@ -0,0 +1,15 @@
1
+ {
2
+ "code": 200,
3
+ "files": null,
4
+ "status": "success",
5
+ "task": {
6
+ "id": "57011e2a534b44741fc67880",
7
+ "category": "download",
8
+ "title": "Download 0000001.1080.mp4",
9
+ "body": "Internal server error.",
10
+ "status": "Error",
11
+ "time_start": "25.01.2021T16:03:20",
12
+ "time_finish": "25.01.2021T16:04:20",
13
+ "lock": false
14
+ }
15
+ }
@@ -1,10 +1,12 @@
1
1
  describe Filespot::Download do
2
2
  describe 'Download' do
3
3
  context '#get_download_task' do
4
+ let(:task_id) { '57011e2a534b44741fc67880' }
5
+
4
6
  it 'task_id found' do
5
- stub_get('/download_tasks/57011e2a534b44741fc67880', 'download_tasks_id.json')
6
- task = Filespot::Client.get_download_task('57011e2a534b44741fc67880')
7
- expect(task.id).to eq '57011e2a534b44741fc67880'
7
+ stub_get("/download_tasks/#{task_id}", 'download_tasks_id.json')
8
+ task = Filespot::Client.get_download_task(task_id)
9
+ expect(task.id).to eq task_id
8
10
  end
9
11
 
10
12
  it 'task_id not found' do
@@ -12,6 +14,11 @@ describe Filespot::Download do
12
14
  task = Filespot::Client.get_download_task('nil')
13
15
  expect(task).to eq nil
14
16
  end
17
+
18
+ it 'raise error' do
19
+ stub_get("download_tasks/#{task_id}", 'download_tasks_id_error.json')
20
+ expect { Filespot::Client.get_download_task(task_id) }.to raise_error(Filespot::TaskError)
21
+ end
15
22
  end
16
23
 
17
24
  context '#get_download_tasks' do
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.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - droff
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-12 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -104,6 +104,7 @@ files:
104
104
  - platformcraft-filespot.gemspec
105
105
  - spec/fixtures/download_tasks.json
106
106
  - spec/fixtures/download_tasks_id.json
107
+ - spec/fixtures/download_tasks_id_error.json
107
108
  - spec/fixtures/objects.json
108
109
  - spec/fixtures/objects_id.json
109
110
  - spec/fixtures/objects_post.json
@@ -116,7 +117,7 @@ files:
116
117
  homepage: https://github.com/droff/platformcraft-filespot
117
118
  licenses: []
118
119
  metadata: {}
119
- post_install_message:
120
+ post_install_message:
120
121
  rdoc_options: []
121
122
  require_paths:
122
123
  - lib
@@ -131,9 +132,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
132
  - !ruby/object:Gem::Version
132
133
  version: '0'
133
134
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.6.8
136
- signing_key:
135
+ rubyforge_project:
136
+ rubygems_version: 2.6.14
137
+ signing_key:
137
138
  specification_version: 4
138
139
  summary: http://doc.platformcraft.ru/filespot/api/
139
- test_files: []
140
+ test_files:
141
+ - spec/fixtures/download_tasks.json
142
+ - spec/fixtures/download_tasks_id.json
143
+ - spec/fixtures/download_tasks_id_error.json
144
+ - spec/fixtures/objects.json
145
+ - spec/fixtures/objects_id.json
146
+ - spec/fixtures/objects_post.json
147
+ - spec/lib/client/download_spec.rb
148
+ - spec/lib/client/objects_spec.rb
149
+ - spec/lib/client_spec.rb
150
+ - spec/lib/digest_spec.rb
151
+ - spec/lib/response_spec.rb
152
+ - spec/spec_helper.rb