platformcraft-filespot 0.1.1 → 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: dcf14ef4db847c5acce86205463816c92e5253d7
4
- data.tar.gz: 0dcf09bdcf0ec78c02f21f47b98655edf4297c64
3
+ metadata.gz: 96b2cbbf8419db3f0ee1694b7954417441946387
4
+ data.tar.gz: fff0f63033cbb2c76197513fae2ad719ae9e2bbe
5
5
  SHA512:
6
- metadata.gz: 09b095787de758de0b9d3ff6bba0f84c3168f9ae28b249f102a17f6d563967aff25f4e2a048767a8be3c55dcf714bd955f65588e43fdcbeb2877521c2925f676
7
- data.tar.gz: 38123ce0ad062ee4b7bd1c4ac6fed4bb54a4ca12adcc60f5ee6393462f2128a6210a4c9e091da6f9bb73f4c583e4c2b51cb56f4af05afe223ead91002d5a8142
6
+ metadata.gz: 7eb7cab06ddfa53433744dfaf29d1a48398f5d2effa1117650b3f208acfcb5fa9a580647776d0b1d5b04b016b7e044d7ba1913e18457079b907190b92c626408
7
+ data.tar.gz: 45cc86e0d83d084fe585172887d8f843dc9aeadd9cc80b3bd243e18a0f94b8ed790d06580010b9efa63d699a4f565fe71dd6dd77e04df49fb7300fdcbd314476
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  Gemfile.lock
2
2
  *.gem
