platformcraft-filespot 0.1.1 → 0.1.2

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: dcf14ef4db847c5acce86205463816c92e5253d7
4
- data.tar.gz: 0dcf09bdcf0ec78c02f21f47b98655edf4297c64
3
+ metadata.gz: d6bf9e9f33e476a6f92d4895ac4243944642b042
4
+ data.tar.gz: ce9672030d01ecda8e969836df3bd163f773f26a
5
5
  SHA512:
6
- metadata.gz: 09b095787de758de0b9d3ff6bba0f84c3168f9ae28b249f102a17f6d563967aff25f4e2a048767a8be3c55dcf714bd955f65588e43fdcbeb2877521c2925f676
7
- data.tar.gz: 38123ce0ad062ee4b7bd1c4ac6fed4bb54a4ca12adcc60f5ee6393462f2128a6210a4c9e091da6f9bb73f4c583e4c2b51cb56f4af05afe223ead91002d5a8142
6
+ metadata.gz: ea5192f38a95b6119cbee4584d1380e6fb5e8349dae2ff23843cd196f10129589dc4f23787e0cf25f4d1cd34d5d11114d458ef8e12181e06038aa17972f2bcc5
7
+ data.tar.gz: 314388a79535f18353cd9e817daff0b32b39d38c0731bf20e8a69efe3dfe229beafb1ff680f70aa5c0c62d763ac99c4b188116291c79c4d0166d535b2d026eff
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ Filespot API Ruby Gem
2
+ ====================
3
+ A Ruby wrapper for the Filespot API
4
+
5
+ http://doc.platformcraft.ru/filespot/api/
6
+
7
+ Installation
8
+ ------------
9
+
10
+ > gem install platformcraft-filespot
11
+
12
+
13
+ Configuration
14
+ ------------
15
+ ```ruby
16
+ Filespot.configure do |config|
17
+ config.url = 'api.platformcraft.ru'
18
+ config.version = 1
19
+ config.apikey = '12345'
20
+ config.apiuserid = '12345'
21
+ end
22
+ ```
23
+
24
+ Example
25
+ ------------
26
+ ```ruby
27
+ require 'filespot'
28
+
29
+ Filespot.configure do |config|
30
+ config.apiuserid = '12345'
31
+ config.apikey = '12345'
32
+ end
33
+
34
+ file = File.open('example.txt')
35
+
36
+ object = Filespot::Client.post_object(file)
37
+ puts object.name #example.txt
38
+
39
+ objects = Filespot::Client.get_objects
40
+ puts objects.count # 1
41
+ puts objects.map(&:name) # example.txt
42
+ ```
@@ -1,4 +1,5 @@
1
1
  require 'faraday'
2
+ require 'open-uri'
2
3
 
3
4
  module Filespot
4
5
  class Request
@@ -40,7 +41,7 @@ module Filespot
40
41
  end
41
42
 
42
43
  def self.api_uri(http_method, api_method, params)
43
- uri = URI("http://" + Filespot.url)
44
+ uri = URI("https://" + Filespot.url)
44
45
  uri.path = "/#{Filespot.version}#{api_method}"
45
46
  uri.query = URI.encode_www_form(init_params(params))
46
47
  uri.query += "&hash=#{Digest.hmac(http_method, uri.to_s)}"
@@ -1,3 +1,3 @@
1
1
  module Filespot
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
@@ -0,0 +1,27 @@
1
+ {
2
+ "code": 200,
3
+ "status": "success",
4
+ "count": 2,
5
+ "tasks": [
6
+ {
7
+ "id": "56365b04044dfe6917000002",
8
+ "category": "download",
9
+ "title": "Download test1.mp4",
10
+ "body": "Please wait.",
11
+ "status": "Progress",
12
+ "time_start": "01.11.2015T21:33:40",
13
+ "time_finish": "",
14
+ "lock": true
15
+ },
16
+ {
17
+ "id": "57011e2a534b44741fc67880",
18
+ "category": "download",
19
+ "title": "Download abc.mp4",
20
+ "body": "Download success.",
21
+ "status": "Completed",
22
+ "time_start": "03.04.2016T16:44:10",
23
+ "time_finish": "03.04.2016T16:44:11",
24
+ "lock": false
25
+ }
26
+ ]
27
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "code": 200,
3
+ "status": "success",
4
+ "object": {
5
+ "id": "56787f0c044dfe226b000001",
6
+ "name": "test.mp4",
7
+ "path": "/test.mp4",
8
+ "size": 985781,
9
+ "content_type": "video/mp4",
10
+ "create_date": "22.12.2015T01:37:00",
11
+ "latest_update": "",
12
+ "resource_url": "api.platformcraft.ru/objects/56787f0c044dfe226b000001",
13
+ "cdn_url": "cdn.platformcraft.ru/billy/test.mp4",
14
+ "video": "video.platformcraft.ru/56787f0c044dfe226b000001",
15
+ "advanced": {
16
+ "audio_streams": [
17
+ {
18
+ "bit_rate": 128079,
19
+ "channel_layout": "stereo",
20
+ "channels": 2,
21
+ "codec_long_name": "AAC (Advanced Audio Coding)",
22
+ "codec_name": "aac",
23
+ "codec_type": "audio",
24
+ "duration": 6.61712,
25
+ "index": 0,
26
+ "sample_rate": 44100
27
+ }
28
+ ],
29
+ "format": {
30
+ "bit_rate": 24756,
31
+ "duration": 6.618,
32
+ "format_long_name": "QuickTime / MOV",
33
+ "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
34
+ "nb_streams": 2
35
+ },
36
+ "video_streams": [
37
+ {
38
+ "bit_rate": 1062457,
39
+ "codec_name": "h264",
40
+ "codec_type": "video",
41
+ "codeclongname": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
42
+ "display_aspect_ratio": "16:9",
43
+ "duration": 6.573233,
44
+ "fps": 29.97002997002997,
45
+ "height": 360,
46
+ "index": 1,
47
+ "width": 640
48
+ }
49
+ ]
50
+ },
51
+ "previews":[
52
+ "cdn.platformcraft.ru/billy/.previews/preview-569fa828534b446996058b6d",
53
+ "cdn.platformcraft.ru/billy/.previews/preview-569fa828534b446996058b70",
54
+ "cdn.platformcraft.ru/billy/.previews/preview-569fa828534b446996058b73"
55
+ ],
56
+ "status":"ok"
57
+ }
58
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "code": 200,
3
+ "status": "success",
4
+ "object": {
5
+ "id": "56787f0c044dfe226b000001",
6
+ "name": "test.mp4",
7
+ "path": "/test.mp4",
8
+ "size": 985781,
9
+ "content_type": "video/mp4",
10
+ "create_date": "22.12.2015T01:37:00",
11
+ "latest_update": "",
12
+ "resource_url": "api.platformcraft.ru/objects/56787f0c044dfe226b000001",
13
+ "cdn_url": "cdn.platformcraft.ru/billy/test.mp4",
14
+ "video": "video.platformcraft.ru/56787f0c044dfe226b000001",
15
+ "status": "ok"
16
+ }
17
+ }
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Filespot::Download do
4
4
  describe 'Download' do