3
+ doc
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1
4
+ - 2.2
data/README.md ADDED
@@ -0,0 +1,44 @@
1
+ [![Build Status](https://travis-ci.org/droff/platformcraft-filespot.svg?branch=master)](https://travis-ci.org/droff/platformcraft-filespot)
2
+
3
+ Filespot API Ruby Gem
4
+ ====================
5
+ A Ruby wrapper for the Filespot API
6
+
7
+ http://doc.platformcraft.ru/filespot/api/
8
+
9
+ Installation
10
+ ------------
11
+
12
+ > gem install platformcraft-filespot
13
+
14
+
15
+ Configuration
16
+ ------------
17
+ ```ruby
18
+ Filespot.configure do |config|
19
+ config.url = 'api.platformcraft.ru'
20
+ config.version = 1
21
+ config.apikey = '12345'
22
+ config.apiuserid = '12345'
23
+ end
24
+ ```
25
+
26
+ Example
27
+ ------------
28
+ ```ruby
29
+ require 'filespot'
30
+
31
+ Filespot.configure do |config|
32
+ config.apiuserid = '12345'
33
+ config.apikey = '12345'
34
+ end
35
+
36
+ file = File.open('example.txt')
37
+
38
+ object = Filespot::Client.post_object(file)
39
+ puts object.name #example.txt
40
+
41
+ objects = Filespot::Client.get_objects
42
+ puts objects.count # 1
43
+ puts objects.map(&:name) # example.txt
44
+ ```
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
8
+
9
+ namespace :doc do
10
+ begin
11
+ require 'yard'
12
+ rescue LoadError
13
+ else
14
+ YARD::Rake::YardocTask.new do |task|
15
+ task.files = ['README.md', 'lib/**/*.rb']
16
+ task.options = [
17
+ '--protected',
18
+ '--output-dir', 'doc/yard',
19
+ '--tag', 'format:Supported formats',
20
+ '--tag', 'authenticated:Requires Authentication',
21
+ '--tag', 'rate_limited:Rate Limited',
22
+ '--markup', 'markdown',
23
+ ]
24
+ end
25
+ end
26
+ end
data/lib/filespot.rb CHANGED
@@ -5,6 +5,11 @@ require 'filespot/request'
5
5
  require 'filespot/response'
6
6
  require 'filespot/client'
7
7
 
8
+ ##
9
+ # Filespot gem module
8
10
  module Filespot
9
11
  extend Configuration
12
+
13
+ Error = Class.new(StandardError)
14
+ TaskError = Class.new(Error)
10
15
  end
@@ -2,6 +2,8 @@ require 'filespot/client/objects'
2
2
  require 'filespot/client/download'
3
3
 
4
4
  module Filespot
5
+ ##
6
+ # Client class provides a communication with API by methods
5
7
  class Client
6
8
  extend Objects
7
9
  extend Download
@@ -1,11 +1,19 @@
1
1
  module Filespot
2
+ ##
3
+ # Download module wraps methods with `/download` resource[http://doc.platformcraft.ru/filespot/api/#download]
2
4
  module Download
5
+ STATUS_ERROR = 'Error'.freeze
6
+
7
+ # POST /download
8
+ # returns task_id
3
9
  def post_download(url, path = nil)
4
10
  res = Response.new(Request.post("/download", {}, { url: url, path: path }))
5
11
  return nil unless res.code == 200
6
12
  res.data['task_id']
7
13
  end
8
14
 
15
+ # GET /download_tasks
16
+ # returns tasks list
9
17
  def get_download_tasks
10
18
  res = Response.new(Request.get("/download_tasks"))
11
19
  return [] unless res.code == 200
@@ -16,21 +24,32 @@ module Filespot
16
24
  arr
17
25
  end
18
26
 
27
+ # GET /download_tasks/{:task_id}
28
+ # returns task data
19
29
  def get_download_task(task_id)
20
30
  res = Response.new(Request.get("/download_tasks/#{task_id}"))
21
31
  return nil unless res.code == 200
22
- 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
23
36
  end
24
37
 
38
+ # DELETE /download_tasks/{:task_id}
39
+ # returns removal status
25
40
  def delete_download_task(task_id)
26
41
  res = Response.new(Request.delete("/download_tasks/#{task_id}"))
27
42
  res
28
43
  end
29
44
  end
30
45
 
46
+ ##
47
+ # Task class provides task as object
31
48
  class Task
49
+ # files data
32
50
  attr_reader :files
33
51
 
52
+ # creates object
34
53
  def initialize(data, files = [])
35
54
  data.each { |k, v| define_singleton_method(k.to_sym) { v } }
36
55
  @files = files
@@ -1,7 +1,11 @@
1
1
  module Filespot
2
+ ##
3
+ # Objects module wraps methods with `/objects` resource[http://doc.platformcraft.ru/filespot/api/#objects]
2
4
  module Objects
3
- def get_objects
4
- res = Response.new(Request.get("/objects"))
5
+ # GET /objects
6
+ # returns an objects list
7
+ def get_objects(folder=nil)
8
+ res = Response.new(Request.get("/objects", folder: folder))
5
9
  return [] unless res.code == 200
6
10
 
7
11
  arr = []
@@ -10,12 +14,18 @@ module Filespot
10
14
  arr
11
15
  end
12
16
 
17
+ # GET /objects/{:object_id}
18
+ # returns an object
13
19
  def get_object(object_id)
14
20
  res = Response.new(Request.get("/objects/#{object_id}"))
15
21
  return nil unless res.code == 200
16
22
  Object.new(res.data['object'])
17
23
  end
18
24
 
25
+ # POST /objects
26
+ # * +file+ - file path(*required*)
27
+ # * +name+ - name that will be stored in API service
28
+ # returns a file info
19
29
  def post_object(file, name = nil)
20
30
  file_io = Faraday::UploadIO.new(file, 'application/octet-stream')
21
31
  res = Response.new(Request.post("/objects", {}, { file: file_io, name: name }))
@@ -24,13 +34,44 @@ module Filespot
24
34
  Object.new(res.data['object'])
25
35
  end
26
36
 
37
+ # DELETE /objects/{:object_id}
38
+ # returns removal status
27
39
  def delete_object(object_id)
28
40
  res = Response.new(Request.delete("/objects/#{object_id}"))
29
41
  res
30
42
  end
43
+
44
+ # deletes object which has been found by path
45
+ def delete_object_by_path(path)
46
+ object = get_object_by_path(path)
47
+ return delete_object(object.id) if object
48
+
49
+ nil
50
+ end
51
+
52
+ # GET /objects/{:path}
53
+ # returns an objects list
54
+ def get_object_by_path(path)
55
+ full_path = path[0] == '/' ? path : "/#{path}"
56
+ folder = File.dirname(full_path)
57
+
58
+ get_objects(folder).each do |object|
59
+ return object if object.path == full_path
60
+ end
61
+
62
+ nil
63
+ end
64
+
65
+ # checks if object exists
66
+ def exists?(path)
67
+ !!get_object_by_path(path)
68
+ end
31
69
  end
32
70
 
71
+ # Object class provides API object as ruby object
33
72
  class Object
73
+
74
+ # creates object
34
75
  def initialize(data)
35
76
  data.each { |k, v| define_singleton_method(k.to_sym) { v } }
36
77
  end
@@ -1,18 +1,35 @@
1
1
  module Filespot
2
+
3
+ ##
4
+ # Configuration module provides gem settings
5
+ #
6
+ # Filespot.configure do |config|
7
+ # config.url = 'api.platformcraft.ru'
8
+ # config.version = 1
9
+ # config.apikey = '12345'
10
+ # config.apiuserid = '12345'
11
+ # end
12
+ #
2
13
  module Configuration
14
+ # default API url
3
15
  API_URL = 'api.platformcraft.ru'
16
+ #default API version
4
17
  API_VERSION = 1
5
18
 
19
+ # options
6
20
  OPTIONS = [
7
21
  :url, :version, :apiuserid, :apikey
8
22
  ].freeze
9
23
 
24
+ # settings attributes
10
25
  attr_accessor *OPTIONS
11
26
 
27
+ # invoke module
12
28
  def self.extended(base)
13
29
  base.init
14
30
  end
15
31
 
32
+ # set default params
16
33
  def init
17
34
  self.url = API_URL
18
35
  self.version = API_VERSION
@@ -20,6 +37,7 @@ module Filespot
20
37
  self.apikey = nil
21
38
  end
22
39
 
40
+ # configure with gem settings
23
41
  def configure
24
42
  yield self
25
43
  end
@@ -2,9 +2,13 @@ require 'openssl'
2
2
  require 'base64'
3
3
 
4
4
  module Filespot
5
+ ##
6
+ # Digest class provides some encryption features
5
7
  class Digest
8
+
9
+ # generates HMAC[https://en.wikipedia.org/wiki/Hash-based_message_authentication_code]
6
10
  def self.hmac(http_method, uri)
7
- data = "#{http_method.upcase}+#{URI.decode(uri).gsub('http://', '')}"
11
+ data = "#{http_method.upcase}+#{URI.decode(uri).gsub(/\Ahttps?:\/\//, '')}"
8
12
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), Filespot.apikey, data)
9
13
  end
10
14
  end
@@ -1,18 +1,37 @@
1
1
  require 'faraday'
2
+ require 'open-uri'
2
3
 
3
4
  module Filespot
5
+ ##
6
+ # Request class wraps HTTP-verbs
4
7
  class Request
5
8
 
9
+ # GET
10
+ #
11
+ # * +api_method+ - API method name
12
+ # * +uri_params+ - contains API method params
6
13
  def self.get(api_method = '', uri_params = {})
7
14
  uri = api_uri('GET', api_method, uri_params)
8
15
  connection(uri).get(uri.query)
9
16
  end
10
17
 
18
+ # POST
19
+ #
20
+ # * +api_method+ - API method name
21
+ # * +uri_params+ - contains API method params
22
+ # * +post_params+ - contains API post params
23
+ #
24
+ # === Example
25
+ # Request.post("/objects", {}, { file: file_io, name: name })
11
26
  def self.post(api_method = '', uri_params = {}, post_params = {})
12
27
  uri = api_uri('POST', api_method, uri_params)
13
28
  connection(uri).post(uri.query, post_params)
14
29
  end
15
30
 
31
+ # DELETE
32
+ #
33
+ # * +api_method+ - API method name
34
+ # * +uri_params+ - contains API method params
16
35
  def self.delete(api_method = '', uri_params = {})
17
36
  uri = api_uri('DELETE', api_method, uri_params)
18
37
  connection(uri).delete(uri.query)
@@ -40,10 +59,11 @@ module Filespot
40
59
  end
41
60
 
42
61
  def self.api_uri(http_method, api_method, params)
43
- uri = URI("http://" + Filespot.url)
62
+ uri = URI("https://" + Filespot.url)
44
63
  uri.path = "/#{Filespot.version}#{api_method}"
45
- uri.query = URI.encode_www_form(init_params(params))
64
+ uri.query = URI.encode_www_form(default_params)
46
65
  uri.query += "&hash=#{Digest.hmac(http_method, uri.to_s)}"
66
+ uri.query += "&#{URI.encode_www_form(params)}" if params.any?
47
67
  uri
48
68
  end
49
69
  end