5
- context 'get_download_task' do
6
- it 'success' do
5
+ context '#get_download_task' do
6
+ it 'task_id found' do
7
7
  stub_get('/download_tasks/57011e2a534b44741fc67880', 'download_tasks_id.json')
8
8
  task = Filespot::Client.get_download_task('57011e2a534b44741fc67880')
9
9
  expect(task.id).to eq '57011e2a534b44741fc67880'
@@ -15,5 +15,13 @@ describe Filespot::Download do
15
15
  expect(task).to eq nil
16
16
  end
17
17
  end
18
+
19
+ context '#get_download_tasks' do
20
+ it 'get tasks' do
21
+ stub_get('/download_tasks', 'download_tasks.json')
22
+ tasks = Filespot::Client.get_download_tasks
23
+ expect(tasks.count).to eq 2
24
+ end
25
+ end
18
26
  end
19
27
  end
@@ -2,10 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  describe Filespot::Client do
4
4
  describe 'Objects' do
5
- it '.get_objects' do
5
+ it '#get_objects' do
6
6
  stub_get('/objects', 'objects.json')
7
7
  objects = Filespot::Client.get_objects
8
8
  expect(objects.count).to eq 2
9
9
  end
10
+
11
+ it '#get_object' do
12
+ stub_get('/objects/56787f0c044dfe226b000001', 'objects_id.json')
13
+ object = Filespot::Client.get_object('56787f0c044dfe226b000001')
14
+ expect(object.id).to eq '56787f0c044dfe226b000001'
15
+ end
10
16
  end
11
17
  end
data/spec/spec_helper.rb CHANGED
@@ -29,6 +29,14 @@ def stub_get(api_method, fixture_name)
29
29
  stub_request(:get, uri).with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=> encoding, 'User-Agent'=> agent}).to_return(status: 200, body: fixture(fixture_name), headers: {})
30
30
  end
31
31
 
32
+ def stub_post(api_method, fixture_name)
33
+ encoding = 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
34
+ agent = 'Faraday v0.9.2'
35
+ uri = /api.platformcraft.ru\/1/
36
+ stub_request(:post, uri).with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=> encoding, 'User-Agent'=> agent}).to_return(status: 200, body: fixture(fixture_name), headers: {})
37
+ end
38
+
39
+
32
40
  def fixture_path
33
41
  File.expand_path("../fixtures", __FILE__)
34
42
  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.1.1
4
+ version: 0.1.2
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-16 00:00:00.000000000 Z
11
+ date: 2016-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -75,6 +75,7 @@ files:
75
75
  - ".gitignore"
76
76
  - ".rspec"
77
77
  - Gemfile
78
+ - README.md
78
79
  - lib/filespot.rb
79
80
  - lib/filespot/client.rb
80
81
  - lib/filespot/client/download.rb
@@ -85,8 +86,11 @@ files:
85
86
  - lib/filespot/response.rb
86
87
  - lib/filespot/version.rb
87
88
  - platformcraft-filespot.gemspec
89
+ - spec/fixtures/download_tasks.json
88
90
  - spec/fixtures/download_tasks_id.json
89
91
  - spec/fixtures/objects.json
92
+ - spec/fixtures/objects_id.json
93
+ - spec/fixtures/objects_post.json
90
94
  - spec/lib/client/download_spec.rb
91
95
  - spec/lib/client/objects_spec.rb
92
96
  - spec/lib/client_spec.rb
@@ -112,16 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
116
  version: '0'
113
117
  requirements: []
114
118
  rubyforge_project:
115
- rubygems_version: 2.6.2
119
+ rubygems_version: 2.5.0
116
120
  signing_key:
117
121
  specification_version: 4
118
122
  summary: http://doc.platformcraft.ru/filespot/api/
119
- test_files:
120
- - spec/fixtures/download_tasks_id.json
121
- - spec/fixtures/objects.json
122
- - spec/lib/client/download_spec.rb
123
- - spec/lib/client/objects_spec.rb
124
- - spec/lib/client_spec.rb
125
- - spec/lib/digest_spec.rb
126
- - spec/lib/response_spec.rb
127
- - spec/spec_helper.rb
123
+ test_files: []