@@ -1,26 +1,35 @@
1
1
  require 'json'
2
2
 
3
3
  module Filespot
4
+ ##
5
+ # Response class provides API response
4
6
  class Response
5
- attr_reader :code, :status, :data
7
+ # HTTP code
8
+ attr_reader :code
6
9
 
10
+ # response status
11
+ attr_reader :status
12
+
13
+ # response data in JSON format
14
+ attr_reader :data
15
+
16
+ # creates response, checks errors and provides data if success
7
17
  def initialize(response)
18
+ return error if response.status == 500
19
+
20
+ @data = JSON.parse(response.body)
8
21
  if response.status == 200
9
- json_data = JSON.parse(response.body)
10
- @code = json_data.delete('code').to_i
11
- @status = json_data.delete('status')
12
- @data = json_data
13
- else
14
- return_error
22
+ @code = @data.delete('code').to_i
23
+ @status = @data.delete('status')
15
24
  end
25
+ error(response.status) unless @status
16
26
  end
17
27
 
18
28
  private
19
29
 
20
- def return_error
21
- @code = 500
30
+ def error(code=500)
31
+ @code = code
22
32
  @status = 'error'
23
- @data = nil
24
33
  end
25
34
  end
26
35
  end
@@ -1,3 +1,3 @@
1
1
  module Filespot
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
@@ -6,8 +6,9 @@ Gem::Specification.new do |gem|
6
6
  gem.email = "adroff@gmail.com"
7
7
  gem.description = "gem provides platformcraft filespot api"
8
8
  gem.summary = "http://doc.platformcraft.ru/filespot/api/"
9
- gem.homepage = ""
9
+ gem.homepage = "https://github.com/droff/platformcraft-filespot"
10
10
 
11
+ gem.add_development_dependency 'rake'
11
12
  gem.add_development_dependency 'rspec'
12
13
  gem.add_development_dependency 'webmock'
13
14
  gem.add_dependency 'json'
@@ -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,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
+ }
@@ -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
+ }
@@ -1,12 +1,12 @@
1
- require 'spec_helper'
2
-
3
1
  describe Filespot::Download do
4
2
  describe 'Download' do
5
- context 'get_download_task' do
6
- it 'success' do
7
- stub_get('/download_tasks/57011e2a534b44741fc67880', 'download_tasks_id.json')
8
- task = Filespot::Client.get_download_task('57011e2a534b44741fc67880')
9
- expect(task.id).to eq '57011e2a534b44741fc67880'
3
+ context '#get_download_task' do
4
+ let(:task_id) { '57011e2a534b44741fc67880' }
5
+
6
+ it 'task_id found' do
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
10
10
  end
11
11
 
12
12
  it 'task_id not found' do
@@ -14,6 +14,19 @@ describe Filespot::Download do
14
14
  task = Filespot::Client.get_download_task('nil')
15
15
  expect(task).to eq nil
16
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
22
+ end
23
+
24
+ context '#get_download_tasks' do
25
+ it 'get tasks' do
26
+ stub_get('/download_tasks', 'download_tasks.json')
27
+ tasks = Filespot::Client.get_download_tasks
28
+ expect(tasks.count).to eq 2
29
+ end
17
30
  end
18
31
  end
19
32
  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
@@ -1,12 +1,16 @@
1
- require 'spec_helper'
2
-
3
1
  describe Filespot::Digest do
4
- context 'fake data' do
5
- subject { Filespot::Digest.hmac('GET', 'api.platformcraft.ru/1/objects?apiuserid=test&timestamp=1450342665') }
2
+ context '#hmac' do
3
+ let (:apikey) { 'APIUserKey' }
4
+ let (:url) { 'api.platformcraft.ru/1/objects?apiuserid=test&timestamp=1450342665' }
5
+ let (:hash) { OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha256'), apikey, "GET+#{url}") }
6
+
7
+ subject { described_class.hmac('GET', url) }
8
+
9
+
10
+ it 'evaluate correct' do
11
+ allow(Filespot).to receive(:apikey).and_return(apikey)
6
12
 
7
- it '.hmac' do
8
- allow(Filespot).to receive(:apikey) { "APIUserKey" }
9
- expect(subject).to eq '46c5500379d2c09c6f8972c7fd79c27fd7ebf0dd0ab47833a034fd613a4f4d93'
13
+ expect(subject).to eq hash
10
14
  end
11
15
  end
12
16
  end
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe Filespot::Response do
4
2
  context 'errors' do
5
3
  let(:response) { double('response') }
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  require 'webmock/rspec'
2
2
  require 'filespot'
3
+ require 'openssl'
4
+ require 'base64'
3
5
 
4
6
  RSpec.configure do |config|
5
7
  config.expect_with :rspec do |expectations|
@@ -22,11 +24,24 @@ RSpec.configure do |config|
22
24
  end
23
25
  end
24
26
 
27
+ def uri
28
+ /api.platformcraft.ru\/1/
29
+ end
30
+
31
+ def headers
32
+ {
33
+ 'Accept'=>'*/*',
34
+ 'Accept-Encoding'=> 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
35
+ 'User-Agent'=> /Faraday/
36
+ }
37
+ end
38
+
25
39
  def stub_get(api_method, fixture_name)
26
- encoding = 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
27
- agent = 'Faraday v0.9.2'
28
- uri = /api.platformcraft.ru\/1/
29
- stub_request(:get, uri).with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=> encoding, 'User-Agent'=> agent}).to_return(status: 200, body: fixture(fixture_name), headers: {})
40
+ stub_request(:get, uri).with(headers: headers).to_return(status: 200, body: fixture(fixture_name), headers: {})
41
+ end
42
+
43
+ def stub_post(api_method, fixture_name)
44
+ stub_request(:post, uri).with(headers: {'Accept'=>'*/*', 'Accept-Encoding'=> encoding, 'User-Agent'=> agent}).to_return(status: 200, body: fixture(fixture_name), headers: {})
30
45
  end
31
46
 
32
47
  def fixture_path
metadata CHANGED
@@ -1,15 +1,29 @@
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.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-04-16 00:00:00.000000000 Z
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rspec
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -74,7 +88,10 @@ extra_rdoc_files: []
74
88
  files:
75
89
  - ".gitignore"
76
90
  - ".rspec"
91
+ - ".travis.yml"
77
92
  - Gemfile
93
+ - README.md
94
+ - Rakefile
78
95
  - lib/filespot.rb
79
96
  - lib/filespot/client.rb
80
97
  - lib/filespot/client/download.rb
@@ -85,18 +102,22 @@ files:
85
102
  - lib/filespot/response.rb
86
103
  - lib/filespot/version.rb
87
104
  - platformcraft-filespot.gemspec
105
+ - spec/fixtures/download_tasks.json
88
106
  - spec/fixtures/download_tasks_id.json
107
+ - spec/fixtures/download_tasks_id_error.json
89
108
  - spec/fixtures/objects.json
109
+ - spec/fixtures/objects_id.json
110
+ - spec/fixtures/objects_post.json
90
111
  - spec/lib/client/download_spec.rb
91
112
  - spec/lib/client/objects_spec.rb
92
113
  - spec/lib/client_spec.rb
93
114
  - spec/lib/digest_spec.rb
94
115
  - spec/lib/response_spec.rb
95
116
  - spec/spec_helper.rb
96
- homepage: ''
117
+ homepage: https://github.com/droff/platformcraft-filespot
97
118
  licenses: []
98
119
  metadata: {}
99
- post_install_message:
120
+ post_install_message:
100
121
  rdoc_options: []
101
122
  require_paths:
102
123
  - lib
@@ -111,14 +132,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
111
132
  - !ruby/object:Gem::Version
112
133
  version: '0'
113
134
  requirements: []
114
- rubyforge_project:
115
- rubygems_version: 2.6.2
116
- signing_key:
135
+ rubyforge_project:
136
+ rubygems_version: 2.6.14
137
+ signing_key:
117
138
  specification_version: 4
118
139
  summary: http://doc.platformcraft.ru/filespot/api/
119
140
  test_files:
141
+ - spec/fixtures/download_tasks.json
120
142
  - spec/fixtures/download_tasks_id.json
143
+ - spec/fixtures/download_tasks_id_error.json
121
144
  - spec/fixtures/objects.json
145
+ - spec/fixtures/objects_id.json
146
+ - spec/fixtures/objects_post.json
122
147
  - spec/lib/client/download_spec.rb
123
148
  - spec/lib/client/objects_spec.rb
124
149
  - spec/lib/client_spec.rb